Click to See Complete Forum and Search --> : Changing the Caption for common control.


Maikeru
April 15th, 1999, 02:30 AM
Hi. I'm implementing this "change color" common dialog box to change the colour of some polygons. anyway, i used:

CColorDialog cDlg;

...(initialising)...
cDlg.DoModal;

note that my dialog is created with "NULL"(no parent) as parameter to parent's handle.
everything's fine except for the dull looking "Color" caption. I tried to change it to "Set Triangle Color" using:

cDlg.SetWindowText("Set Triangle Color");

...but the program reported an "Assert error". I traced the program and apparently it seems that in the first line of CWnd::SetWindowText, which goes something like...

ASSERT(::IsWindow(m_hWnd));

my program got in trouble...

what's wrong with my code, or rather, is there another(better, of course) way to change the default caption of the color common dialog box??? Thanks!

(^_^)
Maikeru Shimu

M Grundberg
April 15th, 1999, 02:42 AM
Hi,
The SetWindowText function sends a WM_SETTEXT message to the dialog window, but the problem is the window isn't created until you call DoModal().
So I'd suggest you derive your own class from CColorDialog and override the OnInitDialog() function. There you can safely call SetWindowText().



/Michael Grundberg
M.Sc. Computer Science
Visionova IT-System, Sweden
michael@itsystem.se