|
THat looks really informative
Appreciate your help,
ns
|
|
|
|
|
I created a toolbar using CToolBar and I would like to update its compile-time tool tips at run time. The toolbar is created with:
m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar.LoadToolBar(IDR_MAINFRAME);
I assumed that the following would allow me to retrieve and modify its list of tool tips:
CToolBarCtrl* m_pToolBarCtrl = &m_wndToolBar.GetToolBarCtrl();
CToolTipCtrl* m_pToolTipCtrl = m_pToolBarCtrl->GetToolTips();
But it doesn't work - m_pToolTipCtrl is set to zero. How should I update my tool tips??
Steve
|
|
|
|
|
Where in your code are you calling GetToolBarCtrl . If in the constructor of your dialog or frame, this is too early. Try in OnInitDialog .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I was calling in OnCreate. I tried placing these lines in a button handler, and m_pToolTipCtrl still gets set to NULL.
CToolBarCtrl *m_pToolBarCtrl = &m_wndToolBar.GetToolBarCtrl();
CToolTipCtrl *m_pToolTipCtrl = m_pToolBarCtrl->GetToolTips();
Any ideas?
Steve
|
|
|
|
|
Issue a UpdateData(FALSE) call before attempting to obtain the toolbar control.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi. I would like to create a property sheet that can be used in several different situations. Instead of putting all my cases as separate tabs on the same sheet (there will be more than 7 pages and can grow beyond that), I would like to create a property sheet that can dynamically (???) add a page to the sheet.
I will have the following pages:
Basic Data (appears on all sheets)
Page 1
Page 2
...
Page 7
I would like to have my sheet used dynamically so that if I want "Basic Data" and "Page 1", I just add Page 1. If I want "Basic Data" and "Page 7", I just switch out my previous page and replace it with Page 7. There will only be two pages on the sheet at one time. Is this easy? Is this good?
I could probably try doing it with an expanding single dialog, but the dialog would be rather big and not appear as neat. Would this be simpiler to manage?
Any opinions or place I should look for help?
Thank you,
John
|
|
|
|
|
Maybe you can take advantage of CPropertySheet::AddPage and CPropertySheet::RemovePage .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
as Joaquín said, use that functions and pass a bit mask as a parameter for the contructor in order to decide which pages you want to show.
Last week I used XML documents and the CArray class in order to create dynamic property sheets, and in the contructor I pass the xml document path as an extra parameter.
Hope this enlights you a little bit...
|
|
|
|
|
When debugging my program I receive an 'Unhandled exception in Kernel32.dll 0xC0000005 : Acces violation", and the debugger stops at the next instruction:
lock xadd dword ptr[ecx], eax
Any start point to find out the wrong code?
Thanks.
|
|
|
|
|
Look at the call stack. It looks like a code calling InterlockedExchangeAdd on a NULL pointer, but you may not be calling this directly, it may be a library or a function you're using.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
void CIa_notesDlg::PrintNotes()
CPrintDialog dlg(FALSE);
if (dlg.DoModal() != IDOK)
return;
HDC hPrinterDC = dlg.GetPrinterDC();
if (hPrinterDC == NULL)
AfxMessageBox("Printer not found"/*IDS_SCRIPT_PRINTER_NOT_FOUND*/,MB_OK|MB_ICONSTOP);
else
{
FORMATRANGE fr;
int nHorizRes = GetDeviceCaps(hPrinterDC, HORZRES);
int nVertRes = GetDeviceCaps(hPrinterDC, VERTRES);
int nLogPixelsX = GetDeviceCaps(hPrinterDC, LOGPIXELSX);
int nLogPixelsY = GetDeviceCaps(hPrinterDC, LOGPIXELSY);
LONG lTextLength; // Length of document.
LONG lTextPrinted; // Amount of document printed.
// Ensure the printer DC is in MM_TEXT mode.
SetMapMode ( hPrinterDC, MM_TEXT );
// Rendering to the same DC we are measuring.
ZeroMemory(&fr, sizeof(fr));
fr.hdc = fr.hdcTarget = hPrinterDC;
// Set up the page.
fr.rcPage.left = fr.rcPage.top = 0;
fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440;
fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440;
// Set up 1" margins all around.
fr.rc.left = fr.rcPage.left + 1440; // 1440 TWIPS = 1 inch.
fr.rc.top = fr.rcPage.top + 1440;
fr.rc.right = fr.rcPage.right - 1440;
fr.rc.bottom = fr.rcPage.bottom - 1440;
// Default the range of text to print as the entire document.
fr.chrg.cpMin = 0;
fr.chrg.cpMax = -1;
DOCINFO di;
ZeroMemory(&di, sizeof(di));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T("(Notes)");
di.lpszOutput = NULL; // Do not print to file.
StartDoc(hPrinterDC, &di); // Start the document.
lTextLength = m_notesExistantes.GetTextLength();
do {
StartPage(hPrinterDC); // Start the page.
// Print as much text as can fit on a page. The return value is
// the index of the first character on the next page. Using TRUE
// for the wParam parameter causes the text to be printed.
#ifdef USE_BANDING
lTextPrinted=m_notesExistantes.FormatRange(&fr,FALSE);
m_notesExistantes.DisplayBand(&fr.rc);
#else
lTextPrinted=m_notesExistantes.FormatRange(&fr,TRUE);
#endif
EndPage(hPrinterDC); // Print last page.
// If there is more text to print, adjust the range of characters
// to start printing at the first character of the next page.
if (lTextPrinted < lTextLength)
{
fr.chrg.cpMin = lTextPrinted;
fr.chrg.cpMax = -1;
}
} while (lTextPrinted < lTextLength);
// Tell the control to release cached information.
m_notesExistantes.FormatRange(NULL,0);
EndDoc (hPrinterDC);
}
-------------
-= Nasty_p =-
|
|
|
|
|
You might want to give us a bit more details about your problem. Does the code compile? Does it run? What happens when it runs? What does it print? etc.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
The code compiles and runs but nothing prints.
The problem appears to be around the following part:
lTextPrinted = m_notesExistantes.FormatRange(&fr,FALSE);
m_notesExistantes.DisplayBand(&fr.rc);
lTextPrinted is alwayz equal to 0 and the "DisplayBand" function returns 0 (meaning that nothing was printed...).
As a result, i end up printing white pages 'cause of the "while (lTextPrinted < lTextLength);" witch always remain TRUE...
I have no clue since the same piece of code seems to be working fine for other forum members.
-------------
-= Nasty_p =-
|
|
|
|
|
Still haven't found what the problem was....
I could really need a hand you guys!
-------------
-= Nasty_p =-
|
|
|
|
|
I am in need of a practical example of forward declaring a class. I have written a couple of mini programs using forward declare but am unable to access or modify member variables.
When the programs run I get to the classes ok,
but when I try to access a variable in the class I get a page fault.
|
|
|
|
|
That has nothing to do with forward declaration. If it compiles, then the compiler is properly resolving the forward declarations. It sounds more like you forgot to create an instance of the object--you're accessing it before it's instantiated:
wrong:
Foo* foo;
foo->data=1;
right:
Foo* foo=new Foo();
foo->data=1;
If that doesn't help, can you give an example of your class and your usage?
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator.
|
|
|
|
|
Thanks, I was missing Foo* foo=new Foo();
All of the examples I viewed, except yours, showed how to
Forward Declare, but not how to use it.
|
|
|
|
|
I suspect you have the classical pointer problem - you have a pointer that does not point to a valid object. Assuming we have two classes A and B and both must know of each other. Assume also that class A will own an instance of class B and class B will hold a reference (a pointer) to A then this would work:
#include <B.h>
class A
{
public:
A( );
void DoStuff( );
private:
B m_B;
};
class A;
class B
{
public:
B( A* pA );
void DoOtherStuff( );
private:
A* m_pA;
};
#include <B.h>
#include <A.h>
B::B( A* pA )
: m_pA( pA )
{
}
void B::DoOtherStuff( )
{
}
#include <A.h>
A::A( )
: m_B( this )
{
}
void A::DoStuff( )
{
m_B.DoOtherStuff( );
}
Of course this might not be the design that you want - you might have a design where two otherwise unrelated objects (i.e. class A does not own an instance of class B) have to be able to communicate to each other. As always you must think more in terms of instances of classes rather than classes themselves. I.e. it is technically not the class A that wants to talk to B but rather an instance of class A that wants to talk to a specific instance of class B.
Hope this helps somewhat.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hi,
I have a CListView where I want to change the style for the CHeaderCtrl.
How do I do that? I've tried to add styles in PreCreateWindow but it doesn't work. For example:
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs) <br />
{<br />
cs.style &= ~HDS_FULLDRAG;<br />
return CListView::PreCreateWindow(cs);<br />
}<br />
Is this the right way to set create styles for the header control?
/P
|
|
|
|
|
Call CListCtrl::GetHeaderCtrl(), then modify the header control itself.
Know Jesus, no peace. No Jesus, know peace.
|
|
|
|
|
Does anybody know how to achieve desktop resizing effect similar for example to what infogate or netzero do?
JRN
|
|
|
|
|
I'm not sure what netzero does, but I do know that creating an AppBar (like the taskbar) can change the size of the Work Area of the desktop.
Chris Richardson
|
|
|
|
|
Thanks a lot!. Here's a link to an article on how to create AppBars:
http://www.microsoft.com/msj/defaulttop.asp?page=/msj/archive/s274.htm
|
|
|
|
|
Hi,
I wanna load some overloeded function exported from a dll by using LoadLibrary and GetProcAddress.
This is the way the exported function is declared in the dll:
BOOL CDllClass::CoolFunction(const char* pszChar,DWORD dwProperty)
{
...
}
BOOL CDllClass::CoolFunction(LPCWSTR pszChar,DWORD dwProperty)
{
...
}
The CDllClass is exported with __declspec(dllexport)
I try to load CoolFunction in this way:
typedef BOOL (CALLBACK* LPFNFUNC)(const char*,DWORD);
...
HMODULE m_hDll = LoadLibrary("mydll.dll");
if (!m_hDll)
{
AfxMessageBox("Error: Cannot find mydll.dll");
return;
}
LPFNFUNC fnMyFunc = (LPFNFUNC)GetProcAddress(m_hDll,"CoolFunction");
if (fnMyFunc == NULL)
{
AfxMessageBox("Error: fnMyFunc == NULL");
return;
}
Problem: GetProcAddress returns NULL.
Question: How does GetProcAddress know which overloeded function to load? Is there some other problem in this code snippet?
Thanks
R.
|
|
|
|
|
Hi, you should use the CDllClass ( why export it otherwise ) or you should make the Coolfunctions static. ( Right now they only have CDllClass scope ).
|
|
|
|