CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    4

    Changing the Caption for common control.

    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

  2. #2
    Join Date
    Apr 1999
    Posts
    8

    Re: Changing the Caption for common control.

    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
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured