Check message response and toolbar loading in the dialog box

Source: Internet
Author: User
When loading a menu in the dialog box, check on the menu cannot be implemented. This is caused by the failure to update the UI.
Therefore, you must manually add the following code:

Void cvrminedlg: oninitmenupopup (cmenu * ppopupmenu, uint nindex, bool bsysmenu)
{
// Add this message ing so that the dialog box-based menu can be updated using on_update_command_ui
Assert (ppopupmenu! = NULL );
// Check the Enabled state of various menu items.

Ccmdui state;
State. m_pmenu = ppopupmenu;
Assert (State. m_pother = NULL );
Assert (State. m_pparentmenu = NULL );

// Determine If menu is popup in top-level menu and set m_pother
// It If so (m_pparentmenu = NULL indicates that it is secondary popup ).
Hmenu hparentmenu;
If (afxgetthreadstate ()-> m_htrackingmenu = ppopupmenu-> m_hmenu)
State. m_pparentmenu = ppopupmenu; // parent = Child for tracking Popup.
Else if (hparentmenu =: getmenu (m_hwnd ))! = NULL)
{
Cwnd * pparent = this;
// Child windows don't have menus -- need to go to the top!
If (pparent! = NULL &&
(Hparentmenu =: getmenu (pparent-> m_hwnd ))! = NULL)
{
Int nindexmax =: getmenuitemcount (hparentmenu );
For (INT nindex = 0; nindex <nindexmax; nindex ++)
{
If (: getsubmenu (hparentmenu, nindex) = ppopupmenu-> m_hmenu)
{
// When popup is found, m_pparentmenu is containing menu.
State. m_pparentmenu = cmenu: fromhandle (hparentmenu );
Break;
}
}
}
}

State. m_nindexmax = ppopupmenu-> getmenuitemcount ();
For (State. m_nindex = 0; State. m_nindex <state. m_nindexmax;
State. m_nindex ++)
{
State. m_nid = ppopupmenu-> getmenuitemid (State. m_nindex );
If (State. m_nid = 0)
Continue; // menu separator or invalid cmd-Ignore it.

Assert (State. m_pother = NULL );
Assert (State. m_pmenu! = NULL );
If (State. m_nid = (uint)-1)
{
// Possibly a popup menu, route to first item of that Popup.
State. m_psubmenu = ppopupmenu-> getsubmenu (State. m_nindex );
If (State. m_psubmenu = NULL |
(State. m_nid = state. m_psubmenu-> getmenuitemid (0) = 0 |
State. m_nid = (uint)-1)
{
Continue; // first item of popup can't be routed.
}
State. doupdate (this, true); // popups are never auto disabled.
}
Else
{
// Normal menu item.
// Auto enable/disable if frame window has m_bautomenuenable
// Set and command is _ not _ A system command.
State. m_psubmenu = NULL;
State. doupdate (this, false );
}

// Adjust for menu deletions and additions.
Uint ncount = ppopupmenu-> getmenuitemcount ();
If (ncount <state. m_nindexmax)
{
State. m_nindex-= (State. m_nindexmax-ncount );
While (State. m_nindex <ncount &&
Ppopupmenu-> getmenuitemid (State. m_nindex) = state. m_nid)
{
State. m_nindex ++;
}
}
State. m_nindexmax = ncount;
}
}

It is a little troublesome to add a toolbar in the dialog box,
A toolbar cannot floating or docking, or be automatically placed together with two toolbars.
Unless you change the code.
I have not found a good solution for the moment.
M_wndtoolbar.create (this); values (idr_toolbar1); values (sw_show); values (cbrs_align_top | cbrs_tooltips | cbrs_flyby | values); repositionbars (values, values, 0 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.