00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 DWORD _GetMenuDefaultItem(
PMENU pMenu, BOOL fByPosition, UINT uFlags)
00027 {
00028
int iItem;
00029
int cItems;
00030
PITEM pItem;
00031
PMENU pSubMenu;
00032
00033 pItem =
REBASEALWAYS(pMenu, rgItems);
00034 cItems = pMenu->
cItems;
00035
00036
00037
00038
00039
00040
for (iItem = 0; iItem < cItems; iItem++, pItem++) {
00041
if (
TestMFS(pItem, MFS_DEFAULT)) {
00042
if ((uFlags & GMDI_USEDISABLED) || !
TestMFS(pItem, MFS_GRAYED)) {
00043
if ((uFlags & GMDI_GOINTOPOPUPS) && (pItem->
spSubMenu !=
NULL)) {
00044
DWORD id;
00045
00046
00047
00048
00049
00050 pSubMenu =
REBASEPTR(pMenu, pItem->
spSubMenu);
00051
id =
_GetMenuDefaultItem(pSubMenu, fByPosition, uFlags);
00052
if (
id !=
MFMWFP_NOITEM)
00053
return(
id);
00054 }
00055
00056
break;
00057 }
00058 }
00059 }
00060
00061
if (iItem < cItems) {
00062
return (fByPosition ? iItem : pItem->
wID);
00063 }
else {
00064
return (
MFMWFP_NOITEM);
00065 }
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 BOOL xxxMNCanClose(
PWND pwnd)
00079 {
00080
PMENU pMenu;
00081
PITEM pItem;
00082
PCLS pcls;
00083
00084
CheckLock(pwnd);
00085
00086 pcls = (
PCLS)
REBASEALWAYS(pwnd, pcls);
00087
if (
TestCF2(pcls,
CFNOCLOSE) )
00088
return FALSE;
00089
00090 pMenu =
xxxGetSysMenuHandle(pwnd);
00091
if (!pMenu || !(pMenu =
REBASEPTR(pwnd, pMenu)))
00092
return(
FALSE);
00093
00094
00095
00096
00097
00098 pItem =
MNLookUpItem(pMenu, SC_CLOSE,
FALSE,
NULL);
00099
00100
if (!(pItem))
00101 pItem =
MNLookUpItem(pMenu, SC_CLOSE-0x7000,
FALSE,
NULL);
00102
00103
if (!(pItem))
00104 pItem =
MNLookUpItem(pMenu, 0xC070,
FALSE,
NULL);
00105
00106
return((pItem) && !
TestMFS(pItem, MFS_GRAYED));
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 RTLMENU xxxLoadSysMenu (UINT uMenuId)
00118 {
00119
RTLMENU rtlMenu;
00120 MENUINFO mi;
00121 MENUITEMINFO mii;
00122
TL tlMenu;
00123
00124
#ifdef _USERK_
00125
UNICODE_STRING strMenuName;
00126
RtlInitUnicodeStringOrId(&strMenuName, MAKEINTRESOURCE(uMenuId));
00127 rtlMenu =
xxxClientLoadMenu(
NULL, &strMenuName);
00128
#else
00129
rtlMenu = LoadMenu(
hmodUser, MAKEINTRESOURCE(uMenuId));
00130
#endif
00131
00132
if (rtlMenu ==
NULL) {
00133 RIPMSG1(RIP_WARNING,
"xxxLoadSysMenu failed to load:%#lx", uMenuId);
00134
return NULL;
00135 }
00136
00137
ThreadLockAlways(rtlMenu, &tlMenu);
00138
00139
00140
00141
00142 mi.cbSize =
sizeof(mi);
00143 mi.fMask = MIM_STYLE | MIM_APPLYTOSUBMENUS;
00144 mi.dwStyle = MNS_CHECKORBMP;
00145
xxxRtlSetMenuInfo(rtlMenu, &mi);
00146
00147
00148
00149 mii.cbSize =
sizeof(mii);
00150 mii.fMask = MIIM_BITMAP;
00151 mii.hbmpItem = HBMMENU_POPUP_CLOSE;
00152
xxxRtlSetMenuItemInfo (rtlMenu, SC_CLOSE, &mii);
00153
if (uMenuId !=
ID_DIALOGSYSMENU) {
00154 mii.hbmpItem = HBMMENU_POPUP_MINIMIZE;
00155
xxxRtlSetMenuItemInfo (rtlMenu, SC_MINIMIZE, &mii);
00156 mii.hbmpItem = HBMMENU_POPUP_MAXIMIZE;
00157
xxxRtlSetMenuItemInfo (rtlMenu, SC_MAXIMIZE, &mii);
00158 mii.hbmpItem = HBMMENU_POPUP_RESTORE;
00159
xxxRtlSetMenuItemInfo (rtlMenu, SC_RESTORE, &mii);
00160 }
00161
00162
ThreadUnlock(&tlMenu);
00163
return rtlMenu;
00164 }
00165