Use on the dialog

zhaozj2021-02-16  51

In the past few days, in order to write a small program, add a toolbar and menu (Menu) on the dialog, online friendly multi-program teach you how to add toolbars and menus on the dialog, but very little mention The toolbar and menu adds on_update_command_ui mapping, and later, I have been searching for a long time, I found some methods, it is more complicated. In fact, just add the following functions in the dialog class.

BOOL CMyDlg :: ContinueModal () {if (m_wndtoolbar.IsWindowVisible ()) {CFrameWnd * pParent = (CFrameWnd *) m_wndtoolbar.GetParent (); if (pParent) m_wndtoolbar.OnUpdateCmdUI (pParent, (WPARAM) TRUE);}

CMenu * PMainMenu = getMenu (); ccmdui cmdui; for (uint n = 0; n getMenuItemcount (); n) {cmenu * psubmenu = PMainMenu-> getSubmenu (n); cmdui.m_nIndexmax = psubmenu > GetMenuItemCount (); for (uint i = 0; i getMenuitemid (i); cmdui.m_pmenu = psubmenu; cmdui.doupdate (this, false);}} Return CDIALOG :: ContinueModal ();} then add Bool ContinueModal (), add BOOL ContinueModal (); so you can use n_update_command_ui.

In addition, reminding that some articles use the WM_KICKIDLE message. I found that the CPU usage was 100% after use. Needless to make

The function is another shortcoming:

If you switch the view with a keyboard, this function does not respond, that is, if you use the right-click menu, if you include a variable according to the VIEW, it is not possible.

转载请注明原文地址:https://www.9cbs.com/read-27375.html

New Post(0)