source: trunk/src/user32/winmenu.cpp@ 1446

Last change on this file since 1446 was 1446, checked in by sandervl, 26 years ago

menu changes + misc bugfixes

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