Checking menu items in dialog based app. 
Author Message
 Checking menu items in dialog based app.

 I can't seem to check menu items with the code I have below in a dialoged
based application.  This same code however, will work in an SDI or MDI
application.  This code is very simplictic using ON_UPDATE _COMMAND
handlers.  Say it ain't so that you can't check menu items in a dialog app.
Jim Kopkowski

oid CTestDlgApp::OnUpdateViewAlertcast(CCmdUI* pCmdUI)
{
 pCmdUI->SetCheck(1);

Quote:
}

void CTestDlgApp::OnViewScorecast()
{
 // TODO: Add your command handler code here

Quote:
}

void CTestDlgApp::OnUpdateViewScorecast(CCmdUI* pCmdUI)
{
 pCmdUI->SetCheck(1);
Quote:
}



Sun, 19 Mar 2000 03:00:00 GMT  
 Checking menu items in dialog based app.

You can easily use WM_INITPOPUP and Usual CMenu::SetCheckItem to do
your stuff.



Quote:
> I can't seem to check menu items with the code I have below in a dialoged
>based application.  This same code however, will work in an SDI or MDI
>application.  This code is very simplictic using ON_UPDATE _COMMAND
>handlers.  Say it ain't so that you can't check menu items in a dialog app.
>Jim Kopkowski


Girish Bharadwaj B.V.
Software Developer
http://members.tripod.com/~GBharadwaj/index.html




Sun, 19 Mar 2000 03:00:00 GMT  
 Checking menu items in dialog based app.

Quote:

> I can't seem to check menu items with the code I have below in a dialoged
>based application.  This same code however, will work in an SDI or MDI
>application.  This code is very simplictic using ON_UPDATE _COMMAND
>handlers.  Say it ain't so that you can't check menu items in a dialog app.

OK, I won't say it. That won't change the reality though <g>. The
problem is that the command-ui dispatching stuff is in the cframewnd
class, but not in the cdialog. I have heard of people copying chunks
of code from CFrameWnd to try and get this working, but I always
figured that life was too short for that and simply used the old
fashioned API calls to do my checking and enabling.

Bob Moore [WinSDK MVP]



Sun, 19 Mar 2000 03:00:00 GMT  
 Checking menu items in dialog based app.

You can do the ON_UPDATE_COMMAND operations in a dialog box, I believe. The
ON_UPDATE_COMMAND handlers are called during idle time processing in the MFC
THRDCORE.CPP file. What you need to do in the dialog application is first
trap the WM_INITDIALOG message and store the pointer to the dialog box class
in the CWinApp::m_pMainWnd variable. If the dialog box is registered as the
main window, the update command messages will be sent to the dialog box.
Next, you need to trap the WM_IDLEUPDATECMDUI message. This is an
MFC-defined message in AFXPRIV.H (a description of this message is in the
MFC technotes, somewhere in the 20's I believe). From the handler for
WM_IDLEUPDATECMDUI you can use the CCmdUI mechanism to handle the updating.
Refer to the handler for CFrameWnd for assistance. It's really easy and will
only take a few minutes to implement. That should be all that you need to
do. I haven't tried this though, so it is only a best guess, but according
to the MFC code, it should work.

Michael Collins

Quote:


>> I can't seem to check menu items with the code I have below in a dialoged
>>based application.  This same code however, will work in an SDI or MDI
>>application.  This code is very simplictic using ON_UPDATE _COMMAND
>>handlers.  Say it ain't so that you can't check menu items in a dialog
app.

>OK, I won't say it. That won't change the reality though <g>. The
>problem is that the command-ui dispatching stuff is in the cframewnd
>class, but not in the cdialog. I have heard of people copying chunks
>of code from CFrameWnd to try and get this working, but I always
>figured that life was too short for that and simply used the old
>fashioned API calls to do my checking and enabling.

>Bob Moore [WinSDK MVP]



Sun, 19 Mar 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to check a menu item in a dialog based application

2. Checking Menu Items in Dialog Based Application

3. Q: Set Check Mark in Menu Item In Based Dialog Application

4. Checked menu items in a dialog based application

5. Dialog app - checking a menu item ??

6. Updating menu items in dialog-based apps: Solution

7. Disabling main menu items in MFC based apps

8. Dialog based app menu

9. Dialog Based Apps - Menu & Windows :: MFC

10. Pop up menu in Dialog based App

11. trying to add menu to dialog based app

12. Newbie : Adding Menu Bar and Tool Bar to Dialog Based App

 

 
Powered by phpBB® Forum Software