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

    Question Change caption on checkbox button at Runtime in VC++ 7.0

    I am looking for a way to modify the caption of a checkbox in a MFC dialog at runtime.

    // With associated member variable to the checkbox
    m_Checkbox.SetWindowText("Caption");

    does not work. GetWindowText shows an empty string and

    SetWindowText does nothing.

    The mfc help says "If the window is a control, the text within the contol is set" (not the caption)

    How to set the caption? Am I doing something wrong in SetWindowsText or is it not the correct way?

    Thank you for your help

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871
    Check to see that if control variable points to control properly or not.
    Try using GetLastError and determine cause in Error Lookup utility.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #3
    Join Date
    Apr 2004
    Posts
    4
    Thank you for your suggestion.
    Since it was a simple dialog, I restarted from scratch and it worked, some file must have been corrupt.

    >Check to see that if control variable points to control properly or not.

    I was wondering how to do this. How do you determine the connection between the appname.rc, the apnname.h and the Resource.h file. In the apnname.h file I only see the declaration of the variables, but not to which control they are linked.

  4. #4
    Join Date
    Jul 2003
    Posts
    116
    posted by petermcwerner

    but not to which control they are linked.
    in your DoDataExchange(CDataExchange* pDX)

    there will be lines like this that determine the linking and subclassing behind the scenes.

    DDX_Control(pDX, IDC_BUTTON1, m_Btn);

  5. #5
    Join Date
    Apr 2004
    Posts
    4

    That solves it

    Thank you all for the help

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