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