CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2003
    Location
    PA
    Posts
    58

    Change dialog caption

    I want to change the dialog text while as the new dialog is being created. I tried SetWindowText("yada"). Doesnt seem to work. How can I do this? And do I do it somwhere like OnInitDialog()?

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354
    yeah. SetWindowText in OnInitDialog should work.

  3. #3
    Join Date
    Sep 2003
    Location
    PA
    Posts
    58
    Do I need to call something to refresh the window then? Nothing happens. Also... I actually inherit from CPropertyPage and not CDialog, Because I am using it as a tab.

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354
    Ok. Let me get this right ?

    You are using a PropertyPage within a property sheet.
    Do you want to change the text of the Sheet or do you want to to change the text of the tab ?

    For e.g.
    ------------------------------------------------
    Property Sheet title
    ------------------------------------------------


    |-------------|--------------|
    |Pagetitle1| Pagetitle2 |
    |-------------|--------------|

  5. #5
    Join Date
    Sep 2003
    Location
    PA
    Posts
    58
    I would like the change the name of the tab... but the tab name will not be derminted until runtime.

  6. #6
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354
    Note that in a propertysheet, he tabs shown for each page is a tab control window. So you would have to manipulate the tab control's items. That is the reason why , even if SetWindowText won't fail, it has no effect on the appearance on the tabs.

    What you need to do is something like this. From MSDN sample:

    When you want to change the text, say in OnInitDialog()...( you could do it any time after the property page is created )

    TCITEM tcItem;
    CString pszString = "Test page title";

    CPropertySheet* pSheet = (CPropertySheet*)GetParent();
    ASSERT_VALID(pSheet);

    int nPageIndex = GetPageIndex(this);
    // Get the page text.
    tcItem.mask = TCIF_TEXT;
    pSheet->GetTabControl()->GetItem(nPageIndex, &tcItem);

    // Set the new text for the item.
    tcItem.pszText = pszString.GetBuffer(256);

    // Set the item in the tab control.
    pSheet->GetTabControl()->SetItem(nPageIndex, &tcItem);

  7. #7
    Join Date
    Sep 2003
    Location
    PA
    Posts
    58
    I changed int nPageIndex = GetPageIndex(this); to int nPageIndex = pSheet->GetPageIndex(this); and it worked beautifully. Thanks a lot.

  8. #8
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354
    Originally posted by mjm461
    I changed int nPageIndex = GetPageIndex(this); to int nPageIndex = pSheet->GetPageIndex(this);
    Yeah. My bad

  9. #9
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635
    Originally posted by mjm461
    I would like the change the name of the tab... but the tab name will not be derminted until runtime.
    Why didn't you ask this in the first place?

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