CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Set Caption

  1. #1
    Join Date
    Oct 2003
    Posts
    72

    Set Caption

    Can you tell me how to set from code a window dialog caption?
    I have tried to use GetDlgItem to get the reference of the window and SetWindowText to set the string but it gives me an error.

  2. #2
    Join Date
    Jul 2003
    Posts
    116
    The question is rather unclear here, from things it seems that you donot have a pointer to your dialog instance.... is it so??
    if yes ...
    I doubt the use of GetDlgItem for finding something in a window, but the case here is that u are on a lookout for the dialog itself, wouldnt it be strange to use GetDlgItem() for finding a dialog.
    Use EnumChildWindows() and find the dialog if you donot have the reference to the dialog. winth any matching criteria like the class name or anyother property.

    otherwise clear the question by elaborating a little, also give the error information.
    cheers

  3. #3
    Join Date
    Oct 2003
    Posts
    72
    Excuse me you're right

    CWnd *a;
    a=m_pDlg->GetDlgItem(IDD_MYWINDOW);
    a->SetWindowText("some text");

    Where m_pDlg is a pointer at my dialog class


    The error is "Memory could not be read "

  4. #4
    what's IDD_MYWINDOW? Your dialog ID?

    m_pDlg->SetWindowText("some text");
    Best Api Monitor tool.
    Trace the target program automatically and monitor the parameters of all API and COM interfaces.

    Auto Debug for Windows 4.0
    Auto Debug for .Net
    http://www.autodebug.com/

  5. #5
    Join Date
    Oct 2003
    Posts
    72
    Yes.

    I have used this code because for other controls(static texts,buttons etc),it works and I manage to set caption.

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