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

mnapi.c

Go to the documentation of this file.
00001 /**************************** Module Header ********************************\ 00002 * Module Name: mnapi.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * Rarely Used Menu API Functions 00007 * 00008 * History: 00009 * 10-10-90 JimA Cleanup. 00010 * 03-18-91 IanJa Window revaliodation added 00011 \***************************************************************************/ 00012 00013 #include "precomp.h" 00014 #pragma hdrstop 00015 00016 00017 /***************************************************************************\ 00018 * xxxSetMenu 00019 * 00020 * Sets the given window's menu to the menu specified by the pMenu 00021 * parameter. If pMenu is Null, the window's current menu is removed (but 00022 * not destroyed). 00023 * 00024 * History: 00025 \***************************************************************************/ 00026 00027 BOOL xxxSetMenu( 00028 PWND pwnd, 00029 PMENU pMenu, 00030 BOOL fRedraw) 00031 { 00032 CheckLock(pwnd); 00033 CheckLock(pMenu); 00034 00035 if (!TestwndChild(pwnd)) { 00036 00037 LockWndMenu(pwnd, &pwnd->spmenu, pMenu); 00038 00039 /* 00040 * only redraw the frame if the window is non-minimized -- 00041 * even if it's not visible, we need RedrawFrame to recalc the NC size 00042 * 00043 * Added a check for (redraw) since the MDISetMenu() only needs to 00044 * set the menu and not perform any redraws. 00045 */ 00046 if (!TestWF(pwnd, WFMINIMIZED) && fRedraw) 00047 xxxRedrawFrame(pwnd); 00048 00049 return TRUE; 00050 } 00051 00052 RIPERR0(ERROR_CHILD_WINDOW_MENU, RIP_VERBOSE, ""); 00053 return FALSE; 00054 } 00055 00056 00057 /***************************************************************************\ 00058 * xxxSetSystemMenu 00059 * 00060 * ! 00061 * 00062 * History: 00063 \***************************************************************************/ 00064 00065 BOOL xxxSetSystemMenu( 00066 PWND pwnd, 00067 PMENU pMenu) 00068 { 00069 CheckLock(pwnd); 00070 CheckLock(pMenu); 00071 00072 if (TestWF(pwnd, WFSYSMENU)) { 00073 PMENU pmenuT = pwnd->spmenuSys; 00074 if (LockWndMenu(pwnd, &pwnd->spmenuSys, pMenu)) 00075 _DestroyMenu(pmenuT); 00076 00077 MNPositionSysMenu(pwnd, pMenu); 00078 00079 return TRUE; 00080 } 00081 00082 RIPERR0(ERROR_NO_SYSTEM_MENU, RIP_VERBOSE, ""); 00083 return FALSE; 00084 } 00085 00086 00087 /***************************************************************************\ 00088 * xxxSetDialogSystemMenu 00089 * 00090 * ! 00091 * 00092 * History: 00093 \***************************************************************************/ 00094 00095 BOOL xxxSetDialogSystemMenu( 00096 PWND pwnd) 00097 { 00098 PMENU pMenu; 00099 00100 CheckLock(pwnd); 00101 00102 pMenu = pwnd->head.rpdesk->spmenuDialogSys; 00103 if (pMenu == NULL) { 00104 pMenu = xxxLoadSysDesktopMenu (&pwnd->head.rpdesk->spmenuDialogSys, ID_DIALOGSYSMENU); 00105 } 00106 00107 LockWndMenu(pwnd, &pwnd->spmenuSys, pMenu); 00108 00109 return (pMenu != NULL); 00110 } 00111 00112 /***************************************************************************\ 00113 * xxxEndMenu 00114 * 00115 * ! 00116 * Revalidation notes: 00117 * o xxxEndMenu must be called with a valid non-NULL pwnd. 00118 * o Revalidation is not required in this routine: pwnd is used at the start 00119 * to obtain pMenuState, and not used again. 00120 * 00121 * History: 00122 \***************************************************************************/ 00123 00124 void xxxEndMenu( 00125 PMENUSTATE pMenuState) 00126 { 00127 BOOL fMenuStateOwner; 00128 PPOPUPMENU ppopup; 00129 PTHREADINFO ptiCurrent; 00130 00131 if ((ppopup = pMenuState->pGlobalPopupMenu) == NULL) { 00132 00133 /* 00134 * We're not really in menu mode. This can happen 00135 * if we are forced out of menu loop too soon; i.e, from 00136 * inside xxxMNGetPopup or xxxTrackPopupMenuEx. 00137 */ 00138 UserAssert(!pMenuState->fInsideMenuLoop && !pMenuState->fMenuStarted); 00139 return; 00140 } 00141 00142 00143 00144 pMenuState->fInsideMenuLoop = FALSE; 00145 pMenuState->fMenuStarted = FALSE; 00146 /* 00147 * Mark the popup as destroyed so people will not use it anymore. 00148 * This means that root popups can be marked as destroyed before 00149 * actually being destroyed (nice and confusing). 00150 */ 00151 ppopup->fDestroyed = TRUE; 00152 00153 /* 00154 * Determine if this is the menu loop owner before calling back. 00155 * Only the owner can destroy the menu windows 00156 */ 00157 ptiCurrent = PtiCurrent(); 00158 fMenuStateOwner = (ptiCurrent == pMenuState->ptiMenuStateOwner); 00159 00160 /* 00161 * Release mouse capture if we got it in xxxStartMenuState 00162 */ 00163 if (ptiCurrent->pq->spwndCapture == pMenuState->pGlobalPopupMenu->spwndNotify) { 00164 xxxMNReleaseCapture(); 00165 } 00166 00167 /* 00168 * Bail if this is not the menu loop owner 00169 */ 00170 if (!fMenuStateOwner) { 00171 RIPMSG1(RIP_WARNING, "xxxEndMenu: Thread %#p doesn't own the menu loop", ptiCurrent); 00172 return; 00173 } 00174 /* 00175 * If the menu loop is running on a thread different than the thread 00176 * that owns spwndNotify, we can have two threads trying to end 00177 * this menu at the same time. 00178 */ 00179 if (pMenuState->fInEndMenu) { 00180 RIPMSG1(RIP_WARNING, "xxxEndMenu: already in EndMenu. pMenuState:%#p", pMenuState); 00181 return; 00182 } 00183 pMenuState->fInEndMenu = TRUE; 00184 00185 if (pMenuState->pGlobalPopupMenu->spwndNotify != NULL) { 00186 if (!pMenuState->pGlobalPopupMenu->fInCancel) { 00187 xxxMNDismiss(pMenuState); 00188 } 00189 } else { 00190 BOOL fTrackedPopup = ppopup->fIsTrackPopup; 00191 00192 /* 00193 * This should do the same stuff as MenuCancelMenus but not send any 00194 * messages... 00195 */ 00196 xxxMNCloseHierarchy(ppopup, pMenuState); 00197 00198 if (fTrackedPopup) { 00199 xxxDestroyWindow(ppopup->spwndPopupMenu); 00200 } 00201 00202 } 00203 00204 }

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