| 1 | /* $Id: winmenu.cpp,v 1.4 1999-08-31 17:14:52 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: (ChangeMenuA/W)
|
|---|
| 10 | * Copyright 1993 Martin Ayotte
|
|---|
| 11 | * Copyright 1994 Alexandre Julliard
|
|---|
| 12 | * Copyright 1997 Morten Welinder
|
|---|
| 13 | *
|
|---|
| 14 | *
|
|---|
| 15 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 16 | *
|
|---|
| 17 | */
|
|---|
| 18 | #include <os2win.h>
|
|---|
| 19 | #include <stdlib.h>
|
|---|
| 20 | #include <win32wbase.h>
|
|---|
| 21 | #include "oslibmenu.h"
|
|---|
| 22 | #include <winresmenu.h>
|
|---|
| 23 |
|
|---|
| 24 | //******************************************************************************
|
|---|
| 25 | //******************************************************************************
|
|---|
| 26 | HMENU WIN32API LoadMenuA(HINSTANCE hinst, LPCSTR lpszMenu)
|
|---|
| 27 | {
|
|---|
| 28 | HMENU rc;
|
|---|
| 29 |
|
|---|
| 30 | rc = (HMENU)FindResourceA(hinst, lpszMenu, RT_MENUA);
|
|---|
| 31 | dprintf(("LoadMenuA (%X) returned %d\n", hinst, rc));
|
|---|
| 32 | return(rc);
|
|---|
| 33 | }
|
|---|
| 34 | //******************************************************************************
|
|---|
| 35 | //******************************************************************************
|
|---|
| 36 | HMENU WIN32API LoadMenuW(HINSTANCE hinst, LPCWSTR lpszMenu)
|
|---|
| 37 | {
|
|---|
| 38 | HMENU rc;
|
|---|
| 39 |
|
|---|
| 40 | rc = (HMENU)FindResourceW(hinst, lpszMenu, RT_MENUW);
|
|---|
| 41 | dprintf(("LoadMenuW (%X) returned %d\n", hinst, rc));
|
|---|
| 42 | return(rc);
|
|---|
| 43 | }
|
|---|
| 44 | //******************************************************************************
|
|---|
| 45 | //TODO: Create PM object?
|
|---|
| 46 | //NOTE: menutemplate strings are always in Unicode format
|
|---|
| 47 | //******************************************************************************
|
|---|
| 48 | HMENU WIN32API LoadMenuIndirectA( const MENUITEMTEMPLATEHEADER * menuTemplate)
|
|---|
| 49 | {
|
|---|
| 50 | Win32MenuRes *winres;
|
|---|
| 51 |
|
|---|
| 52 | dprintf(("OS2LoadMenuIndirectA\n"));
|
|---|
| 53 | winres = new Win32MenuRes((LPVOID)menuTemplate);
|
|---|
| 54 | if(winres == NULL) {
|
|---|
| 55 | return 0;
|
|---|
| 56 | }
|
|---|
| 57 | return (HMENU)winres;
|
|---|
| 58 | }
|
|---|
| 59 | //******************************************************************************
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | HMENU WIN32API LoadMenuIndirectW(const MENUITEMTEMPLATEHEADER *menuTemplate)
|
|---|
| 62 | {
|
|---|
| 63 | Win32MenuRes *winres;
|
|---|
| 64 |
|
|---|
| 65 | dprintf(("OS2LoadMenuIndirectW\n"));
|
|---|
| 66 | winres = new Win32MenuRes((LPVOID)menuTemplate);
|
|---|
| 67 | if(winres == NULL) {
|
|---|
| 68 | return 0;
|
|---|
| 69 | }
|
|---|
| 70 | return (HMENU)winres;
|
|---|
| 71 | }
|
|---|
| 72 | //******************************************************************************
|
|---|
| 73 | //******************************************************************************
|
|---|
| 74 | BOOL WIN32API DestroyMenu(HMENU hmenu)
|
|---|
| 75 | {
|
|---|
| 76 | Win32MenuRes *winres;
|
|---|
| 77 |
|
|---|
| 78 | dprintf(("OS2DestroyMenu\n"));
|
|---|
| 79 | if(HIWORD(hmenu) == 0) {
|
|---|
| 80 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 81 | return FALSE;
|
|---|
| 82 | }
|
|---|
| 83 | winres = (Win32MenuRes *)hmenu;
|
|---|
| 84 | delete winres;
|
|---|
| 85 | return TRUE;
|
|---|
| 86 | }
|
|---|
| 87 | //******************************************************************************
|
|---|
| 88 | //******************************************************************************
|
|---|
| 89 | HMENU WIN32API GetMenu( HWND hwnd)
|
|---|
| 90 | {
|
|---|
| 91 | Win32BaseWindow *window;
|
|---|
| 92 |
|
|---|
| 93 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 94 | if(!window) {
|
|---|
| 95 | dprintf(("GetMenu, window %x not found", hwnd));
|
|---|
| 96 | return 0;
|
|---|
| 97 | }
|
|---|
| 98 | dprintf(("GetMenu %x", hwnd));
|
|---|
| 99 | return window->GetMenu();
|
|---|
| 100 | }
|
|---|
| 101 | //******************************************************************************
|
|---|
| 102 | //******************************************************************************
|
|---|
| 103 | BOOL WIN32API SetMenu( HWND hwnd, HMENU hmenu)
|
|---|
| 104 | {
|
|---|
| 105 | Win32BaseWindow *window;
|
|---|
| 106 |
|
|---|
| 107 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 108 | if(!window) {
|
|---|
| 109 | dprintf(("GetMenu, window %x not found", hwnd));
|
|---|
| 110 | return 0;
|
|---|
| 111 | }
|
|---|
| 112 | dprintf(("SetMenu %x %x\n", hwnd, hmenu));
|
|---|
| 113 | window->SetMenu(hmenu);
|
|---|
| 114 | return TRUE;
|
|---|
| 115 | }
|
|---|
| 116 | //******************************************************************************
|
|---|
| 117 | //******************************************************************************
|
|---|
| 118 | DWORD WIN32API GetMenuCheckMarkDimensions(void)
|
|---|
| 119 | {
|
|---|
| 120 | dprintf(("USER32: GetMenuCheckMarkDimensions\n"));
|
|---|
| 121 | return O32_GetMenuCheckMarkDimensions();
|
|---|
| 122 | }
|
|---|
| 123 | //******************************************************************************
|
|---|
| 124 | //******************************************************************************
|
|---|
| 125 | int WIN32API GetMenuItemCount( HMENU hMenu)
|
|---|
| 126 | {
|
|---|
| 127 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 128 |
|
|---|
| 129 | dprintf(("USER32: GetMenuItemCount %x", hMenu));
|
|---|
| 130 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 131 | {
|
|---|
| 132 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 133 | return 0;
|
|---|
| 134 | }
|
|---|
| 135 | return OSLibGetMenuItemCount(menu->getOS2Handle());
|
|---|
| 136 | }
|
|---|
| 137 | //******************************************************************************
|
|---|
| 138 | //******************************************************************************
|
|---|
| 139 | UINT WIN32API GetMenuItemID( HMENU hMenu, int nPos)
|
|---|
| 140 | {
|
|---|
| 141 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 142 |
|
|---|
| 143 | dprintf(("USER32: GetMenuItemID %x %d\n", hMenu, nPos));
|
|---|
| 144 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 145 | {
|
|---|
| 146 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 147 | return 0;
|
|---|
| 148 | }
|
|---|
| 149 | return O32_GetMenuItemID(menu->getOS2Handle(), nPos);
|
|---|
| 150 | }
|
|---|
| 151 | //******************************************************************************
|
|---|
| 152 | //******************************************************************************
|
|---|
| 153 | UINT WIN32API GetMenuState(HMENU hMenu, UINT arg2, UINT arg3)
|
|---|
| 154 | {
|
|---|
| 155 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 156 |
|
|---|
| 157 | dprintf(("USER32: GetMenuState\n"));
|
|---|
| 158 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 159 | {
|
|---|
| 160 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 161 | return 0;
|
|---|
| 162 | }
|
|---|
| 163 | return O32_GetMenuState(menu->getOS2Handle(), arg2, arg3);
|
|---|
| 164 | }
|
|---|
| 165 | //******************************************************************************
|
|---|
| 166 | //******************************************************************************
|
|---|
| 167 | int WIN32API GetMenuStringA( HMENU hMenu, UINT arg2, LPSTR arg3, int arg4, UINT arg5)
|
|---|
| 168 | {
|
|---|
| 169 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 170 |
|
|---|
| 171 | dprintf(("USER32: GetMenuStringA"));
|
|---|
| 172 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 173 | {
|
|---|
| 174 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 175 | return 0;
|
|---|
| 176 | }
|
|---|
| 177 | return O32_GetMenuString(menu->getOS2Handle(), arg2, arg3, arg4, arg5);
|
|---|
| 178 | }
|
|---|
| 179 | //******************************************************************************
|
|---|
| 180 | //******************************************************************************
|
|---|
| 181 | int WIN32API GetMenuStringW(HMENU hMenu, UINT idItem, LPWSTR lpsz, int cchMax, UINT fuFlags)
|
|---|
| 182 | {
|
|---|
| 183 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 184 | char *astring = (char *)malloc(cchMax);
|
|---|
| 185 | int rc;
|
|---|
| 186 |
|
|---|
| 187 | dprintf(("USER32: GetMenuStringW"));
|
|---|
| 188 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 189 | {
|
|---|
| 190 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 191 | return 0;
|
|---|
| 192 | }
|
|---|
| 193 | rc = O32_GetMenuString(menu->getOS2Handle(), idItem, astring, cchMax, fuFlags);
|
|---|
| 194 | free(astring);
|
|---|
| 195 | if(rc) {
|
|---|
| 196 | dprintf(("USER32: OS2GetMenuStringW %s\n", astring));
|
|---|
| 197 | AsciiToUnicode(astring, lpsz);
|
|---|
| 198 | }
|
|---|
| 199 | else lpsz[0] = 0;
|
|---|
| 200 | return(rc);
|
|---|
| 201 | }
|
|---|
| 202 | //******************************************************************************
|
|---|
| 203 | //******************************************************************************
|
|---|
| 204 | BOOL WIN32API SetMenuItemBitmaps( HMENU hMenu, UINT arg2, UINT arg3, HBITMAP arg4, HBITMAP arg5)
|
|---|
| 205 | {
|
|---|
| 206 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 207 |
|
|---|
| 208 | dprintf(("USER32: SetMenuItemBitmaps\n"));
|
|---|
| 209 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 210 | {
|
|---|
| 211 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 212 | return 0;
|
|---|
| 213 | }
|
|---|
| 214 | return O32_SetMenuItemBitmaps(menu->getOS2Handle(), arg2, arg3, arg4, arg5);
|
|---|
| 215 | }
|
|---|
| 216 | //******************************************************************************
|
|---|
| 217 | //******************************************************************************
|
|---|
| 218 | HMENU WIN32API GetSubMenu(HWND hMenu, int arg2)
|
|---|
| 219 | {
|
|---|
| 220 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 221 |
|
|---|
| 222 | dprintf(("USER32: GetSubMenu\n"));
|
|---|
| 223 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 224 | {
|
|---|
| 225 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 226 | return 0;
|
|---|
| 227 | }
|
|---|
| 228 | return O32_GetSubMenu(menu->getOS2Handle(), arg2);
|
|---|
| 229 | }
|
|---|
| 230 | //******************************************************************************
|
|---|
| 231 | //******************************************************************************
|
|---|
| 232 | HMENU WIN32API GetSystemMenu( HWND hMenu, BOOL arg2)
|
|---|
| 233 | {
|
|---|
| 234 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 235 |
|
|---|
| 236 | dprintf(("USER32: GetSystemMenu\n"));
|
|---|
| 237 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 238 | {
|
|---|
| 239 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 240 | return 0;
|
|---|
| 241 | }
|
|---|
| 242 | return O32_GetSystemMenu(menu->getOS2Handle(), arg2);
|
|---|
| 243 | }
|
|---|
| 244 | //******************************************************************************
|
|---|
| 245 | //******************************************************************************
|
|---|
| 246 | BOOL WIN32API IsMenu( HMENU hMenu)
|
|---|
| 247 | {
|
|---|
| 248 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 249 |
|
|---|
| 250 | dprintf(("USER32: IsMenu\n"));
|
|---|
| 251 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 252 | {
|
|---|
| 253 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 254 | return 0;
|
|---|
| 255 | }
|
|---|
| 256 | return O32_IsMenu(menu->getOS2Handle());
|
|---|
| 257 | }
|
|---|
| 258 | //******************************************************************************
|
|---|
| 259 | //******************************************************************************
|
|---|
| 260 | BOOL WIN32API TrackPopupMenu(HMENU hMenu, UINT arg2, int arg3, int arg4, int arg5, HWND arg6, const RECT * arg7)
|
|---|
| 261 | {
|
|---|
| 262 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 263 |
|
|---|
| 264 | dprintf(("USER32: TrackPopupMenu\n"));
|
|---|
| 265 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 266 | {
|
|---|
| 267 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 268 | return 0;
|
|---|
| 269 | }
|
|---|
| 270 | return O32_TrackPopupMenu(menu->getOS2Handle(), arg2, arg3, arg4, arg5, arg6, arg7);
|
|---|
| 271 | }
|
|---|
| 272 | //******************************************************************************
|
|---|
| 273 | //******************************************************************************
|
|---|
| 274 | BOOL WIN32API TrackPopupMenuEx(HMENU hMenu, UINT flags, int X, int Y, HWND hwnd, LPTPMPARAMS lpPM)
|
|---|
| 275 | {
|
|---|
| 276 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 277 | RECT *rect = NULL;
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 | dprintf(("USER32: TrackPopupMenuEx, not completely implemented\n"));
|
|---|
| 281 | if(lpPM->cbSize != 0)
|
|---|
| 282 | rect = &lpPM->rcExclude;
|
|---|
| 283 |
|
|---|
| 284 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 285 | {
|
|---|
| 286 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 287 | return 0;
|
|---|
| 288 | }
|
|---|
| 289 | return O32_TrackPopupMenu(menu->getOS2Handle(), flags, X, Y, 0, hwnd, rect);
|
|---|
| 290 | }
|
|---|
| 291 | //******************************************************************************
|
|---|
| 292 | //******************************************************************************
|
|---|
| 293 | BOOL WIN32API AppendMenuA(HMENU hMenu, UINT uFlags, UINT ulDNewItem, LPCSTR lpNewItem)
|
|---|
| 294 | {
|
|---|
| 295 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 296 | BOOL rc;
|
|---|
| 297 |
|
|---|
| 298 | dprintf(("USER32: OS2AppendMenuA uFlags = %X\n", uFlags));
|
|---|
| 299 |
|
|---|
| 300 | if(uFlags & MF_STRING || uFlags == 0)
|
|---|
| 301 | dprintf(("USER32: OS2AppendMenuA %s\n", lpNewItem));
|
|---|
| 302 |
|
|---|
| 303 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 304 | {
|
|---|
| 305 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 306 | return 0;
|
|---|
| 307 | }
|
|---|
| 308 | rc = O32_AppendMenu(menu->getOS2Handle(), uFlags, ulDNewItem, lpNewItem);
|
|---|
| 309 | dprintf(("USER32: OS2AppendMenuA returned %d\n", rc));
|
|---|
| 310 | return rc;
|
|---|
| 311 | }
|
|---|
| 312 | //******************************************************************************
|
|---|
| 313 | //******************************************************************************
|
|---|
| 314 | BOOL WIN32API AppendMenuW( HMENU hMenu, UINT arg2, UINT arg3, LPCWSTR arg4)
|
|---|
| 315 | {
|
|---|
| 316 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 317 | BOOL rc;
|
|---|
| 318 | char *astring = NULL;
|
|---|
| 319 |
|
|---|
| 320 | dprintf(("USER32: OS2AppendMenuW\n"));
|
|---|
| 321 |
|
|---|
| 322 | if(arg2 & MF_STRING && (int)arg4 >> 16 != 0)
|
|---|
| 323 | astring = UnicodeToAsciiString((LPWSTR)arg4);
|
|---|
| 324 | else
|
|---|
| 325 | astring = (char *) arg4;
|
|---|
| 326 |
|
|---|
| 327 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 328 | {
|
|---|
| 329 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 330 | return 0;
|
|---|
| 331 | }
|
|---|
| 332 | rc = O32_AppendMenu(menu->getOS2Handle(), arg2, arg3, astring);
|
|---|
| 333 | if(arg2 & MF_STRING && (int)arg4 >> 16 != 0)
|
|---|
| 334 | FreeAsciiString(astring);
|
|---|
| 335 | return(rc);
|
|---|
| 336 | }
|
|---|
| 337 | //******************************************************************************
|
|---|
| 338 | //******************************************************************************
|
|---|
| 339 | DWORD WIN32API CheckMenuItem( HMENU hMenu, UINT arg2, UINT arg3)
|
|---|
| 340 | {
|
|---|
| 341 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 342 |
|
|---|
| 343 | dprintf(("USER32: OS2CheckMenuItem\n"));
|
|---|
| 344 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 345 | {
|
|---|
| 346 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 347 | return 0;
|
|---|
| 348 | }
|
|---|
| 349 | return O32_CheckMenuItem(menu->getOS2Handle(), arg2, arg3);
|
|---|
| 350 | }
|
|---|
| 351 | //******************************************************************************
|
|---|
| 352 | //******************************************************************************
|
|---|
| 353 | HMENU WIN32API CreateMenu(void)
|
|---|
| 354 | {
|
|---|
| 355 | Win32MenuRes *menu = 0;
|
|---|
| 356 | HMENU hMenu;
|
|---|
| 357 |
|
|---|
| 358 | hMenu = O32_CreateMenu();
|
|---|
| 359 | if(hMenu) {
|
|---|
| 360 | menu = new Win32MenuRes(hMenu);
|
|---|
| 361 | if(menu == NULL) {
|
|---|
| 362 | return 0;
|
|---|
| 363 | }
|
|---|
| 364 | }
|
|---|
| 365 | dprintf(("USER32: OS2CreateMenu returned %d\n", hMenu));
|
|---|
| 366 | return (HMENU)menu;
|
|---|
| 367 | }
|
|---|
| 368 | //******************************************************************************
|
|---|
| 369 | //******************************************************************************
|
|---|
| 370 | HMENU WIN32API CreatePopupMenu(void)
|
|---|
| 371 | {
|
|---|
| 372 | Win32MenuRes *menu = 0;
|
|---|
| 373 | HMENU hMenu;
|
|---|
| 374 |
|
|---|
| 375 | dprintf(("USER32: OS2CreatePopupMenu\n"));
|
|---|
| 376 | hMenu = O32_CreatePopupMenu();
|
|---|
| 377 | if(hMenu) {
|
|---|
| 378 | menu = new Win32MenuRes(hMenu);
|
|---|
| 379 | if(menu == NULL) {
|
|---|
| 380 | return 0;
|
|---|
| 381 | }
|
|---|
| 382 | }
|
|---|
| 383 | return (HMENU)menu;
|
|---|
| 384 | }
|
|---|
| 385 | //******************************************************************************
|
|---|
| 386 | //******************************************************************************
|
|---|
| 387 | BOOL WIN32API EnableMenuItem( HMENU hMenu, UINT arg2, UINT arg3)
|
|---|
| 388 | {
|
|---|
| 389 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 390 |
|
|---|
| 391 | dprintf(("USER32: OS2EnableMenuItem\n"));
|
|---|
| 392 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 393 | {
|
|---|
| 394 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 395 | return 0;
|
|---|
| 396 | }
|
|---|
| 397 | return O32_EnableMenuItem(menu->getOS2Handle(), arg2, arg3);
|
|---|
| 398 | }
|
|---|
| 399 | //******************************************************************************
|
|---|
| 400 | //******************************************************************************
|
|---|
| 401 | BOOL WIN32API ModifyMenuA( HMENU hMenu, UINT arg2, UINT arg3, UINT arg4, LPCSTR arg5)
|
|---|
| 402 | {
|
|---|
| 403 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 404 |
|
|---|
| 405 | dprintf(("USER32: OS2ModifyMenuA\n"));
|
|---|
| 406 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 407 | {
|
|---|
| 408 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 409 | return 0;
|
|---|
| 410 | }
|
|---|
| 411 | return O32_ModifyMenu(menu->getOS2Handle(), arg2, arg3, arg4, arg5);
|
|---|
| 412 | }
|
|---|
| 413 | //******************************************************************************
|
|---|
| 414 | //******************************************************************************
|
|---|
| 415 | BOOL WIN32API ModifyMenuW( HMENU hMenu, UINT arg2, UINT arg3, UINT arg4, LPCWSTR arg5)
|
|---|
| 416 | {
|
|---|
| 417 | BOOL rc;
|
|---|
| 418 | char *astring = NULL;
|
|---|
| 419 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 420 |
|
|---|
| 421 | dprintf(("USER32: OS2ModifyMenuW %s\n", astring));
|
|---|
| 422 |
|
|---|
| 423 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 424 | {
|
|---|
| 425 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 426 | return 0;
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | if(arg3 & MF_STRING && (int)arg5 >> 16 != 0)
|
|---|
| 430 | astring = UnicodeToAsciiString((LPWSTR)arg5);
|
|---|
| 431 | else
|
|---|
| 432 | astring = (char *) arg5;
|
|---|
| 433 |
|
|---|
| 434 | rc = O32_ModifyMenu(menu->getOS2Handle(), arg2, arg3, arg4, astring);
|
|---|
| 435 | if(arg3 & MF_STRING && (int)arg5 >> 16 != 0)
|
|---|
| 436 | FreeAsciiString(astring);
|
|---|
| 437 | return(rc);
|
|---|
| 438 | }
|
|---|
| 439 | //******************************************************************************
|
|---|
| 440 | //******************************************************************************
|
|---|
| 441 | BOOL WIN32API RemoveMenu( HMENU hMenu, UINT arg2, UINT arg3)
|
|---|
| 442 | {
|
|---|
| 443 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 444 |
|
|---|
| 445 | dprintf(("USER32: OS2RemoveMenu\n"));
|
|---|
| 446 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 447 | {
|
|---|
| 448 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 449 | return 0;
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | return O32_RemoveMenu(menu->getOS2Handle(), arg2, arg3);
|
|---|
| 453 | }
|
|---|
| 454 | //******************************************************************************
|
|---|
| 455 | //******************************************************************************
|
|---|
| 456 | BOOL WIN32API DeleteMenu( HMENU hMenu, UINT arg2, UINT arg3)
|
|---|
| 457 | {
|
|---|
| 458 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 459 |
|
|---|
| 460 | dprintf(("USER32: OS2DeleteMenu\n"));
|
|---|
| 461 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 462 | {
|
|---|
| 463 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 464 | return 0;
|
|---|
| 465 | }
|
|---|
| 466 |
|
|---|
| 467 | return O32_DeleteMenu(menu->getOS2Handle(), arg2, arg3);
|
|---|
| 468 | }
|
|---|
| 469 | //******************************************************************************
|
|---|
| 470 | //******************************************************************************
|
|---|
| 471 | BOOL WIN32API HiliteMenuItem( HWND hMenu, HMENU arg2, UINT arg3, UINT arg4)
|
|---|
| 472 | {
|
|---|
| 473 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 474 |
|
|---|
| 475 | dprintf(("USER32: OS2HiliteMenuItem\n"));
|
|---|
| 476 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 477 | {
|
|---|
| 478 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 479 | return 0;
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | return O32_HiliteMenuItem(menu->getOS2Handle(), arg2, arg3, arg4);
|
|---|
| 483 | }
|
|---|
| 484 | //******************************************************************************
|
|---|
| 485 | //******************************************************************************
|
|---|
| 486 | BOOL WIN32API InsertMenuA( HMENU hMenu, UINT arg2, UINT arg3, UINT arg4, LPCSTR arg5)
|
|---|
| 487 | {
|
|---|
| 488 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 489 |
|
|---|
| 490 | dprintf(("USER32: OS2InsertMenuA\n"));
|
|---|
| 491 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 492 | {
|
|---|
| 493 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 494 | return 0;
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | return O32_InsertMenu(menu->getOS2Handle(), arg2, arg3, arg4, arg5);
|
|---|
| 498 | }
|
|---|
| 499 | //******************************************************************************
|
|---|
| 500 | //******************************************************************************
|
|---|
| 501 | BOOL WIN32API InsertMenuW(HMENU hMenu, UINT arg2, UINT arg3, UINT arg4, LPCWSTR arg5)
|
|---|
| 502 | {
|
|---|
| 503 | BOOL rc;
|
|---|
| 504 | char *astring = NULL;
|
|---|
| 505 | Win32MenuRes *menu = (Win32MenuRes *)hMenu;
|
|---|
| 506 |
|
|---|
| 507 | dprintf(("USER32: OS2InsertMenuW %s\n", astring));
|
|---|
| 508 | if(menu == NULL || menu->getOS2Handle() == 0)
|
|---|
| 509 | {
|
|---|
| 510 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 511 | return 0;
|
|---|
| 512 | }
|
|---|
| 513 | if(arg3 & MF_STRING && (int)arg5 >> 16 != 0)
|
|---|
| 514 | astring = UnicodeToAsciiString((LPWSTR)arg5);
|
|---|
| 515 | else
|
|---|
| 516 | astring = (char *) arg5;
|
|---|
| 517 |
|
|---|
| 518 | rc = O32_InsertMenu(menu->getOS2Handle(), arg2, arg3, arg4, astring);
|
|---|
| 519 | if(arg3 & MF_STRING && (int)arg5 >> 16 != 0)
|
|---|
| 520 | FreeAsciiString(astring);
|
|---|
| 521 | return(rc);
|
|---|
| 522 | }
|
|---|
| 523 | //******************************************************************************
|
|---|
| 524 | //******************************************************************************
|
|---|
| 525 | BOOL WIN32API SetMenuContextHelpId(HMENU hmenu, DWORD dwContextHelpId)
|
|---|
| 526 | {
|
|---|
| 527 | dprintf(("USER32: OS2SetMenuContextHelpId, not implemented\n"));
|
|---|
| 528 | return(TRUE);
|
|---|
| 529 | }
|
|---|
| 530 | //******************************************************************************
|
|---|
| 531 | //******************************************************************************
|
|---|
| 532 | DWORD WIN32API GetMenuContextHelpId(HMENU hmenu)
|
|---|
| 533 | {
|
|---|
| 534 | dprintf(("USER32: OS2GetMenuContextHelpId, not implemented\n"));
|
|---|
| 535 | return(0);
|
|---|
| 536 | }
|
|---|
| 537 | //******************************************************************************
|
|---|
| 538 | //******************************************************************************
|
|---|
| 539 | BOOL WIN32API CheckMenuRadioItem(HMENU hmenu, UINT idFirst, UINT idLast,
|
|---|
| 540 | UINT idCheck, UINT uFlags)
|
|---|
| 541 | {
|
|---|
| 542 | dprintf(("USER32: OS2CheckMenuRadioItem, not implemented\n"));
|
|---|
| 543 | return(TRUE);
|
|---|
| 544 | }
|
|---|
| 545 | //******************************************************************************
|
|---|
| 546 | //******************************************************************************
|
|---|
| 547 | BOOL WIN32API ChangeMenuA(HMENU hMenu, UINT pos, LPCSTR data, UINT id, UINT flags)
|
|---|
| 548 | {
|
|---|
| 549 | dprintf(("USER32: ChangeMenuA flags %X\n", flags));
|
|---|
| 550 |
|
|---|
| 551 | if (flags & MF_APPEND) return AppendMenuA(hMenu, flags & ~MF_APPEND,
|
|---|
| 552 | id, data );
|
|---|
| 553 | if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE);
|
|---|
| 554 | if (flags & MF_CHANGE) return ModifyMenuA(hMenu, pos, flags & ~MF_CHANGE,
|
|---|
| 555 | id, data );
|
|---|
| 556 | if (flags & MF_REMOVE) return RemoveMenu(hMenu,
|
|---|
| 557 | flags & MF_BYPOSITION ? pos : id,
|
|---|
| 558 | flags & ~MF_REMOVE );
|
|---|
| 559 | /* Default: MF_INSERT */
|
|---|
| 560 | return InsertMenuA( hMenu, pos, flags, id, data );
|
|---|
| 561 | }
|
|---|
| 562 | //******************************************************************************
|
|---|
| 563 | //******************************************************************************
|
|---|
| 564 | BOOL WIN32API ChangeMenuW(HMENU hMenu, UINT pos, LPCWSTR data,
|
|---|
| 565 | UINT id, UINT flags )
|
|---|
| 566 | {
|
|---|
| 567 | dprintf(("USER32: ChangeMenuW flags %X\n", flags));
|
|---|
| 568 |
|
|---|
| 569 | if (flags & MF_APPEND) return AppendMenuW(hMenu, flags & ~MF_APPEND,
|
|---|
| 570 | id, data );
|
|---|
| 571 | if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE);
|
|---|
| 572 | if (flags & MF_CHANGE) return ModifyMenuW(hMenu, pos, flags & ~MF_CHANGE,
|
|---|
| 573 | id, data );
|
|---|
| 574 | if (flags & MF_REMOVE) return RemoveMenu(hMenu,
|
|---|
| 575 | flags & MF_BYPOSITION ? pos : id,
|
|---|
| 576 | flags & ~MF_REMOVE );
|
|---|
| 577 | /* Default: MF_INSERT */
|
|---|
| 578 | return InsertMenuW(hMenu, pos, flags, id, data);
|
|---|
| 579 | }
|
|---|
| 580 | //******************************************************************************
|
|---|
| 581 | //******************************************************************************
|
|---|
| 582 | BOOL WIN32API SetMenuItemInfoA(HMENU hmenu, UINT par1, BOOL par2,
|
|---|
| 583 | const MENUITEMINFOA * lpMenuItemInfo)
|
|---|
| 584 | {
|
|---|
| 585 | dprintf(("USER32: SetMenuItemInfoA, faked\n"));
|
|---|
| 586 | return(TRUE);
|
|---|
| 587 | }
|
|---|
| 588 | /*****************************************************************************
|
|---|
| 589 | * Name : BOOL WIN32API SetMenuItemInfoW
|
|---|
| 590 | * Purpose : The SetMenuItemInfo function changes information about a menu item.
|
|---|
| 591 | * Parameters:
|
|---|
| 592 | * Variables :
|
|---|
| 593 | * Result : If the function succeeds, the return value is TRUE.
|
|---|
| 594 | * If the function fails, the return value is FALSE. To get extended
|
|---|
| 595 | * error information, use the GetLastError function.
|
|---|
| 596 | * Remark :
|
|---|
| 597 | * Status : UNTESTED STUB
|
|---|
| 598 | *
|
|---|
| 599 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 600 | *****************************************************************************/
|
|---|
| 601 |
|
|---|
| 602 | BOOL WIN32API SetMenuItemInfoW(HMENU hMenu,
|
|---|
| 603 | UINT uItem,
|
|---|
| 604 | BOOL fByPosition,
|
|---|
| 605 | const MENUITEMINFOW *lpmmi)
|
|---|
| 606 | {
|
|---|
| 607 | dprintf(("USER32:SetMenuItemInfoW (%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
|---|
| 608 | hMenu,
|
|---|
| 609 | uItem,
|
|---|
| 610 | fByPosition,
|
|---|
| 611 | lpmmi));
|
|---|
| 612 |
|
|---|
| 613 | return (SetMenuItemInfoA(hMenu,
|
|---|
| 614 | uItem,
|
|---|
| 615 | fByPosition,
|
|---|
| 616 | (const MENUITEMINFOA *)lpmmi));
|
|---|
| 617 | }
|
|---|
| 618 | //******************************************************************************
|
|---|
| 619 | //******************************************************************************
|
|---|
| 620 | BOOL WIN32API SetMenuDefaultItem(HMENU hmenu, UINT uItem, UINT fByPos )
|
|---|
| 621 | {
|
|---|
| 622 | dprintf(("USER32: SetMenuDefaultItem, faked\n"));
|
|---|
| 623 | return(TRUE);
|
|---|
| 624 | }
|
|---|
| 625 | //******************************************************************************
|
|---|
| 626 | //******************************************************************************
|
|---|
| 627 | BOOL WIN32API GetMenuItemInfoA(HMENU hmenu, UINT uItem, BOOL aBool,
|
|---|
| 628 | MENUITEMINFOA *lpMenuItemInfo )
|
|---|
| 629 |
|
|---|
| 630 | {
|
|---|
| 631 | dprintf(("USER32: GetMenuItemInfoA, faked\n"));
|
|---|
| 632 | return(TRUE);
|
|---|
| 633 | }
|
|---|
| 634 | /*****************************************************************************
|
|---|
| 635 | * Name : UINT WIN32API GetMenuDefaultItem
|
|---|
| 636 | * Purpose : The GetMenuDefaultItem function determines the default menu item
|
|---|
| 637 | * on the specified menu.
|
|---|
| 638 | * Parameters:
|
|---|
| 639 | * Variables :
|
|---|
| 640 | * Result : If the function succeeds, the return value is the identifier or
|
|---|
| 641 | * position of the menu item.
|
|---|
| 642 | * If the function fails, the return value is - 1.
|
|---|
| 643 | * Remark :
|
|---|
| 644 | * Status : UNTESTED STUB
|
|---|
| 645 | *
|
|---|
| 646 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 647 | *****************************************************************************/
|
|---|
| 648 |
|
|---|
| 649 | UINT WIN32API GetMenuDefaultItem(HMENU hMenu,
|
|---|
| 650 | UINT fByPos,
|
|---|
| 651 | UINT gmdiFlags)
|
|---|
| 652 | {
|
|---|
| 653 | dprintf(("USER32:GetMenuDefaultItem (%08xh,%u,%08x) not implemented.\n",
|
|---|
| 654 | hMenu,
|
|---|
| 655 | fByPos,
|
|---|
| 656 | gmdiFlags));
|
|---|
| 657 |
|
|---|
| 658 | return (-1);
|
|---|
| 659 | }
|
|---|
| 660 |
|
|---|
| 661 |
|
|---|
| 662 | /*****************************************************************************
|
|---|
| 663 | * Name : BOOL WIN32API GetMenuItemInfoW
|
|---|
| 664 | * Purpose : The GetMenuItemInfo function retrieves information about a menu item.
|
|---|
| 665 | * Parameters:
|
|---|
| 666 | * Variables :
|
|---|
| 667 | * Result : If the function succeeds, the return value is TRUE.
|
|---|
| 668 | * If the function fails, the return value is FALSE. To get extended
|
|---|
| 669 | * error information, use the GetLastError function.
|
|---|
| 670 | * Remark :
|
|---|
| 671 | * Status : UNTESTED STUB
|
|---|
| 672 | *
|
|---|
| 673 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 674 | *****************************************************************************/
|
|---|
| 675 |
|
|---|
| 676 | BOOL WIN32API GetMenuItemInfoW(HMENU hMenu,
|
|---|
| 677 | UINT uItem,
|
|---|
| 678 | BOOL fByPosition,
|
|---|
| 679 | MENUITEMINFOW * lpmii)
|
|---|
| 680 | {
|
|---|
| 681 | dprintf(("USER32:GetMenuItemInfoW (%08xh,%08xh,%u,%08x) not implemented.\n",
|
|---|
| 682 | hMenu,
|
|---|
| 683 | uItem,
|
|---|
| 684 | fByPosition,
|
|---|
| 685 | lpmii));
|
|---|
| 686 |
|
|---|
| 687 | return(GetMenuItemInfoA(hMenu,
|
|---|
| 688 | uItem,
|
|---|
| 689 | fByPosition,
|
|---|
| 690 | (MENUITEMINFOA *)lpmii));
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 |
|
|---|
| 694 | /*****************************************************************************
|
|---|
| 695 | * Name : BOOL WIN32API GetMenuItemRect
|
|---|
| 696 | * Purpose : The GetMenuItemRect function retrieves the bounding rectangle
|
|---|
| 697 | * for the specified menu item.
|
|---|
| 698 | * Parameters:
|
|---|
| 699 | * Variables :
|
|---|
| 700 | * Result : If the function succeeds, the return value is TRUE.
|
|---|
| 701 | * If the function fails, the return value is FALSE. To get
|
|---|
| 702 | * extended error information, use the GetLastError function.
|
|---|
| 703 | * Remark :
|
|---|
| 704 | * Status : UNTESTED STUB
|
|---|
| 705 | *
|
|---|
| 706 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 707 | *****************************************************************************/
|
|---|
| 708 |
|
|---|
| 709 | BOOL WIN32API GetMenuItemRect(HWND hWnd,
|
|---|
| 710 | HMENU hMenu,
|
|---|
| 711 | UINT uItem,
|
|---|
| 712 | LPRECT lprcItem)
|
|---|
| 713 | {
|
|---|
| 714 | dprintf(("USER32:GetMenuItemRect (%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
|---|
| 715 | hWnd,
|
|---|
| 716 | hMenu,
|
|---|
| 717 | uItem,
|
|---|
| 718 | lprcItem));
|
|---|
| 719 |
|
|---|
| 720 | return (FALSE);
|
|---|
| 721 | }
|
|---|
| 722 | /*****************************************************************************
|
|---|
| 723 | * Name : BOOL WIN32API InsertMenuItemA
|
|---|
| 724 | * Purpose : The InsertMenuItem function inserts a new menu item at the specified
|
|---|
| 725 | * position in a menu bar or pop-up menu.
|
|---|
| 726 | * Parameters:
|
|---|
| 727 | * Variables :
|
|---|
| 728 | * Result : If the function succeeds, the return value is TRUE.
|
|---|
| 729 | * If the function fails, the return value is FALSE. To get extended
|
|---|
| 730 | * error information, use the GetLastError function.
|
|---|
| 731 | * Remark :
|
|---|
| 732 | * Status : UNTESTED STUB
|
|---|
| 733 | *
|
|---|
| 734 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 735 | *****************************************************************************/
|
|---|
| 736 |
|
|---|
| 737 | BOOL WIN32API InsertMenuItemA(HMENU hMenu,
|
|---|
| 738 | UINT uItem,
|
|---|
| 739 | BOOL fByPosition,
|
|---|
| 740 | const MENUITEMINFOA* lpmii)
|
|---|
| 741 | {
|
|---|
| 742 | dprintf(("USER32:InsertMenuItemA (%08xh,%08xh,%u,%08x) not implemented.\n",
|
|---|
| 743 | hMenu,
|
|---|
| 744 | uItem,
|
|---|
| 745 | fByPosition,
|
|---|
| 746 | lpmii));
|
|---|
| 747 |
|
|---|
| 748 | return (FALSE);
|
|---|
| 749 | }
|
|---|
| 750 |
|
|---|
| 751 |
|
|---|
| 752 | /*****************************************************************************
|
|---|
| 753 | * Name : BOOL WIN32API InsertMenuItemW
|
|---|
| 754 | * Purpose : The InsertMenuItem function inserts a new menu item at the specified
|
|---|
| 755 | * position in a menu bar or pop-up menu.
|
|---|
| 756 | * Parameters:
|
|---|
| 757 | * Variables :
|
|---|
| 758 | * Result : If the function succeeds, the return value is TRUE.
|
|---|
| 759 | * If the function fails, the return value is FALSE. To get extended
|
|---|
| 760 | * error information, use the GetLastError function.
|
|---|
| 761 | * Remark :
|
|---|
| 762 | * Status : UNTESTED STUB
|
|---|
| 763 | *
|
|---|
| 764 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 765 | *****************************************************************************/
|
|---|
| 766 |
|
|---|
| 767 | BOOL WIN32API InsertMenuItemW(HMENU hMenu,
|
|---|
| 768 | UINT uItem,
|
|---|
| 769 | BOOL fByPosition,
|
|---|
| 770 | const MENUITEMINFOW * lpmii)
|
|---|
| 771 | {
|
|---|
| 772 | dprintf(("USER32:InsertMenuItemW (%08xh,%08xh,%u,%08x) not implemented.\n",
|
|---|
| 773 | hMenu,
|
|---|
| 774 | uItem,
|
|---|
| 775 | fByPosition,
|
|---|
| 776 | lpmii));
|
|---|
| 777 |
|
|---|
| 778 | return (FALSE);
|
|---|
| 779 | }
|
|---|
| 780 | /*****************************************************************************
|
|---|
| 781 | * Name : UINT WIN32API MenuItemFromPoint
|
|---|
| 782 | * Purpose : The MenuItemFromPoint function determines which menu item, if
|
|---|
| 783 | * any, is at the specified location.
|
|---|
| 784 | * Parameters:
|
|---|
| 785 | * Variables :
|
|---|
| 786 | * Result : Returns the zero-based position of the menu item at the specified
|
|---|
| 787 | * location or -1 if no menu item is at the specified location.
|
|---|
| 788 | * Remark :
|
|---|
| 789 | * Status : UNTESTED STUB
|
|---|
| 790 | *
|
|---|
| 791 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 792 | *****************************************************************************/
|
|---|
| 793 |
|
|---|
| 794 | UINT WIN32API MenuItemFromPoint(HWND hWnd,
|
|---|
| 795 | HMENU hMenu,
|
|---|
| 796 | POINT ptScreen)
|
|---|
| 797 | {
|
|---|
| 798 | dprintf(("USER32:MenuItemFromPoint (%08xh,%08xh,%u) not implemented.\n",
|
|---|
| 799 | hWnd,
|
|---|
| 800 | hMenu,
|
|---|
| 801 | ptScreen));
|
|---|
| 802 |
|
|---|
| 803 | return (-1);
|
|---|
| 804 | }
|
|---|