Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

mnsel.c

Go to the documentation of this file.
00001 /**************************** Module Header ********************************\ 00002 * Module Name: mnsel.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * Menu Selection Routines 00007 * 00008 * History: 00009 * 10-10-90 JimA Cleanup. 00010 * 03-18-91 IanJa Window revalidation added 00011 \***************************************************************************/ 00012 00013 #include "precomp.h" 00014 #pragma hdrstop 00015 00016 /***************************************************************************\ 00017 * xxxSendMenuSelect 00018 * 00019 * ! 00020 * 00021 * Revalidation notes: 00022 * o Assumes pMenuState->hwndMenu is non-NULL and valid 00023 * 00024 * Note: if pMenu==SMS_NOMENU, idx had better be MFMWFP_NOITEM! 00025 * 00026 * History: 00027 \***************************************************************************/ 00028 00029 void xxxSendMenuSelect( 00030 PWND pwndNotify, 00031 PWND pwndMenu, 00032 PMENU pMenu, 00033 int idx) 00034 { 00035 UINT cmd; // Menu ID if applicable. 00036 UINT flags; // MF_ values if any 00037 MSG msg; 00038 PMENUSTATE pMenuState; 00039 00040 CheckLock(pwndNotify); 00041 CheckLock(pwndMenu); 00042 00043 00044 /* 00045 * We must be hacking or passing valid things. 00046 */ 00047 UserAssert((pMenu != SMS_NOMENU) || (idx == MFMWFP_NOITEM)); 00048 00049 00050 if ((idx >= 0) && (pMenu->cItems > (UINT)idx)) { 00051 PITEM pItem = &(pMenu->rgItems[idx]); 00052 00053 flags = (pItem->fType & MFT_OLDAPI_MASK) | 00054 (pItem->fState & MFS_OLDAPI_MASK); 00055 00056 if (pItem->spSubMenu != NULL) 00057 flags |= MF_POPUP; 00058 00059 flags &= (~(MF_SYSMENU | MF_MOUSESELECT)); 00060 00061 /* 00062 * WARNING! 00063 * Under Windows the menu handle was always returned but additionally 00064 * if the menu was a pop-up the pop-up menu handle was returned 00065 * instead of the ID. In NT we don't have enough space for 2 handles 00066 * and flags so if it is a pop-up we return the pop-up index 00067 * and the main Menu handle. 00068 */ 00069 00070 if (flags & MF_POPUP) 00071 cmd = idx; // index of popup-menu 00072 else 00073 cmd = pItem->wID; 00074 00075 pMenuState = GetpMenuState(pwndNotify); 00076 if (pMenuState != NULL) { 00077 if (pMenuState->mnFocus == MOUSEHOLD) 00078 flags |= MF_MOUSESELECT; 00079 00080 if (pMenuState->fIsSysMenu) 00081 flags |= MF_SYSMENU; 00082 00083 } 00084 } else { 00085 /* 00086 * idx assumed to be MFMWFP_NOITEM 00087 */ 00088 if (pMenu == SMS_NOMENU) { 00089 00090 /* 00091 * Hack so we can send MenuSelect messages with MFMWFP_MAINMENU 00092 * (loword(lparam)=-1) when the menu pops back up for the CBT people. 00093 */ 00094 flags = MF_MAINMENU; 00095 } else { 00096 flags = 0; 00097 } 00098 00099 cmd = 0; // so MAKELONG(cmd, flags) == MFMWFP_MAINMENU 00100 pMenu = 0; 00101 idx = -1; // so that idx+1 == 0, meaning nothing for zzzWindowEvent() 00102 } 00103 00104 /* 00105 * Call msgfilter so help libraries can hook WM_MENUSELECT messages. 00106 */ 00107 msg.hwnd = HW(pwndNotify); 00108 msg.message = WM_MENUSELECT; 00109 msg.wParam = (DWORD)MAKELONG(cmd, flags); 00110 msg.lParam = (LPARAM)PtoH(pMenu); 00111 if (!_CallMsgFilter((LPMSG)&msg, MSGF_MENU)) { 00112 xxxSendNotifyMessage(pwndNotify, WM_MENUSELECT, msg.wParam, msg.lParam); 00113 } 00114 00115 if (FWINABLE() && pwndMenu) { 00116 xxxWindowEvent(EVENT_OBJECT_FOCUS, pwndMenu, 00117 ((pwndMenu != pwndNotify) ? OBJID_CLIENT : ((flags & MF_SYSMENU) ? OBJID_SYSMENU : OBJID_MENU)), 00118 idx+1, 0); 00119 } 00120 }

Generated on Sat May 15 19:40:51 2004 for test by doxygen 1.3.7