00001 /****************************** Module Header ******************************\ 00002 * 00003 * Module Name: mncreate.c 00004 * 00005 * Copyright (c) 1985 - 1999, Microsoft Corporation 00006 * 00007 * Creation routines for menus 00008 * 00009 * Public Functions: 00010 * 00011 * _CreateMenu() 00012 * _CreatePopupMenu() 00013 * 00014 * History: 00015 * 09-24-90 mikeke from win30 00016 * 02-11-91 JimA Added access checks. 00017 * 03-18-91 IanJa Window revalidation added (none required) 00018 \***************************************************************************/ 00019 00020 #include "precomp.h" 00021 #pragma hdrstop 00022 00023 00024 /***************************************************************************\ 00025 * InternalCreateMenu 00026 * 00027 * Creates and returns a handle to an empty menu structure. Returns 00028 * NULL if unsuccessful in allocating the memory. If PtiCurrent() == 00029 * NULL, create an unowned menu, probably the system menu. 00030 * 00031 * History: 00032 * 28-Sep-1990 mikeke from win30 00033 * 02-11-91 JimA Added access checks. 00034 \***************************************************************************/ 00035 00036 PMENU InternalCreateMenu( 00037 BOOL fPopup) 00038 { 00039 PMENU pmenu; 00040 PTHREADINFO ptiCurrent = PtiCurrent(); 00041 PDESKTOP pdesk = NULL; 00042 00043 /* 00044 * If the windowstation has been initialized, allocate from 00045 * the current desktop. 00046 */ 00047 pdesk = ptiCurrent->rpdesk; 00048 /* 00049 * Just like in xxxCreateWindowEx, bypass the security check if hdesk is NULL 00050 * This allows CSR worker threads (ie harderror boxes) to do what they need to 00051 */ 00052 if (ptiCurrent->hdesk != NULL) { 00053 RETURN_IF_ACCESS_DENIED(ptiCurrent->amdesk, DESKTOP_CREATEMENU, NULL); 00054 } else { 00055 UserAssert(ptiCurrent->TIF_flags & TIF_CSRSSTHREAD); 00056 } 00057 00058 pmenu = HMAllocObject(ptiCurrent, pdesk, TYPE_MENU, sizeof(MENU)); 00059 00060 if (pmenu != NULL) { 00061 if (fPopup) { 00062 pmenu->fFlags = MFISPOPUP; 00063 } 00064 } 00065 return pmenu; 00066 } 00067 00068 00069 /***************************************************************************\ 00070 * CreateMenu 00071 * 00072 * Creates and returns a handle to an empty menu structure. Returns 00073 * NULL if unsuccessful in allocating the memory. If PtiCurrent() == 00074 * NULL, create an unowned menu, probably the system menu. 00075 * 00076 * History: 00077 * 28-Sep-1990 mikeke from win30 00078 * 02-11-91 JimA Added access checks. 00079 \***************************************************************************/ 00080 00081 PMENU _CreateMenu() 00082 { 00083 return InternalCreateMenu(FALSE); 00084 } 00085 00086 00087 /***************************************************************************\ 00088 * CreatePopupMenu 00089 * 00090 * Creates and returns a handle to an empty POPUP menu structure. Returns 00091 * NULL if unsuccessful in allocating the memory. 00092 * 00093 * History: 00094 * 28-Sep-1990 mikeke from win30 00095 \***************************************************************************/ 00096 00097 PMENU _CreatePopupMenu() 00098 { 00099 return InternalCreateMenu(TRUE); 00100 }