| 1 | /* $Id: winmenu.cpp,v 1.19 1999-12-18 14:31:15 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Win32 menu API functions for OS/2 | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1998 Sander van Leeuwen | 
|---|
| 7 | * Copyright 1998 Patrick Haller | 
|---|
| 8 | * | 
|---|
| 9 | * Parts ported from Wine: | 
|---|
| 10 | * Copyright 1993 Martin Ayotte | 
|---|
| 11 | * Copyright 1994 Alexandre Julliard | 
|---|
| 12 | * Copyright 1997 Morten Welinder | 
|---|
| 13 | * | 
|---|
| 14 | * | 
|---|
| 15 | * TODO: Set/GetMenu(Item)Info only partially implemented | 
|---|
| 16 | * TODO: Memory leak when deleting submenus | 
|---|
| 17 | * TODO: Check error nrs | 
|---|
| 18 | * | 
|---|
| 19 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 20 | * | 
|---|
| 21 | */ | 
|---|
| 22 | #include <os2win.h> | 
|---|
| 23 | #include <odin.h> | 
|---|
| 24 | #include <odinwrap.h> | 
|---|
| 25 | #include <stdlib.h> | 
|---|
| 26 | #include <string.h> | 
|---|
| 27 | #include <win32wbase.h> | 
|---|
| 28 | #include "oslibmenu.h" | 
|---|
| 29 | #include "oslibwin.h" | 
|---|
| 30 | #include "winmenudef.h" | 
|---|
| 31 |  | 
|---|
| 32 | ODINDEBUGCHANNEL(USER32) | 
|---|
| 33 |  | 
|---|
| 34 | BOOL  ODIN_INTERNAL ODIN_InsertMenuA(HMENU,UINT,UINT,UINT,LPCSTR); | 
|---|
| 35 | BOOL  ODIN_INTERNAL ODIN_InsertMenuW(HMENU,UINT,UINT,UINT,LPCWSTR); | 
|---|
| 36 | BOOL  ODIN_INTERNAL ODIN_InsertMenuItemA(HMENU,UINT,BOOL,const MENUITEMINFOA*); | 
|---|
| 37 | BOOL  ODIN_INTERNAL ODIN_InsertMenuItemW(HMENU,UINT,BOOL,const MENUITEMINFOW*); | 
|---|
| 38 | BOOL  ODIN_INTERNAL ODIN_AppendMenuA(HMENU,UINT,UINT,LPCSTR); | 
|---|
| 39 | BOOL  ODIN_INTERNAL ODIN_AppendMenuW(HMENU,UINT,UINT,LPCWSTR); | 
|---|
| 40 | HMENU ODIN_INTERNAL ODIN_CreateMenu(void); | 
|---|
| 41 | HMENU ODIN_INTERNAL ODIN_CreatePopupMenu(void); | 
|---|
| 42 | BOOL  ODIN_INTERNAL ODIN_DestroyMenu(HMENU); | 
|---|
| 43 |  | 
|---|
| 44 | //@@@PH: experiment with WINE LoadMenuIndirect code | 
|---|
| 45 | #include <heapstring.h> | 
|---|
| 46 | #define MENU_ITEM_TYPE(flags) \ | 
|---|
| 47 | ((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)) | 
|---|
| 48 |  | 
|---|
| 49 | #define IS_STRING_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_STRING) | 
|---|
| 50 | #define IS_BITMAP_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_BITMAP) | 
|---|
| 51 |  | 
|---|
| 52 | /********************************************************************** | 
|---|
| 53 | *         MENU_ParseResource | 
|---|
| 54 | * | 
|---|
| 55 | * Parse a standard menu resource and add items to the menu. | 
|---|
| 56 | * Return a pointer to the end of the resource. | 
|---|
| 57 | */ | 
|---|
| 58 | static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu) | 
|---|
| 59 | { | 
|---|
| 60 | WORD flags, id = 0; | 
|---|
| 61 | LPCSTR str; | 
|---|
| 62 |  | 
|---|
| 63 | do | 
|---|
| 64 | { | 
|---|
| 65 | flags = GET_WORD(res); | 
|---|
| 66 | res += sizeof(WORD); | 
|---|
| 67 | if (!(flags & MF_POPUP)) | 
|---|
| 68 | { | 
|---|
| 69 | id = GET_WORD(res); | 
|---|
| 70 | res += sizeof(WORD); | 
|---|
| 71 | } | 
|---|
| 72 | if (!IS_STRING_ITEM(flags)) | 
|---|
| 73 | dprintf(("USER32: WinMenu: MENU_ParseResource: not a string item %04x\n", flags )); | 
|---|
| 74 | str = res; | 
|---|
| 75 |  | 
|---|
| 76 | res += (lstrlenW((LPCWSTR)str) + 1) * sizeof(WCHAR); | 
|---|
| 77 | if (flags & MF_POPUP) | 
|---|
| 78 | { | 
|---|
| 79 | HMENU hSubMenu = ODIN_CreatePopupMenu(); | 
|---|
| 80 | if (!hSubMenu) return NULL; | 
|---|
| 81 | if (!(res = MENU_ParseResource( res, hSubMenu))) | 
|---|
| 82 | return NULL; | 
|---|
| 83 | ODIN_AppendMenuW( hMenu, flags, (UINT)hSubMenu, (LPCWSTR)str ); | 
|---|
| 84 | } | 
|---|
| 85 | else  /* Not a popup */ | 
|---|
| 86 | { | 
|---|
| 87 | ODIN_AppendMenuW( hMenu, flags, id, *(LPCWSTR)str ? (LPCWSTR)str : NULL ); | 
|---|
| 88 | } | 
|---|
| 89 | } while (!(flags & MF_END)); | 
|---|
| 90 | return res; | 
|---|
| 91 | } | 
|---|
| 92 |  | 
|---|
| 93 |  | 
|---|
| 94 | /********************************************************************** | 
|---|
| 95 | *         MENUEX_ParseResource | 
|---|
| 96 | * | 
|---|
| 97 | * Parse an extended menu resource and add items to the menu. | 
|---|
| 98 | * Return a pointer to the end of the resource. | 
|---|
| 99 | */ | 
|---|
| 100 | static LPCSTR MENUEX_ParseResource( LPCSTR res, HMENU hMenu) | 
|---|
| 101 | { | 
|---|
| 102 | WORD resinfo; | 
|---|
| 103 |  | 
|---|
| 104 | do { | 
|---|
| 105 | MENUITEMINFOW mii; | 
|---|
| 106 |  | 
|---|
| 107 | mii.cbSize = sizeof(mii); | 
|---|
| 108 | mii.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE; | 
|---|
| 109 | mii.fType = GET_DWORD(res); | 
|---|
| 110 | res += sizeof(DWORD); | 
|---|
| 111 | mii.fState = GET_DWORD(res); | 
|---|
| 112 | res += sizeof(DWORD); | 
|---|
| 113 | mii.wID = GET_DWORD(res); | 
|---|
| 114 | res += sizeof(DWORD); | 
|---|
| 115 | resinfo = GET_WORD(res); /* FIXME: for 16-bit apps this is a byte.  */ | 
|---|
| 116 | res += sizeof(WORD); | 
|---|
| 117 |  | 
|---|
| 118 | /* Align the text on a word boundary.  */ | 
|---|
| 119 | res += (~((int)res - 1)) & 1; | 
|---|
| 120 | mii.dwTypeData = (LPWSTR) res; | 
|---|
| 121 | res += (1 + lstrlenW(mii.dwTypeData)) * sizeof(WCHAR); | 
|---|
| 122 | /* Align the following fields on a dword boundary.  */ | 
|---|
| 123 | res += (~((int)res - 1)) & 3; | 
|---|
| 124 |  | 
|---|
| 125 | /* FIXME: This is inefficient and cannot be optimised away by gcc.  */ | 
|---|
| 126 | { | 
|---|
| 127 | LPSTR newstr = HEAP_strdupWtoA(GetProcessHeap(), 0, mii.dwTypeData); | 
|---|
| 128 |  | 
|---|
| 129 | dprintf(("USER32:WinMenu:MENUEX_ParseResource Menu item: [%08x,%08x,%04x,%04x,%s]\n", | 
|---|
| 130 | mii.fType, mii.fState, mii.wID, resinfo, newstr)); | 
|---|
| 131 | HeapFree( GetProcessHeap(), 0, newstr ); | 
|---|
| 132 | } | 
|---|
| 133 |  | 
|---|
| 134 | if (resinfo & 1) {                    /* Pop-up? */ | 
|---|
| 135 | /* DWORD helpid = GET_DWORD(res); FIXME: use this.  */ | 
|---|
| 136 | res += sizeof(DWORD); | 
|---|
| 137 | mii.hSubMenu = ODIN_CreatePopupMenu(); | 
|---|
| 138 | if (!mii.hSubMenu) | 
|---|
| 139 | return NULL; | 
|---|
| 140 | if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) { | 
|---|
| 141 | DestroyMenu(mii.hSubMenu); | 
|---|
| 142 | return NULL; | 
|---|
| 143 | } | 
|---|
| 144 | mii.fMask |= MIIM_SUBMENU; | 
|---|
| 145 | mii.fType |= MF_POPUP; | 
|---|
| 146 | } | 
|---|
| 147 | ODIN_InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii); | 
|---|
| 148 | } | 
|---|
| 149 | while (!(resinfo & MF_END)); | 
|---|
| 150 |  | 
|---|
| 151 | return res; | 
|---|
| 152 | } | 
|---|
| 153 | /********************************************************************** | 
|---|
| 154 | *    myLoadMenuIndirect | 
|---|
| 155 | */ | 
|---|
| 156 | HMENU myLoadMenuIndirect(LPCVOID pMenuTemplate) | 
|---|
| 157 | { | 
|---|
| 158 | HMENU hMenu; | 
|---|
| 159 | WORD  version, | 
|---|
| 160 | offset; | 
|---|
| 161 | LPCSTR p = (LPCSTR)pMenuTemplate; | 
|---|
| 162 |  | 
|---|
| 163 | version = GET_WORD(p); | 
|---|
| 164 | p += sizeof(WORD); | 
|---|
| 165 |  | 
|---|
| 166 | switch (version) | 
|---|
| 167 | { | 
|---|
| 168 | case 0: | 
|---|
| 169 | offset = GET_WORD(p); | 
|---|
| 170 | p += sizeof(WORD) + offset; | 
|---|
| 171 | if (!(hMenu = ODIN_CreateMenu())) | 
|---|
| 172 | return 0; | 
|---|
| 173 | if (!MENU_ParseResource( p, hMenu)) | 
|---|
| 174 | { | 
|---|
| 175 | DestroyMenu( hMenu ); | 
|---|
| 176 | return 0; | 
|---|
| 177 | } | 
|---|
| 178 | return hMenu; | 
|---|
| 179 |  | 
|---|
| 180 | case 1: | 
|---|
| 181 | offset = GET_WORD(p); | 
|---|
| 182 | p += sizeof(WORD) + offset; | 
|---|
| 183 | if (!(hMenu = ODIN_CreateMenu())) | 
|---|
| 184 | return 0; | 
|---|
| 185 | if (!MENUEX_ParseResource( p, hMenu)) | 
|---|
| 186 | { | 
|---|
| 187 | ODIN_DestroyMenu( hMenu ); | 
|---|
| 188 | return 0; | 
|---|
| 189 | } | 
|---|
| 190 | return hMenu; | 
|---|
| 191 |  | 
|---|
| 192 | default: | 
|---|
| 193 | dprintf(("USER32: LoadMenuIndirectA: version %d not supported.\n", version)); | 
|---|
| 194 | return 0; | 
|---|
| 195 | } | 
|---|
| 196 | } | 
|---|
| 197 | //****************************************************************************** | 
|---|
| 198 | //****************************************************************************** | 
|---|
| 199 | void SetInternalMenuInfo(HMENU hMenu) | 
|---|
| 200 | { | 
|---|
| 201 | LPPOPUPMENU lpMenuInfo; | 
|---|
| 202 |  | 
|---|
| 203 | lpMenuInfo = (LPPOPUPMENU)malloc(sizeof(*lpMenuInfo)); | 
|---|
| 204 | memset(lpMenuInfo, 0, sizeof(*lpMenuInfo)); | 
|---|
| 205 | OSLibWinSetWindowULong(hMenu, OSLIB_QWL_USER, (ULONG)lpMenuInfo); | 
|---|
| 206 | } | 
|---|
| 207 | //****************************************************************************** | 
|---|
| 208 | //****************************************************************************** | 
|---|
| 209 | LPPOPUPMENU GetInternalMenuInfo(HMENU hMenu) | 
|---|
| 210 | { | 
|---|
| 211 | return (LPPOPUPMENU)OSLibWinGetWindowULong(hMenu, OSLIB_QWL_USER); | 
|---|
| 212 | } | 
|---|
| 213 | //****************************************************************************** | 
|---|
| 214 | //****************************************************************************** | 
|---|
| 215 | void DeleteInternalMenuInfo(HMENU hMenu) | 
|---|
| 216 | { | 
|---|
| 217 | LPPOPUPMENU lpMenuInfo; | 
|---|
| 218 |  | 
|---|
| 219 | lpMenuInfo = (LPPOPUPMENU)OSLibWinGetWindowULong(hMenu, OSLIB_QWL_USER); | 
|---|
| 220 | if(lpMenuInfo) { | 
|---|
| 221 | free(lpMenuInfo); | 
|---|
| 222 | OSLibWinSetWindowULong(hMenu, OSLIB_QWL_USER, 0); | 
|---|
| 223 | } | 
|---|
| 224 | } | 
|---|
| 225 | //****************************************************************************** | 
|---|
| 226 | //****************************************************************************** | 
|---|
| 227 | ODINFUNCTION0(HMENU, CreateMenu) | 
|---|
| 228 | { | 
|---|
| 229 | HMENU hMenu; | 
|---|
| 230 |  | 
|---|
| 231 | dprintf(("USER32: CreateMenu\n")); | 
|---|
| 232 |  | 
|---|
| 233 | hMenu = OSLibWinCreateEmptyMenu(); | 
|---|
| 234 | if(hMenu) { | 
|---|
| 235 | SetInternalMenuInfo(hMenu); | 
|---|
| 236 | } | 
|---|
| 237 | else    SetLastError(ERROR_INVALID_PARAMETER); //wrong error | 
|---|
| 238 |  | 
|---|
| 239 | return hMenu; | 
|---|
| 240 | } | 
|---|
| 241 | //****************************************************************************** | 
|---|
| 242 | //****************************************************************************** | 
|---|
| 243 | ODINFUNCTION0(HMENU, CreatePopupMenu) | 
|---|
| 244 | { | 
|---|
| 245 | HMENU hMenu; | 
|---|
| 246 |  | 
|---|
| 247 | dprintf(("USER32: CreatePopupMenu\n")); | 
|---|
| 248 |  | 
|---|
| 249 | hMenu = OSLibWinCreateEmptyPopupMenu(); | 
|---|
| 250 | if(hMenu) { | 
|---|
| 251 | SetInternalMenuInfo(hMenu); | 
|---|
| 252 | } | 
|---|
| 253 | else    SetLastError(ERROR_INVALID_PARAMETER); //wrong error | 
|---|
| 254 |  | 
|---|
| 255 | return hMenu; | 
|---|
| 256 | } | 
|---|
| 257 | //****************************************************************************** | 
|---|
| 258 | //****************************************************************************** | 
|---|
| 259 | ODINFUNCTION2(HMENU,     LoadMenuA, | 
|---|
| 260 | HINSTANCE, hinst, | 
|---|
| 261 | LPCSTR,    lpszMenu) | 
|---|
| 262 | { | 
|---|
| 263 | Win32Resource *winres; | 
|---|
| 264 | HMENU hMenu; | 
|---|
| 265 |  | 
|---|
| 266 | winres = (Win32Resource *)FindResourceA(hinst, lpszMenu, RT_MENUA); | 
|---|
| 267 | if(winres) | 
|---|
| 268 | { | 
|---|
| 269 | hMenu = myLoadMenuIndirect((MENUITEMTEMPLATEHEADER *)winres->lockResource()); | 
|---|
| 270 | if(hMenu) { | 
|---|
| 271 | SetInternalMenuInfo(hMenu); | 
|---|
| 272 | } | 
|---|
| 273 | else    SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 274 |  | 
|---|
| 275 | delete winres; | 
|---|
| 276 | return hMenu; | 
|---|
| 277 | } | 
|---|
| 278 | return 0; | 
|---|
| 279 | } | 
|---|
| 280 | //****************************************************************************** | 
|---|
| 281 | //****************************************************************************** | 
|---|
| 282 | ODINFUNCTION2(HMENU, LoadMenuW, | 
|---|
| 283 | HINSTANCE, hinst, | 
|---|
| 284 | LPCWSTR, lpszMenu) | 
|---|
| 285 | { | 
|---|
| 286 | Win32Resource *winres; | 
|---|
| 287 | HMENU hMenu; | 
|---|
| 288 |  | 
|---|
| 289 | winres = (Win32Resource *)FindResourceW(hinst, lpszMenu, RT_MENUW); | 
|---|
| 290 | if(winres) { | 
|---|
| 291 | hMenu = myLoadMenuIndirect((MENUITEMTEMPLATEHEADER *)winres->lockResource()); | 
|---|
| 292 | if(hMenu) { | 
|---|
| 293 | SetInternalMenuInfo(hMenu); | 
|---|
| 294 | } | 
|---|
| 295 | else    SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 296 |  | 
|---|
| 297 | delete winres; | 
|---|
| 298 | return hMenu; | 
|---|
| 299 | } | 
|---|
| 300 | return 0; | 
|---|
| 301 | } | 
|---|
| 302 | //****************************************************************************** | 
|---|
| 303 | //NOTE: menutemplate strings are always in Unicode format | 
|---|
| 304 | //****************************************************************************** | 
|---|
| 305 | ODINFUNCTION1(HMENU, LoadMenuIndirectW, | 
|---|
| 306 | const MENUITEMTEMPLATEHEADER *, menuTemplate) | 
|---|
| 307 | { | 
|---|
| 308 | HMENU hMenu; | 
|---|
| 309 |  | 
|---|
| 310 | hMenu = myLoadMenuIndirect(menuTemplate); | 
|---|
| 311 | if(hMenu) { | 
|---|
| 312 | SetInternalMenuInfo(hMenu); | 
|---|
| 313 | } | 
|---|
| 314 | else    SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 315 |  | 
|---|
| 316 | return (HMENU)hMenu; | 
|---|
| 317 | } | 
|---|
| 318 | //****************************************************************************** | 
|---|
| 319 | //****************************************************************************** | 
|---|
| 320 | ODINFUNCTION1(BOOL,  DestroyMenu, | 
|---|
| 321 | HMENU, hMenu) | 
|---|
| 322 | { | 
|---|
| 323 | if(hMenu == 0) | 
|---|
| 324 | { | 
|---|
| 325 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 326 | return 0; | 
|---|
| 327 | } | 
|---|
| 328 | DeleteInternalMenuInfo(hMenu); | 
|---|
| 329 | return O32_DestroyMenu(hMenu); | 
|---|
| 330 | } | 
|---|
| 331 | //****************************************************************************** | 
|---|
| 332 | //****************************************************************************** | 
|---|
| 333 | ODINFUNCTION1(HMENU, GetMenu, | 
|---|
| 334 | HWND,  hwnd) | 
|---|
| 335 | { | 
|---|
| 336 | Win32BaseWindow *window; | 
|---|
| 337 |  | 
|---|
| 338 | window = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 339 | if(!window) | 
|---|
| 340 | { | 
|---|
| 341 | dprintf(("GetMenu, window %x not found", hwnd)); | 
|---|
| 342 | SetLastError(ERROR_INVALID_WINDOW_HANDLE); | 
|---|
| 343 | return 0; | 
|---|
| 344 | } | 
|---|
| 345 |  | 
|---|
| 346 | return window->GetMenu(); | 
|---|
| 347 | } | 
|---|
| 348 | //****************************************************************************** | 
|---|
| 349 | //****************************************************************************** | 
|---|
| 350 | ODINFUNCTION2(BOOL,  SetMenu, | 
|---|
| 351 | HWND,  hwnd, | 
|---|
| 352 | HMENU, hMenu) | 
|---|
| 353 | { | 
|---|
| 354 | Win32BaseWindow *window; | 
|---|
| 355 |  | 
|---|
| 356 | window = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 357 | if(!window) | 
|---|
| 358 | { | 
|---|
| 359 | dprintf(("SetMenu, window %x not found", hwnd)); | 
|---|
| 360 | SetLastError(ERROR_INVALID_WINDOW_HANDLE); | 
|---|
| 361 | return 0; | 
|---|
| 362 | } | 
|---|
| 363 |  | 
|---|
| 364 | window->SetMenu(hMenu); | 
|---|
| 365 | return TRUE; | 
|---|
| 366 | } | 
|---|
| 367 | //****************************************************************************** | 
|---|
| 368 | //****************************************************************************** | 
|---|
| 369 | ODINFUNCTION0(DWORD, GetMenuCheckMarkDimensions) | 
|---|
| 370 | { | 
|---|
| 371 | return O32_GetMenuCheckMarkDimensions(); | 
|---|
| 372 | } | 
|---|
| 373 | //****************************************************************************** | 
|---|
| 374 | //****************************************************************************** | 
|---|
| 375 | ODINFUNCTION1(int,   GetMenuItemCount, | 
|---|
| 376 | HMENU, hMenu) | 
|---|
| 377 | { | 
|---|
| 378 | if(hMenu == 0) | 
|---|
| 379 | { | 
|---|
| 380 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 381 | return 0; | 
|---|
| 382 | } | 
|---|
| 383 | return OSLibGetMenuItemCount(hMenu); | 
|---|
| 384 | } | 
|---|
| 385 | //****************************************************************************** | 
|---|
| 386 | //****************************************************************************** | 
|---|
| 387 | ODINFUNCTION2(UINT,  GetMenuItemID, | 
|---|
| 388 | HMENU, hMenu, | 
|---|
| 389 | int,   nPos) | 
|---|
| 390 | { | 
|---|
| 391 | if(hMenu == 0) | 
|---|
| 392 | { | 
|---|
| 393 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 394 | return 0; | 
|---|
| 395 | } | 
|---|
| 396 | return O32_GetMenuItemID(hMenu, nPos); | 
|---|
| 397 | } | 
|---|
| 398 | //****************************************************************************** | 
|---|
| 399 | //****************************************************************************** | 
|---|
| 400 | ODINFUNCTION3(UINT,  GetMenuState, | 
|---|
| 401 | HMENU, hMenu, | 
|---|
| 402 | UINT,  arg2, | 
|---|
| 403 | UINT,  arg3) | 
|---|
| 404 | { | 
|---|
| 405 | if(hMenu == 0) | 
|---|
| 406 | { | 
|---|
| 407 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 408 | return 0; | 
|---|
| 409 | } | 
|---|
| 410 |  | 
|---|
| 411 | return O32_GetMenuState(hMenu, arg2, arg3); | 
|---|
| 412 | } | 
|---|
| 413 | //****************************************************************************** | 
|---|
| 414 | //****************************************************************************** | 
|---|
| 415 | ODINFUNCTION5(int,   GetMenuStringA, | 
|---|
| 416 | HMENU, hMenu, | 
|---|
| 417 | UINT,  arg2, | 
|---|
| 418 | LPSTR, arg3, | 
|---|
| 419 | int,   arg4, | 
|---|
| 420 | UINT,  arg5) | 
|---|
| 421 | { | 
|---|
| 422 | if(hMenu == 0) | 
|---|
| 423 | { | 
|---|
| 424 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 425 | return 0; | 
|---|
| 426 | } | 
|---|
| 427 |  | 
|---|
| 428 | return O32_GetMenuString(hMenu, arg2, arg3, arg4, arg5); | 
|---|
| 429 | } | 
|---|
| 430 | //****************************************************************************** | 
|---|
| 431 | //****************************************************************************** | 
|---|
| 432 | ODINFUNCTION5(int,   GetMenuStringW, | 
|---|
| 433 | HMENU, hMenu, | 
|---|
| 434 | UINT,  idItem, | 
|---|
| 435 | LPWSTR,lpsz, | 
|---|
| 436 | int,   cchMax, | 
|---|
| 437 | UINT,  fuFlags) | 
|---|
| 438 | { | 
|---|
| 439 | char *astring = (char *)malloc(cchMax); | 
|---|
| 440 | int   rc; | 
|---|
| 441 |  | 
|---|
| 442 | rc = ODIN_GetMenuStringA(hMenu, idItem, astring, cchMax, fuFlags); | 
|---|
| 443 | if(rc) | 
|---|
| 444 | { | 
|---|
| 445 | dprintf(("USER32: GetMenuStringW %s\n", astring)); | 
|---|
| 446 | AsciiToUnicode(astring, lpsz); | 
|---|
| 447 | } | 
|---|
| 448 | else    lpsz[0] = 0; | 
|---|
| 449 | free(astring); | 
|---|
| 450 |  | 
|---|
| 451 | return(rc); | 
|---|
| 452 | } | 
|---|
| 453 | //****************************************************************************** | 
|---|
| 454 | //****************************************************************************** | 
|---|
| 455 | ODINFUNCTION5(BOOL, SetMenuItemBitmaps, | 
|---|
| 456 | HMENU, hMenu, | 
|---|
| 457 | UINT, arg2, | 
|---|
| 458 | UINT, arg3, | 
|---|
| 459 | HBITMAP, arg4, | 
|---|
| 460 | HBITMAP, arg5) | 
|---|
| 461 | { | 
|---|
| 462 | dprintf(("USER32:  SetMenuItemBitmaps\n")); | 
|---|
| 463 | if(hMenu == 0) | 
|---|
| 464 | { | 
|---|
| 465 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 466 | return 0; | 
|---|
| 467 | } | 
|---|
| 468 | return O32_SetMenuItemBitmaps(hMenu, arg2, arg3, arg4, arg5); | 
|---|
| 469 | } | 
|---|
| 470 | //****************************************************************************** | 
|---|
| 471 | //****************************************************************************** | 
|---|
| 472 | ODINFUNCTION2(HMENU, GetSubMenu, | 
|---|
| 473 | HWND, hMenu, | 
|---|
| 474 | int, arg2) | 
|---|
| 475 | { | 
|---|
| 476 | if(hMenu == 0) | 
|---|
| 477 | { | 
|---|
| 478 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 479 | return 0; | 
|---|
| 480 | } | 
|---|
| 481 |  | 
|---|
| 482 | return O32_GetSubMenu(hMenu, arg2); | 
|---|
| 483 | } | 
|---|
| 484 | //****************************************************************************** | 
|---|
| 485 | //****************************************************************************** | 
|---|
| 486 | ODINFUNCTION2(HMENU, GetSystemMenu, | 
|---|
| 487 | HWND,  hSystemWindow, | 
|---|
| 488 | BOOL,  bRevert) | 
|---|
| 489 | { | 
|---|
| 490 | Win32BaseWindow *window; | 
|---|
| 491 |  | 
|---|
| 492 | window = Win32BaseWindow::GetWindowFromHandle(hSystemWindow); | 
|---|
| 493 | if(!window) | 
|---|
| 494 | { | 
|---|
| 495 | dprintf(("GetSystemMenu, window %x not found", hSystemWindow)); | 
|---|
| 496 | return 0; | 
|---|
| 497 | } | 
|---|
| 498 |  | 
|---|
| 499 | return O32_GetSystemMenu(window->getOS2FrameWindowHandle(), bRevert); | 
|---|
| 500 | } | 
|---|
| 501 | //****************************************************************************** | 
|---|
| 502 | //****************************************************************************** | 
|---|
| 503 | ODINFUNCTION1(BOOL, IsMenu, | 
|---|
| 504 | HMENU, hMenu) | 
|---|
| 505 | { | 
|---|
| 506 | dprintf(("USER32:  IsMenu\n")); | 
|---|
| 507 | return O32_IsMenu(hMenu); | 
|---|
| 508 | } | 
|---|
| 509 | //****************************************************************************** | 
|---|
| 510 | //****************************************************************************** | 
|---|
| 511 | ODINFUNCTION7(BOOL, TrackPopupMenu, | 
|---|
| 512 | HMENU, hMenu, | 
|---|
| 513 | UINT, arg2, | 
|---|
| 514 | int, arg3, | 
|---|
| 515 | int, arg4, | 
|---|
| 516 | int, arg5, | 
|---|
| 517 | HWND, arg6, | 
|---|
| 518 | const RECT *, arg7) | 
|---|
| 519 | { | 
|---|
| 520 | Win32BaseWindow *window; | 
|---|
| 521 |  | 
|---|
| 522 | window = Win32BaseWindow::GetWindowFromHandle(arg6); | 
|---|
| 523 | if(!window) | 
|---|
| 524 | { | 
|---|
| 525 | dprintf(("TrackPopupMenu, window %x not found", arg6)); | 
|---|
| 526 | SetLastError(ERROR_INVALID_WINDOW_HANDLE); | 
|---|
| 527 | return 0; | 
|---|
| 528 | } | 
|---|
| 529 | dprintf(("USER32:  TrackPopupMenu\n")); | 
|---|
| 530 | if(hMenu == 0) | 
|---|
| 531 | { | 
|---|
| 532 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 533 | return 0; | 
|---|
| 534 | } | 
|---|
| 535 | return O32_TrackPopupMenu(hMenu, arg2, arg3, arg4, arg5, window->getOS2WindowHandle(), | 
|---|
| 536 | arg7); | 
|---|
| 537 | } | 
|---|
| 538 | //****************************************************************************** | 
|---|
| 539 | //****************************************************************************** | 
|---|
| 540 | ODINFUNCTION6(BOOL, TrackPopupMenuEx, | 
|---|
| 541 | HMENU, hMenu, | 
|---|
| 542 | UINT, flags, | 
|---|
| 543 | int, X, | 
|---|
| 544 | int, Y, | 
|---|
| 545 | HWND, hwnd, | 
|---|
| 546 | LPTPMPARAMS, lpPM) | 
|---|
| 547 | { | 
|---|
| 548 | RECT *rect = NULL; | 
|---|
| 549 | Win32BaseWindow *window; | 
|---|
| 550 |  | 
|---|
| 551 | window = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 552 | if(!window) | 
|---|
| 553 | { | 
|---|
| 554 | dprintf(("TrackPopupMenu, window %x not found", hwnd)); | 
|---|
| 555 | SetLastError(ERROR_INVALID_WINDOW_HANDLE); | 
|---|
| 556 | return 0; | 
|---|
| 557 | } | 
|---|
| 558 |  | 
|---|
| 559 | dprintf(("USER32:  TrackPopupMenuEx, not completely implemented\n")); | 
|---|
| 560 |  | 
|---|
| 561 | if (lpPM != NULL) // this parameter can be NULL | 
|---|
| 562 | if(lpPM->cbSize != 0) | 
|---|
| 563 | rect = &lpPM->rcExclude; | 
|---|
| 564 |  | 
|---|
| 565 | if(hMenu == 0) | 
|---|
| 566 | { | 
|---|
| 567 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 568 | return 0; | 
|---|
| 569 | } | 
|---|
| 570 | return O32_TrackPopupMenu(hMenu, flags, X, Y, 0, window->getOS2WindowHandle(), rect); | 
|---|
| 571 | } | 
|---|
| 572 | //****************************************************************************** | 
|---|
| 573 | //****************************************************************************** | 
|---|
| 574 | ODINFUNCTION4(BOOL, AppendMenuA, | 
|---|
| 575 | HMENU, hMenu, | 
|---|
| 576 | UINT, uFlags, | 
|---|
| 577 | UINT, id, | 
|---|
| 578 | LPCSTR, lpNewItem) | 
|---|
| 579 | { | 
|---|
| 580 | return ODIN_InsertMenuA( hMenu, -1, uFlags | MF_BYPOSITION, id, lpNewItem ); | 
|---|
| 581 | } | 
|---|
| 582 | //****************************************************************************** | 
|---|
| 583 | //****************************************************************************** | 
|---|
| 584 | ODINFUNCTION4(BOOL, AppendMenuW, | 
|---|
| 585 | HMENU, hMenu, | 
|---|
| 586 | UINT, uFlags, | 
|---|
| 587 | UINT, id, | 
|---|
| 588 | LPCWSTR, lpNewItem) | 
|---|
| 589 | { | 
|---|
| 590 | return ODIN_InsertMenuW( hMenu, -1, uFlags | MF_BYPOSITION, id, lpNewItem ); | 
|---|
| 591 | } | 
|---|
| 592 | //****************************************************************************** | 
|---|
| 593 | //****************************************************************************** | 
|---|
| 594 | ODINFUNCTION3(DWORD, CheckMenuItem, | 
|---|
| 595 | HMENU, hMenu, | 
|---|
| 596 | UINT, arg2, | 
|---|
| 597 | UINT, arg3) | 
|---|
| 598 | { | 
|---|
| 599 | if(hMenu == 0) | 
|---|
| 600 | { | 
|---|
| 601 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 602 | return 0; | 
|---|
| 603 | } | 
|---|
| 604 | return O32_CheckMenuItem(hMenu, arg2, arg3); | 
|---|
| 605 | } | 
|---|
| 606 | //****************************************************************************** | 
|---|
| 607 | //****************************************************************************** | 
|---|
| 608 | ODINFUNCTION3(BOOL,EnableMenuItem,HMENU,hMenu, | 
|---|
| 609 | UINT, uIDEnableItem, | 
|---|
| 610 | UINT, uEnable) | 
|---|
| 611 | { | 
|---|
| 612 | if(hMenu == 0) | 
|---|
| 613 | { | 
|---|
| 614 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 615 | return 0; | 
|---|
| 616 | } | 
|---|
| 617 |  | 
|---|
| 618 | return O32_EnableMenuItem(hMenu, | 
|---|
| 619 | uIDEnableItem, | 
|---|
| 620 | uEnable); | 
|---|
| 621 | } | 
|---|
| 622 | //****************************************************************************** | 
|---|
| 623 | //****************************************************************************** | 
|---|
| 624 | ODINFUNCTION5(BOOL, ModifyMenuA, | 
|---|
| 625 | HMENU, hMenu, | 
|---|
| 626 | UINT, arg2, | 
|---|
| 627 | UINT, arg3, | 
|---|
| 628 | UINT, arg4, | 
|---|
| 629 | LPCSTR, arg5) | 
|---|
| 630 | { | 
|---|
| 631 | dprintf(("USER32:  OS2ModifyMenuA\n")); | 
|---|
| 632 | if(hMenu == 0) | 
|---|
| 633 | { | 
|---|
| 634 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 635 | return 0; | 
|---|
| 636 | } | 
|---|
| 637 | return O32_ModifyMenu(hMenu, arg2, arg3, arg4, arg5); | 
|---|
| 638 | } | 
|---|
| 639 | //****************************************************************************** | 
|---|
| 640 | //****************************************************************************** | 
|---|
| 641 | ODINFUNCTION5(BOOL, ModifyMenuW, | 
|---|
| 642 | HMENU, hMenu, | 
|---|
| 643 | UINT, arg2, | 
|---|
| 644 | UINT, arg3, | 
|---|
| 645 | UINT, arg4, | 
|---|
| 646 | LPCWSTR, arg5) | 
|---|
| 647 | { | 
|---|
| 648 | BOOL  rc; | 
|---|
| 649 | char *astring = NULL; | 
|---|
| 650 |  | 
|---|
| 651 | if(hMenu == 0) | 
|---|
| 652 | { | 
|---|
| 653 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 654 | return 0; | 
|---|
| 655 | } | 
|---|
| 656 |  | 
|---|
| 657 | if(IS_STRING_ITEM(arg3) && HIWORD(arg5) != 0) | 
|---|
| 658 | astring = UnicodeToAsciiString((LPWSTR)arg5); | 
|---|
| 659 | else | 
|---|
| 660 | astring = (char *) arg5; | 
|---|
| 661 |  | 
|---|
| 662 | rc = ODIN_ModifyMenuA(hMenu, arg2, arg3, arg4, astring); | 
|---|
| 663 | if(IS_STRING_ITEM(arg3) && HIWORD(arg5) != 0) | 
|---|
| 664 | FreeAsciiString(astring); | 
|---|
| 665 |  | 
|---|
| 666 | return(rc); | 
|---|
| 667 | } | 
|---|
| 668 | //****************************************************************************** | 
|---|
| 669 | //****************************************************************************** | 
|---|
| 670 | ODINFUNCTION3(BOOL, RemoveMenu, | 
|---|
| 671 | HMENU, hMenu, | 
|---|
| 672 | UINT, arg2, | 
|---|
| 673 | UINT, arg3) | 
|---|
| 674 | { | 
|---|
| 675 | dprintf(("USER32:  OS2RemoveMenu\n")); | 
|---|
| 676 | if(hMenu == 0) | 
|---|
| 677 | { | 
|---|
| 678 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 679 | return 0; | 
|---|
| 680 | } | 
|---|
| 681 |  | 
|---|
| 682 | return O32_RemoveMenu(hMenu, arg2, arg3); | 
|---|
| 683 | } | 
|---|
| 684 | //****************************************************************************** | 
|---|
| 685 | //****************************************************************************** | 
|---|
| 686 | ODINFUNCTION3(BOOL, DeleteMenu, | 
|---|
| 687 | HMENU, hMenu, | 
|---|
| 688 | UINT, arg2, | 
|---|
| 689 | UINT, arg3) | 
|---|
| 690 | { | 
|---|
| 691 | dprintf(("USER32:  OS2DeleteMenu\n")); | 
|---|
| 692 | if(hMenu == 0) | 
|---|
| 693 | { | 
|---|
| 694 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 695 | return 0; | 
|---|
| 696 | } | 
|---|
| 697 |  | 
|---|
| 698 | return O32_DeleteMenu(hMenu, arg2, arg3); | 
|---|
| 699 | } | 
|---|
| 700 | //****************************************************************************** | 
|---|
| 701 | //****************************************************************************** | 
|---|
| 702 | ODINFUNCTION4(BOOL, HiliteMenuItem, | 
|---|
| 703 | HWND, hMenu, | 
|---|
| 704 | HMENU, arg2, | 
|---|
| 705 | UINT, arg3, | 
|---|
| 706 | UINT, arg4) | 
|---|
| 707 | { | 
|---|
| 708 | dprintf(("USER32:  OS2HiliteMenuItem\n")); | 
|---|
| 709 | if(hMenu == 0) | 
|---|
| 710 | { | 
|---|
| 711 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 712 | return 0; | 
|---|
| 713 | } | 
|---|
| 714 |  | 
|---|
| 715 | return O32_HiliteMenuItem(hMenu, arg2, arg3, arg4); | 
|---|
| 716 | } | 
|---|
| 717 | //****************************************************************************** | 
|---|
| 718 | //****************************************************************************** | 
|---|
| 719 | ODINFUNCTION5(BOOL, InsertMenuA, | 
|---|
| 720 | HMENU, hMenu, | 
|---|
| 721 | UINT, pos, | 
|---|
| 722 | UINT, flags, | 
|---|
| 723 | UINT, id, | 
|---|
| 724 | LPCSTR, str) | 
|---|
| 725 | { | 
|---|
| 726 | if(IS_STRING_ITEM(flags) && HIWORD(str)) { | 
|---|
| 727 | dprintf(("USER32: InsertMenuA %x %d %x %d %s", hMenu, pos, flags, id, str)); | 
|---|
| 728 | } | 
|---|
| 729 | else dprintf(("USER32: InsertMenuA %x %d %x %d %x", hMenu, pos, flags, id, str)); | 
|---|
| 730 |  | 
|---|
| 731 | if(hMenu == 0) | 
|---|
| 732 | { | 
|---|
| 733 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 734 | return 0; | 
|---|
| 735 | } | 
|---|
| 736 |  | 
|---|
| 737 | if(IS_STRING_ITEM(flags) && (!str || *str == NULL)) { | 
|---|
| 738 | flags |= MF_SEPARATOR; | 
|---|
| 739 | } | 
|---|
| 740 | return O32_InsertMenu(hMenu, pos, flags, id, str); | 
|---|
| 741 | } | 
|---|
| 742 | //****************************************************************************** | 
|---|
| 743 | //****************************************************************************** | 
|---|
| 744 | ODINFUNCTION5(BOOL, InsertMenuW, | 
|---|
| 745 | HMENU, hMenu, | 
|---|
| 746 | UINT, arg2, | 
|---|
| 747 | UINT, arg3, | 
|---|
| 748 | UINT, arg4, | 
|---|
| 749 | LPCWSTR, arg5) | 
|---|
| 750 | { | 
|---|
| 751 | BOOL  rc; | 
|---|
| 752 | char *astring = NULL; | 
|---|
| 753 |  | 
|---|
| 754 | if(IS_STRING_ITEM(arg3) && HIWORD(arg5) != 0) | 
|---|
| 755 | astring = UnicodeToAsciiString((LPWSTR)arg5); | 
|---|
| 756 | else | 
|---|
| 757 | astring = (char *) arg5; | 
|---|
| 758 |  | 
|---|
| 759 | rc = ODIN_InsertMenuA(hMenu, arg2, arg3, arg4, astring); | 
|---|
| 760 |  | 
|---|
| 761 | if(IS_STRING_ITEM(arg3) && HIWORD(arg5) != 0) | 
|---|
| 762 | FreeAsciiString(astring); | 
|---|
| 763 |  | 
|---|
| 764 | return(rc); | 
|---|
| 765 | } | 
|---|
| 766 | //****************************************************************************** | 
|---|
| 767 | //****************************************************************************** | 
|---|
| 768 | ODINFUNCTION2(BOOL, SetMenuContextHelpId, | 
|---|
| 769 | HMENU, hMenu, | 
|---|
| 770 | DWORD, dwContextHelpId) | 
|---|
| 771 | { | 
|---|
| 772 | POPUPMENU *menu; | 
|---|
| 773 |  | 
|---|
| 774 | menu = GetInternalMenuInfo(hMenu); | 
|---|
| 775 | if(menu == NULL) { | 
|---|
| 776 | dprintf(("USER32: SetMenuContextHelpId(%x) No POPUPMENU structure found!", hMenu)); | 
|---|
| 777 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 778 | return FALSE; | 
|---|
| 779 | } | 
|---|
| 780 | dprintf(("USER32:  SetMenuContextHelpId %x %d", hMenu, dwContextHelpId)); | 
|---|
| 781 | menu->dwContextHelpID = dwContextHelpId; | 
|---|
| 782 | return(TRUE); | 
|---|
| 783 | } | 
|---|
| 784 | //****************************************************************************** | 
|---|
| 785 | //****************************************************************************** | 
|---|
| 786 | ODINFUNCTION1(DWORD, GetMenuContextHelpId, | 
|---|
| 787 | HMENU, hMenu) | 
|---|
| 788 | { | 
|---|
| 789 | POPUPMENU *menu; | 
|---|
| 790 |  | 
|---|
| 791 | menu = GetInternalMenuInfo(hMenu); | 
|---|
| 792 | if(menu == NULL) { | 
|---|
| 793 | dprintf(("USER32: GetMenuContextHelpId(%x) No POPUPMENU structure found!", hMenu)); | 
|---|
| 794 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 795 | return 0; | 
|---|
| 796 | } | 
|---|
| 797 | dprintf(("USER32:  GetMenuContextHelpId %x %d", hMenu, menu->dwContextHelpID)); | 
|---|
| 798 | return menu->dwContextHelpID; | 
|---|
| 799 | } | 
|---|
| 800 | //****************************************************************************** | 
|---|
| 801 | //****************************************************************************** | 
|---|
| 802 | ODINFUNCTION5(BOOL, CheckMenuRadioItem, | 
|---|
| 803 | HMENU, hMenu, | 
|---|
| 804 | UINT, idFirst, | 
|---|
| 805 | UINT, idLast, | 
|---|
| 806 | UINT, idCheck, | 
|---|
| 807 | UINT, uFlags) | 
|---|
| 808 | { | 
|---|
| 809 | dprintf(("USER32:  OS2CheckMenuRadioItem, not implemented\n")); | 
|---|
| 810 | return(TRUE); | 
|---|
| 811 | } | 
|---|
| 812 | //****************************************************************************** | 
|---|
| 813 | //****************************************************************************** | 
|---|
| 814 | ODINFUNCTION5(BOOL, ChangeMenuA, | 
|---|
| 815 | HMENU, hMenu, | 
|---|
| 816 | UINT, pos, | 
|---|
| 817 | LPCSTR, data, | 
|---|
| 818 | UINT, id, | 
|---|
| 819 | UINT, flags) | 
|---|
| 820 | { | 
|---|
| 821 | dprintf(("USER32:  ChangeMenuA flags %X\n", flags)); | 
|---|
| 822 |  | 
|---|
| 823 | if (flags & MF_APPEND) return ODIN_AppendMenuA(hMenu, flags & ~MF_APPEND, | 
|---|
| 824 | id, data ); | 
|---|
| 825 | if (flags & MF_DELETE) return ODIN_DeleteMenu(hMenu, pos, flags & ~MF_DELETE); | 
|---|
| 826 | if (flags & MF_CHANGE) return ODIN_ModifyMenuA(hMenu, pos, flags & ~MF_CHANGE, | 
|---|
| 827 | id, data ); | 
|---|
| 828 | if (flags & MF_REMOVE) return ODIN_RemoveMenu(hMenu, | 
|---|
| 829 | flags & MF_BYPOSITION ? pos : id, | 
|---|
| 830 | flags & ~MF_REMOVE ); | 
|---|
| 831 | /* Default: MF_INSERT */ | 
|---|
| 832 | return InsertMenuA( hMenu, pos, flags, id, data ); | 
|---|
| 833 | } | 
|---|
| 834 | //****************************************************************************** | 
|---|
| 835 | //****************************************************************************** | 
|---|
| 836 | ODINFUNCTION5(BOOL, ChangeMenuW, | 
|---|
| 837 | HMENU, hMenu, | 
|---|
| 838 | UINT, pos, | 
|---|
| 839 | LPCWSTR, data, | 
|---|
| 840 | UINT, id, | 
|---|
| 841 | UINT, flags) | 
|---|
| 842 | { | 
|---|
| 843 | dprintf(("USER32:  ChangeMenuW flags %X\n", flags)); | 
|---|
| 844 |  | 
|---|
| 845 | if (flags & MF_APPEND) return ODIN_AppendMenuW(hMenu, flags & ~MF_APPEND, | 
|---|
| 846 | id, data ); | 
|---|
| 847 | if (flags & MF_DELETE) return ODIN_DeleteMenu(hMenu, pos, flags & ~MF_DELETE); | 
|---|
| 848 | if (flags & MF_CHANGE) return ODIN_ModifyMenuW(hMenu, pos, flags & ~MF_CHANGE, | 
|---|
| 849 | id, data ); | 
|---|
| 850 | if (flags & MF_REMOVE) return ODIN_RemoveMenu(hMenu, | 
|---|
| 851 | flags & MF_BYPOSITION ? pos : id, | 
|---|
| 852 | flags & ~MF_REMOVE ); | 
|---|
| 853 | /* Default: MF_INSERT */ | 
|---|
| 854 | return InsertMenuW(hMenu, pos, flags, id, data); | 
|---|
| 855 | } | 
|---|
| 856 | //****************************************************************************** | 
|---|
| 857 | //****************************************************************************** | 
|---|
| 858 | ODINFUNCTION4(BOOL, SetMenuItemInfoA, | 
|---|
| 859 | HMENU, hMenu, | 
|---|
| 860 | UINT, par1, | 
|---|
| 861 | BOOL, par2, | 
|---|
| 862 | const MENUITEMINFOA *, lpmii) | 
|---|
| 863 | { | 
|---|
| 864 | dprintf(("USER32:  SetMenuItemInfoA faked %x", hMenu)); | 
|---|
| 865 |  | 
|---|
| 866 | if (!hMenu) { | 
|---|
| 867 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 868 | return FALSE; | 
|---|
| 869 | } | 
|---|
| 870 | return TRUE; | 
|---|
| 871 | } | 
|---|
| 872 | /***************************************************************************** | 
|---|
| 873 | * Function  : SetMenuItemInfoW | 
|---|
| 874 | * Purpose   : The SetMenuItemInfo function changes information about a menu item. | 
|---|
| 875 | * Parameters: | 
|---|
| 876 | * Variables : | 
|---|
| 877 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 878 | *             If the function fails, the return value is FALSE. To get extended | 
|---|
| 879 | *               error information, use the GetLastError function. | 
|---|
| 880 | * Remark    : | 
|---|
| 881 | * Status    : UNTESTED STUB | 
|---|
| 882 | * | 
|---|
| 883 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 884 | *****************************************************************************/ | 
|---|
| 885 |  | 
|---|
| 886 | ODINFUNCTION4(BOOL, SetMenuItemInfoW, | 
|---|
| 887 | HMENU, hMenu, | 
|---|
| 888 | UINT, uItem, | 
|---|
| 889 | BOOL, fByPosition, | 
|---|
| 890 | const MENUITEMINFOW *, lpmmi) | 
|---|
| 891 | { | 
|---|
| 892 | dprintf(("USER32:SetMenuItemInfoW (%08xh,%08xh,%08xh,%08x) not implemented.\n", | 
|---|
| 893 | hMenu, | 
|---|
| 894 | uItem, | 
|---|
| 895 | fByPosition, | 
|---|
| 896 | lpmmi)); | 
|---|
| 897 |  | 
|---|
| 898 | return (SetMenuItemInfoA(hMenu, | 
|---|
| 899 | uItem, | 
|---|
| 900 | fByPosition, | 
|---|
| 901 | (const MENUITEMINFOA *)lpmmi)); | 
|---|
| 902 | } | 
|---|
| 903 | /***************************************************************************** | 
|---|
| 904 | * Function  : GetMenuDefaultItem | 
|---|
| 905 | * Purpose   : TheGetMenuDefaultItem function determines the default menu item | 
|---|
| 906 | *             on the specified menu. | 
|---|
| 907 | * Parameters: | 
|---|
| 908 | * Variables : | 
|---|
| 909 | * Result    : If the function succeeds, the return value is the identifier or | 
|---|
| 910 | *             position of the menu item. | 
|---|
| 911 | *             If the function fails, the return value is - 1. | 
|---|
| 912 | * Remark    : | 
|---|
| 913 | * Status    : UNTESTED STUB | 
|---|
| 914 | * | 
|---|
| 915 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 916 | *****************************************************************************/ | 
|---|
| 917 |  | 
|---|
| 918 | ODINFUNCTION3(UINT, GetMenuDefaultItem, | 
|---|
| 919 | HMENU, hMenu, | 
|---|
| 920 | UINT, fByPos, | 
|---|
| 921 | UINT, gmdiFlags) | 
|---|
| 922 | { | 
|---|
| 923 | dprintf(("USER32:GetMenuDefaultItem (%08xh,%u,%08x) not implemented.\n", | 
|---|
| 924 | hMenu, | 
|---|
| 925 | fByPos, | 
|---|
| 926 | gmdiFlags)); | 
|---|
| 927 |  | 
|---|
| 928 | return (-1); | 
|---|
| 929 | } | 
|---|
| 930 | //****************************************************************************** | 
|---|
| 931 | //****************************************************************************** | 
|---|
| 932 | ODINFUNCTION3(BOOL, SetMenuDefaultItem, | 
|---|
| 933 | HMENU, hMenu, | 
|---|
| 934 | UINT, uItem, | 
|---|
| 935 | UINT, fByPos) | 
|---|
| 936 | { | 
|---|
| 937 | dprintf(("USER32:  SetMenuDefaultItem, faked\n")); | 
|---|
| 938 | return(TRUE); | 
|---|
| 939 | } | 
|---|
| 940 | //****************************************************************************** | 
|---|
| 941 | //****************************************************************************** | 
|---|
| 942 | BOOL GetMenuItemInfoAW(HMENU hMenu, UINT uItem, BOOL byPos, MENUITEMINFOA *lpmii, BOOL unicode) | 
|---|
| 943 | { | 
|---|
| 944 | if(byPos) { | 
|---|
| 945 | uItem = GetMenuItemID(hMenu, uItem); | 
|---|
| 946 | } | 
|---|
| 947 | if(ODIN_GetMenuState(hMenu, uItem, MF_BYCOMMAND) == -1) { | 
|---|
| 948 | //item doesn't exist | 
|---|
| 949 | dprintf(("USER32:  GetMenuItemInfoAW %x item %d doesn't exist", hMenu, uItem)); | 
|---|
| 950 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 951 | return FALSE; | 
|---|
| 952 | } | 
|---|
| 953 | if (lpmii->fMask & MIIM_TYPE) | 
|---|
| 954 | { | 
|---|
| 955 | lpmii->fType = ODIN_GetMenuState(hMenu, uItem, MF_BYCOMMAND); //not correct | 
|---|
| 956 | //      lpmii->fType = menu->fType; | 
|---|
| 957 | if (unicode) { | 
|---|
| 958 | lpmii->cch = ODIN_GetMenuStringW(hMenu, uItem, (LPWSTR)lpmii->dwTypeData, lpmii->cch, MF_BYCOMMAND); | 
|---|
| 959 | } | 
|---|
| 960 | else { | 
|---|
| 961 | lpmii->cch = ODIN_GetMenuStringA(hMenu, uItem, (LPSTR)lpmii->dwTypeData, lpmii->cch, MF_BYCOMMAND); | 
|---|
| 962 | } | 
|---|
| 963 | //TODO: | 
|---|
| 964 | #if 0 | 
|---|
| 965 | switch (MENU_ITEM_TYPE(menu->fType)) { | 
|---|
| 966 | case MF_STRING: | 
|---|
| 967 | if (menu->text && lpmii->dwTypeData && lpmii->cch) { | 
|---|
| 968 | if (unicode) { | 
|---|
| 969 | lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text, lpmii->cch); | 
|---|
| 970 | lpmii->cch = lstrlenW((LPWSTR)menu->text); | 
|---|
| 971 | } | 
|---|
| 972 | else { | 
|---|
| 973 | lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch); | 
|---|
| 974 | lpmii->cch = lstrlenA(menu->text); | 
|---|
| 975 | } | 
|---|
| 976 | } | 
|---|
| 977 | break; | 
|---|
| 978 | case MF_OWNERDRAW: | 
|---|
| 979 | case MF_BITMAP: | 
|---|
| 980 | lpmii->dwTypeData = menu->text; | 
|---|
| 981 | /* fall through */ | 
|---|
| 982 | default: | 
|---|
| 983 | lpmii->cch = 0; | 
|---|
| 984 | } | 
|---|
| 985 | #endif | 
|---|
| 986 | } | 
|---|
| 987 |  | 
|---|
| 988 | if (lpmii->fMask & MIIM_STRING) { | 
|---|
| 989 | if (unicode) { | 
|---|
| 990 | lpmii->cch = ODIN_GetMenuStringW(hMenu, uItem, (LPWSTR)lpmii->dwTypeData, lpmii->cch, MF_BYCOMMAND); | 
|---|
| 991 | } | 
|---|
| 992 | else { | 
|---|
| 993 | lpmii->cch = ODIN_GetMenuStringA(hMenu, uItem, (LPSTR)lpmii->dwTypeData, lpmii->cch, MF_BYCOMMAND); | 
|---|
| 994 | } | 
|---|
| 995 | } | 
|---|
| 996 |  | 
|---|
| 997 | //TODO: | 
|---|
| 998 | #if 0 | 
|---|
| 999 | if (lpmii->fMask & MIIM_FTYPE) | 
|---|
| 1000 | lpmii->fType = menu->fType; | 
|---|
| 1001 |  | 
|---|
| 1002 | if (lpmii->fMask & MIIM_BITMAP) | 
|---|
| 1003 | lpmii->hbmpItem = menu->hbmpItem; | 
|---|
| 1004 | #endif | 
|---|
| 1005 |  | 
|---|
| 1006 | if (lpmii->fMask & MIIM_STATE) | 
|---|
| 1007 | lpmii->fState = ODIN_GetMenuState(hMenu, uItem, MF_BYCOMMAND); | 
|---|
| 1008 |  | 
|---|
| 1009 | if (lpmii->fMask & MIIM_ID) | 
|---|
| 1010 | lpmii->wID = uItem; | 
|---|
| 1011 |  | 
|---|
| 1012 | //TODO: | 
|---|
| 1013 | #if 1 | 
|---|
| 1014 | lpmii->hSubMenu = 0; | 
|---|
| 1015 | lpmii->hbmpChecked = 0; | 
|---|
| 1016 | lpmii->hbmpUnchecked = 0; | 
|---|
| 1017 | lpmii->dwItemData = 0; | 
|---|
| 1018 | #else | 
|---|
| 1019 | if (lpmii->fMask & MIIM_SUBMENU) | 
|---|
| 1020 | lpmii->hSubMenu = ODIN_GetSubMenu(hMenu, uItem); //need index, not id | 
|---|
| 1021 |  | 
|---|
| 1022 | if (lpmii->fMask & MIIM_CHECKMARKS) { | 
|---|
| 1023 | lpmii->hbmpChecked = menu->hCheckBit; | 
|---|
| 1024 | lpmii->hbmpUnchecked = menu->hUnCheckBit; | 
|---|
| 1025 | } | 
|---|
| 1026 | if (lpmii->fMask & MIIM_DATA) | 
|---|
| 1027 | lpmii->dwItemData = menu->dwItemData; | 
|---|
| 1028 | #endif | 
|---|
| 1029 |  | 
|---|
| 1030 | return(FALSE); | 
|---|
| 1031 | } | 
|---|
| 1032 | //****************************************************************************** | 
|---|
| 1033 | //****************************************************************************** | 
|---|
| 1034 | ODINFUNCTION4(BOOL, GetMenuItemInfoA, | 
|---|
| 1035 | HMENU, hMenu, | 
|---|
| 1036 | UINT, uItem, | 
|---|
| 1037 | BOOL, byPos, | 
|---|
| 1038 | MENUITEMINFOA *, lpMenuItemInfo) | 
|---|
| 1039 | { | 
|---|
| 1040 | return GetMenuItemInfoAW(hMenu, uItem, byPos, lpMenuItemInfo, FALSE); | 
|---|
| 1041 | } | 
|---|
| 1042 | /***************************************************************************** | 
|---|
| 1043 | * Function  : GetMenuItemInfoW | 
|---|
| 1044 | * Purpose   : The GetMenuItemInfo function retrieves information about a menu item. | 
|---|
| 1045 | * Parameters: | 
|---|
| 1046 | * Variables : | 
|---|
| 1047 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 1048 | *             If the function fails, the return value is FALSE. To get extended | 
|---|
| 1049 | *             error information, use the GetLastError function. | 
|---|
| 1050 | * Remark    : | 
|---|
| 1051 | * Status    : UNTESTED STUB | 
|---|
| 1052 | * | 
|---|
| 1053 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1054 | *****************************************************************************/ | 
|---|
| 1055 |  | 
|---|
| 1056 | ODINFUNCTION4(BOOL, GetMenuItemInfoW, | 
|---|
| 1057 | HMENU, hMenu, | 
|---|
| 1058 | UINT, uItem, | 
|---|
| 1059 | BOOL, byPos, | 
|---|
| 1060 | MENUITEMINFOW *, lpMenuItemInfo) | 
|---|
| 1061 | { | 
|---|
| 1062 | return GetMenuItemInfoAW(hMenu, uItem, byPos, (MENUITEMINFOA*)lpMenuItemInfo, TRUE); | 
|---|
| 1063 | } | 
|---|
| 1064 | /***************************************************************************** | 
|---|
| 1065 | * Function  : GetMenuItemRect | 
|---|
| 1066 | * Purpose   : The GetMenuItemRect function retrieves the bounding rectangle | 
|---|
| 1067 | *             for the specified menu item. | 
|---|
| 1068 | * Parameters: | 
|---|
| 1069 | * Variables : | 
|---|
| 1070 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 1071 | *             If the function fails, the return value is FALSE. To get | 
|---|
| 1072 | *             extended error information, use the GetLastError function. | 
|---|
| 1073 | * Remark    : | 
|---|
| 1074 | * Status    : | 
|---|
| 1075 | * | 
|---|
| 1076 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1077 | *****************************************************************************/ | 
|---|
| 1078 |  | 
|---|
| 1079 | ODINFUNCTION4(BOOL, GetMenuItemRect, | 
|---|
| 1080 | HWND, hWnd, | 
|---|
| 1081 | HMENU, hMenu, | 
|---|
| 1082 | UINT, uItem, | 
|---|
| 1083 | LPRECT, lprcItem) | 
|---|
| 1084 | { | 
|---|
| 1085 | return OSLibGetMenuItemRect(hMenu, uItem, lprcItem); | 
|---|
| 1086 | } | 
|---|
| 1087 | /***************************************************************************** | 
|---|
| 1088 | * Function  : InsertMenuItemA | 
|---|
| 1089 | * Purpose   : The InsertMenuItem function inserts a new menu item at the specified | 
|---|
| 1090 | *             position in a menu bar or pop-up menu. | 
|---|
| 1091 | * Parameters: | 
|---|
| 1092 | * Variables : | 
|---|
| 1093 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 1094 | *             If the function fails, the return value is FALSE. To get extended | 
|---|
| 1095 | *             error information, use the GetLastError function. | 
|---|
| 1096 | * Remark    : | 
|---|
| 1097 | * Status    : UNTESTED STUB | 
|---|
| 1098 | * | 
|---|
| 1099 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1100 | *****************************************************************************/ | 
|---|
| 1101 |  | 
|---|
| 1102 | ODINFUNCTION4(BOOL, InsertMenuItemA, | 
|---|
| 1103 | HMENU, hMenu, | 
|---|
| 1104 | UINT, uItem, | 
|---|
| 1105 | BOOL, fByPosition, | 
|---|
| 1106 | const MENUITEMINFOA*, lpmii) | 
|---|
| 1107 | { | 
|---|
| 1108 | DWORD dwType; | 
|---|
| 1109 | BOOL rc; | 
|---|
| 1110 |  | 
|---|
| 1111 | dprintf(("USER32:InsertMenuItemA (%08xh,%08xh,%u,%08x) not correctly implemented.\n", | 
|---|
| 1112 | hMenu, | 
|---|
| 1113 | uItem, | 
|---|
| 1114 | fByPosition, | 
|---|
| 1115 | lpmii)); | 
|---|
| 1116 |  | 
|---|
| 1117 | if(fByPosition) { | 
|---|
| 1118 | dwType = lpmii->fType | MF_BYPOSITION; | 
|---|
| 1119 | } | 
|---|
| 1120 | else    dwType = lpmii->fType | MF_BYCOMMAND; | 
|---|
| 1121 |  | 
|---|
| 1122 | if(lpmii->fMask & MIIM_SUBMENU && lpmii->hSubMenu) { | 
|---|
| 1123 | rc &= ODIN_InsertMenuA(hMenu, uItem, dwType | MF_POPUP, lpmii->hSubMenu, lpmii->dwTypeData); | 
|---|
| 1124 | } | 
|---|
| 1125 | else | 
|---|
| 1126 | if(lpmii->fMask & MIIM_ID) { | 
|---|
| 1127 | rc = ODIN_InsertMenuA(hMenu, uItem, dwType, lpmii->wID, lpmii->dwTypeData); | 
|---|
| 1128 | } | 
|---|
| 1129 | if(lpmii->fMask & MIIM_STATE) { | 
|---|
| 1130 | //TODO | 
|---|
| 1131 | } | 
|---|
| 1132 | return rc; | 
|---|
| 1133 | } | 
|---|
| 1134 |  | 
|---|
| 1135 |  | 
|---|
| 1136 | /***************************************************************************** | 
|---|
| 1137 | * Function  : InsertMenuItemW | 
|---|
| 1138 | * Purpose   : The InsertMenuItem function inserts a new menu item at the specified | 
|---|
| 1139 | *             position in a menu bar or pop-up menu. | 
|---|
| 1140 | * Parameters: | 
|---|
| 1141 | * Variables : | 
|---|
| 1142 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 1143 | *             If the function fails, the return value is FALSE. To get extended | 
|---|
| 1144 | *             error information, use the GetLastError function. | 
|---|
| 1145 | * Remark    : | 
|---|
| 1146 | * Status    : UNTESTED STUB | 
|---|
| 1147 | * | 
|---|
| 1148 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1149 | *****************************************************************************/ | 
|---|
| 1150 |  | 
|---|
| 1151 | ODINFUNCTION4(BOOL, InsertMenuItemW, | 
|---|
| 1152 | HMENU, hMenu, | 
|---|
| 1153 | UINT, uItem, | 
|---|
| 1154 | BOOL, fByPosition, | 
|---|
| 1155 | const MENUITEMINFOW *, lpmii) | 
|---|
| 1156 | { | 
|---|
| 1157 | dprintf(("USER32:InsertMenuItemW (%08xh,%08xh,%u,%08x) not correctly implemented.\n", | 
|---|
| 1158 | hMenu, | 
|---|
| 1159 | uItem, | 
|---|
| 1160 | fByPosition, | 
|---|
| 1161 | lpmii)); | 
|---|
| 1162 |  | 
|---|
| 1163 | if(fByPosition) { | 
|---|
| 1164 | return ODIN_InsertMenuW(hMenu, uItem, lpmii->fType | MF_BYPOSITION, (lpmii->fType & MF_POPUP) ? lpmii->hSubMenu : lpmii->wID, lpmii->dwTypeData); | 
|---|
| 1165 | } | 
|---|
| 1166 | else    return ODIN_InsertMenuW(hMenu, uItem, lpmii->fType | MF_BYCOMMAND, (lpmii->fType & MF_POPUP) ? lpmii->hSubMenu : lpmii->wID, lpmii->dwTypeData); | 
|---|
| 1167 | } | 
|---|
| 1168 | /***************************************************************************** | 
|---|
| 1169 | * Function  : MenuItemFromPoint | 
|---|
| 1170 | * Purpose   : TheMenuItemFromPoint function determines which menu item, if | 
|---|
| 1171 | *             any, is at the specified location. | 
|---|
| 1172 | * Parameters: | 
|---|
| 1173 | * Variables : | 
|---|
| 1174 | * Result    : Returns the zero-based position of the menu item at the specified | 
|---|
| 1175 | *             location or -1 if no menu item is at the specified location. | 
|---|
| 1176 | * Remark    : | 
|---|
| 1177 | * Status    : UNTESTED STUB | 
|---|
| 1178 | * | 
|---|
| 1179 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1180 | *****************************************************************************/ | 
|---|
| 1181 |  | 
|---|
| 1182 | ODINFUNCTION3(UINT, MenuItemFromPoint, | 
|---|
| 1183 | HWND, hWnd, | 
|---|
| 1184 | HMENU, hMenu, | 
|---|
| 1185 | POINT, ptScreen) | 
|---|
| 1186 | { | 
|---|
| 1187 | dprintf(("USER32:MenuItemFromPoint (%08xh,%08xh,%u) not implemented.\n", | 
|---|
| 1188 | hWnd, | 
|---|
| 1189 | hMenu, | 
|---|
| 1190 | ptScreen)); | 
|---|
| 1191 |  | 
|---|
| 1192 | return (-1); | 
|---|
| 1193 | } | 
|---|
| 1194 |  | 
|---|
| 1195 |  | 
|---|
| 1196 | /***************************************************************************** | 
|---|
| 1197 | * Function  :  GetMenuInfo | 
|---|
| 1198 | * Parameters: | 
|---|
| 1199 | * Variables : | 
|---|
| 1200 | * Result    : | 
|---|
| 1201 | * Remark    : | 
|---|
| 1202 | * Status    : UNTESTED STUB win98/NT5.0 | 
|---|
| 1203 | * | 
|---|
| 1204 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1205 | *****************************************************************************/ | 
|---|
| 1206 |  | 
|---|
| 1207 | ODINFUNCTION2(BOOL, GetMenuInfo, | 
|---|
| 1208 | HMENU, hMenu, | 
|---|
| 1209 | LPMENUINFO, lpmi) | 
|---|
| 1210 | { | 
|---|
| 1211 | POPUPMENU *menu; | 
|---|
| 1212 |  | 
|---|
| 1213 | menu = GetInternalMenuInfo(hMenu); | 
|---|
| 1214 | if(menu == NULL) { | 
|---|
| 1215 | dprintf(("USER32: GetMenuInfo(%08xh,%08xh) No POPUPMENU structure found!", hMenu, lpmi)); | 
|---|
| 1216 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 1217 | return FALSE; | 
|---|
| 1218 | } | 
|---|
| 1219 | dprintf(("USER32: GetMenuInfo(%08xh,%08xh)", hMenu, lpmi)); | 
|---|
| 1220 |  | 
|---|
| 1221 | if (lpmi) | 
|---|
| 1222 | { | 
|---|
| 1223 | if (lpmi->fMask & MIM_BACKGROUND) | 
|---|
| 1224 | lpmi->hbrBack = menu->hbrBack; | 
|---|
| 1225 |  | 
|---|
| 1226 | if (lpmi->fMask & MIM_HELPID) | 
|---|
| 1227 | lpmi->dwContextHelpID = menu->dwContextHelpID; | 
|---|
| 1228 |  | 
|---|
| 1229 | if (lpmi->fMask & MIM_MAXHEIGHT) | 
|---|
| 1230 | lpmi->cyMax = menu->cyMax; | 
|---|
| 1231 |  | 
|---|
| 1232 | if (lpmi->fMask & MIM_MENUDATA) | 
|---|
| 1233 | lpmi->dwMenuData = menu->dwMenuData; | 
|---|
| 1234 |  | 
|---|
| 1235 | if (lpmi->fMask & MIM_STYLE) | 
|---|
| 1236 | lpmi->dwStyle = menu->dwStyle; | 
|---|
| 1237 |  | 
|---|
| 1238 | return TRUE; | 
|---|
| 1239 | } | 
|---|
| 1240 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 1241 | return FALSE; | 
|---|
| 1242 | } | 
|---|
| 1243 | /***************************************************************************** | 
|---|
| 1244 | * Function  :  SetMenuInfo | 
|---|
| 1245 | * Purpose   : | 
|---|
| 1246 | * Parameters: | 
|---|
| 1247 | * Variables : | 
|---|
| 1248 | * Result    : | 
|---|
| 1249 | * Remark    : | 
|---|
| 1250 | * FIXME | 
|---|
| 1251 | * MIM_APPLYTOSUBMENUS | 
|---|
| 1252 | * actually use the items to draw the menu | 
|---|
| 1253 | * Status    : UNTESTED STUB win98/NT5.0 | 
|---|
| 1254 | * | 
|---|
| 1255 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1256 | *****************************************************************************/ | 
|---|
| 1257 |  | 
|---|
| 1258 | ODINFUNCTION2(BOOL, SetMenuInfo, | 
|---|
| 1259 | HMENU, hMenu, | 
|---|
| 1260 | LPCMENUINFO, lpmi) | 
|---|
| 1261 | { | 
|---|
| 1262 | POPUPMENU *menu; | 
|---|
| 1263 |  | 
|---|
| 1264 | menu = GetInternalMenuInfo(hMenu); | 
|---|
| 1265 | if(menu == NULL) { | 
|---|
| 1266 | dprintf(("USER32: SetMenuInfo(%08xh,%08xh) No POPUPMENU structure found!", hMenu, lpmi)); | 
|---|
| 1267 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 1268 | return FALSE; | 
|---|
| 1269 | } | 
|---|
| 1270 |  | 
|---|
| 1271 | dprintf(("USER32: SetMenuInfo(%08xh,%08xh)", hMenu, lpmi)); | 
|---|
| 1272 |  | 
|---|
| 1273 | if (lpmi && (lpmi->cbSize==sizeof(MENUINFO))) | 
|---|
| 1274 | { | 
|---|
| 1275 | if (lpmi->fMask & MIM_BACKGROUND) | 
|---|
| 1276 | menu->hbrBack = lpmi->hbrBack; | 
|---|
| 1277 |  | 
|---|
| 1278 | if (lpmi->fMask & MIM_HELPID) | 
|---|
| 1279 | menu->dwContextHelpID = lpmi->dwContextHelpID; | 
|---|
| 1280 |  | 
|---|
| 1281 | if (lpmi->fMask & MIM_MAXHEIGHT) | 
|---|
| 1282 | menu->cyMax = lpmi->cyMax; | 
|---|
| 1283 |  | 
|---|
| 1284 | if (lpmi->fMask & MIM_MENUDATA) | 
|---|
| 1285 | menu->dwMenuData = lpmi->dwMenuData; | 
|---|
| 1286 |  | 
|---|
| 1287 | if (lpmi->fMask & MIM_STYLE) | 
|---|
| 1288 | menu->dwStyle = lpmi->dwStyle; | 
|---|
| 1289 |  | 
|---|
| 1290 | return TRUE; | 
|---|
| 1291 | } | 
|---|
| 1292 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 1293 | return FALSE; | 
|---|
| 1294 | } | 
|---|
| 1295 | //****************************************************************************** | 
|---|
| 1296 | //****************************************************************************** | 
|---|
| 1297 |  | 
|---|