Dynamically changing text of a menu in a Dialog box 
Author Message
 Dynamically changing text of a menu in a Dialog box

Hi,

i have been lokking here for the old message here to find any clues
tio solve my problem, but none of them work on Pocket PC 2002
(emulator, COMPAQ or Loox).

what i am trying to do seems vey simple to me :
changing the text of the menu dynamically depending on the langage the
user installed on his device.

i have no trouble for the sub-menu, but no-way to do it for the base
menu in the command tool bar.

i try 2 ways :

- pmnuMainMenu->ModifyMenu(0, MF_BYPOSITION,
pmnuMainMenu->GetMenuItemID(0), _T("toto") ) ;

to change the first item of the Menu (the traditionnaly File), it does
nothing, but by the way i loose the sub-menu traditionnally associated
with him.

-   TBBUTTONINFO tbbi = {0} ;
    tbbi.cbSize = sizeof(TBBUTTONINFO) ;
    tbbi.dwMask = TBIF_TEXT;
    TCHAR szBuf[255] ;
    tbbi.pszText = szBuf ;
    tbbi.cchText = 255 ;
    tbbi.cbSize = sizeof(TBBUTTONINFO) ;
    int iResult = m_wndCommandBar.SendMessage(TB_GETBUTTONINFO,
pmnuMainMenu->GetMenuItemID(0), (LPARAM)&tbbi) ;

    tbbi.pszText = _T("toto");
    iResult = m_wndCommandBar.SendMessage(TB_SETBUTTONINFO,
pmnuMainMenu->GetMenuItemID(0), (LPARAM)&tbbi) ;

do nothing because my SendMessage return an error.

to be more precise my beginig code is :

        if(!m_wndCommandBar.Create(this) || ! (pmnuMainMenu=
m_wndCommandBar.InsertMenuBar(IDR_MENUBAR_MAINDLG, 0) ) ||
!m_wndCommandBar.AddAdornments())
        {
                TRACE0("Failed to create CommandBar\n");
                return -1;      // fail to create
        }

        m_wndCommandBar.LoadToolBar(IDR_TOOLBAR_MAIN);
        m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() |
                CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

Hope somebody will answer me to uderstand what his my mistake....



Sun, 28 Aug 2005 21:59:41 GMT  
 Dynamically changing text of a menu in a Dialog box

The second approach should work. I think the problem is here:

Quote:
>     iResult = m_wndCommandBar.SendMessage(TB_SETBUTTONINFO,
> pmnuMainMenu->GetMenuItemID(0), (LPARAM)&tbbi) ;

I don't think GetMenuItemID is the right function to get ID of the first
button on the toolbar. Try TB_GETBUTTON instead. This message allows you to
get some info on a button using its zero-based index. ID will be returned in
TBBUTTON::idCommand. Then use this id with your TB_GET/SETBUTTONINFO
messages.

--
Sincerely,
Alexander


http://www.RSDN.ru - Russian Software Developer Network


Quote:
> Hi,

> i have been lokking here for the old message here to find any clues
> tio solve my problem, but none of them work on Pocket PC 2002
> (emulator, COMPAQ or Loox).

> what i am trying to do seems vey simple to me :
> changing the text of the menu dynamically depending on the langage the
> user installed on his device.

> i have no trouble for the sub-menu, but no-way to do it for the base
> menu in the command tool bar.

> i try 2 ways :

> - pmnuMainMenu->ModifyMenu(0, MF_BYPOSITION,
> pmnuMainMenu->GetMenuItemID(0), _T("toto") ) ;

> to change the first item of the Menu (the traditionnaly File), it does
> nothing, but by the way i loose the sub-menu traditionnally associated
> with him.

> -   TBBUTTONINFO tbbi = {0} ;
>     tbbi.cbSize = sizeof(TBBUTTONINFO) ;
>     tbbi.dwMask = TBIF_TEXT;
>     TCHAR szBuf[255] ;
>     tbbi.pszText = szBuf ;
>     tbbi.cchText = 255 ;
>     tbbi.cbSize = sizeof(TBBUTTONINFO) ;
>     int iResult = m_wndCommandBar.SendMessage(TB_GETBUTTONINFO,
> pmnuMainMenu->GetMenuItemID(0), (LPARAM)&tbbi) ;

>     tbbi.pszText = _T("toto");
>     iResult = m_wndCommandBar.SendMessage(TB_SETBUTTONINFO,
> pmnuMainMenu->GetMenuItemID(0), (LPARAM)&tbbi) ;

> do nothing because my SendMessage return an error.

> to be more precise my beginig code is :

> if(!m_wndCommandBar.Create(this) || ! (pmnuMainMenu=
> m_wndCommandBar.InsertMenuBar(IDR_MENUBAR_MAINDLG, 0) ) ||
> !m_wndCommandBar.AddAdornments())
> {
> TRACE0("Failed to create CommandBar\n");
> return -1;      // fail to create
> }

> m_wndCommandBar.LoadToolBar(IDR_TOOLBAR_MAIN);
> m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() |
> CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

> Hope somebody will answer me to uderstand what his my mistake....



Sun, 28 Aug 2005 22:16:30 GMT  
 Dynamically changing text of a menu in a Dialog box

Quote:
> The second approach should work. I think the problem is here:

> >     iResult = m_wndCommandBar.SendMessage(TB_SETBUTTONINFO,
> > pmnuMainMenu->GetMenuItemID(0), (LPARAM)&tbbi) ;

> I don't think GetMenuItemID is the right function to get ID of the first
> button on the toolbar. Try TB_GETBUTTON instead. This message allows you to
> get some info on a button using its zero-based index. ID will be returned in
> TBBUTTON::idCommand. Then use this id with your TB_GET/SETBUTTONINFO
> messages.

i try it but the text of my main menu item, still doesn't change. But
now there is no errors with the send messages....

thanks again.
Arnaud.



Mon, 29 Aug 2005 16:05:20 GMT  
 Dynamically changing text of a menu in a Dialog box
Sorry, for my first post !

it works fine !!!

thanks a lot !!!!
Arnaud.



Mon, 29 Aug 2005 16:25:50 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Dynamically change menu text

2. URGENT! Dynamically change File menu text

3. How do I change the caption on an MFC Dialog box (dynamically)

4. Change title for dialog box dynamically

5. change title for dialog box dynamically

6. How to change the color,size,font of text in a dialog box

7. How to change statit text in dialog box

8. Changing text in dialog box

9. How to change the color,size,font of text in a dialog box

10. Q: Changing a dialog box's title text

11. changing the font for text items in a dialog box

12. Problems with List box in dynamically created dialog box

 

 
Powered by phpBB® Forum Software