1 | /* $Id: menu.cpp,v 1.15 2000-02-03 17:13:00 cbratschi Exp $*/
|
---|
2 | /*
|
---|
3 | * Menu functions
|
---|
4 | *
|
---|
5 | * Copyright 1993 Martin Ayotte
|
---|
6 | * Copyright 1994 Alexandre Julliard
|
---|
7 | * Copyright 1997 Morten Welinder
|
---|
8 | *
|
---|
9 | * Copyright 1999 Christoph Bratschi
|
---|
10 | *
|
---|
11 | * WINE version: 20000130
|
---|
12 | *
|
---|
13 | * Status: ???
|
---|
14 | * Version: ???
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * Note: the style MF_MOUSESELECT is used to mark popup items that
|
---|
19 | * have been selected, i.e. their popup menu is currently displayed.
|
---|
20 | * This is probably not the meaning this style has in MS-Windows.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #include <assert.h>
|
---|
24 | #include <ctype.h>
|
---|
25 | #include <stdlib.h>
|
---|
26 | #include <string.h>
|
---|
27 | #include <os2win.h>
|
---|
28 | #include <heapstring.h>
|
---|
29 | #include "controls.h"
|
---|
30 | #include "menu.h"
|
---|
31 |
|
---|
32 | //DEFAULT_DEBUG_CHANNEL(menu)
|
---|
33 |
|
---|
34 |
|
---|
35 | /* internal popup menu window messages */
|
---|
36 |
|
---|
37 | #define MM_SETMENUHANDLE (WM_USER + 0)
|
---|
38 | #define MM_GETMENUHANDLE (WM_USER + 1)
|
---|
39 |
|
---|
40 | /* Menu item structure */
|
---|
41 | typedef struct {
|
---|
42 | /* ----------- MENUITEMINFO Stuff ----------- */
|
---|
43 | UINT fType; /* Item type. */
|
---|
44 | UINT fState; /* Item state. */
|
---|
45 | UINT wID; /* Item id. */
|
---|
46 | HMENU hSubMenu; /* Pop-up menu. */
|
---|
47 | HBITMAP hCheckBit; /* Bitmap when checked. */
|
---|
48 | HBITMAP hUnCheckBit; /* Bitmap when unchecked. */
|
---|
49 | LPSTR text; /* Item text or bitmap handle. */
|
---|
50 | DWORD dwItemData; /* Application defined. */
|
---|
51 | DWORD dwTypeData; /* depends on fMask */
|
---|
52 | HBITMAP hbmpItem; /* bitmap in win98 style menus */
|
---|
53 | /* ----------- Wine stuff ----------- */
|
---|
54 | RECT rect; /* Item area (relative to menu window) */
|
---|
55 | UINT xTab; /* X position of text after Tab */
|
---|
56 | } MENUITEM;
|
---|
57 |
|
---|
58 | /* Popup menu structure */
|
---|
59 | typedef struct {
|
---|
60 | WORD wFlags; /* Menu flags (MF_POPUP, MF_SYSMENU) */
|
---|
61 | WORD wMagic; /* Magic number */
|
---|
62 | HQUEUE hTaskQ; /* Task queue for this menu */
|
---|
63 | WORD Width; /* Width of the whole menu */
|
---|
64 | WORD Height; /* Height of the whole menu */
|
---|
65 | WORD nItems; /* Number of items in the menu */
|
---|
66 | HWND hWnd; /* Window containing the menu */
|
---|
67 | MENUITEM *items; /* Array of menu items */
|
---|
68 | UINT FocusedItem; /* Currently focused item */
|
---|
69 | HWND hwndOwner; /* window receiving the messages for ownerdraw */
|
---|
70 | BOOL bTimeToHide; /* Request hiding when receiving a second click in the top-level menu item */
|
---|
71 | /* ------------ MENUINFO members ------ */
|
---|
72 | DWORD dwStyle; /* Extended mennu style */
|
---|
73 | UINT cyMax; /* max hight of the whole menu, 0 is screen hight */
|
---|
74 | HBRUSH hbrBack; /* brush for menu background */
|
---|
75 | DWORD dwContextHelpID;
|
---|
76 | DWORD dwMenuData; /* application defined value */
|
---|
77 | HMENU hSysMenuOwner; /* Handle to the dummy sys menu holder */
|
---|
78 | } POPUPMENU, *LPPOPUPMENU;
|
---|
79 |
|
---|
80 | /* internal flags for menu tracking */
|
---|
81 |
|
---|
82 | #define TF_ENDMENU 0x0001
|
---|
83 | #define TF_SUSPENDPOPUP 0x0002
|
---|
84 | #define TF_SKIPREMOVE 0x0004
|
---|
85 |
|
---|
86 | typedef struct
|
---|
87 | {
|
---|
88 | UINT trackFlags;
|
---|
89 | HMENU hCurrentMenu; /* current submenu (can be equal to hTopMenu)*/
|
---|
90 | HMENU hTopMenu; /* initial menu */
|
---|
91 | HWND hOwnerWnd; /* where notifications are sent */
|
---|
92 | POINT pt;
|
---|
93 | } MTRACKER;
|
---|
94 |
|
---|
95 | #define MENU_MAGIC 0x554d /* 'MU' */
|
---|
96 | #define IS_A_MENU(pmenu) ((pmenu) && (pmenu)->wMagic == MENU_MAGIC)
|
---|
97 |
|
---|
98 | #define ITEM_PREV -1
|
---|
99 | #define ITEM_NEXT 1
|
---|
100 |
|
---|
101 | /* Internal MENU_TrackMenu() flags */
|
---|
102 | #define TPM_INTERNAL 0xF0000000
|
---|
103 | #define TPM_ENTERIDLEEX 0x80000000 /* set owner window for WM_ENTERIDLE */
|
---|
104 | #define TPM_BUTTONDOWN 0x40000000 /* menu was clicked before tracking */
|
---|
105 | #define TPM_POPUPMENU 0x20000000 /* menu is a popup menu */
|
---|
106 | #define TPM_CAPTIONSYSMENU 0x10000000
|
---|
107 |
|
---|
108 | /* popup menu shade thickness */
|
---|
109 | #define POPUP_XSHADE 4
|
---|
110 | #define POPUP_YSHADE 4
|
---|
111 |
|
---|
112 | /* Space between 2 menu bar items */
|
---|
113 | #define MENU_BAR_ITEMS_SPACE 12
|
---|
114 |
|
---|
115 | /* Minimum width of a tab character */
|
---|
116 | #define MENU_TAB_SPACE 8
|
---|
117 |
|
---|
118 | /* Height of a separator item */
|
---|
119 | #define SEPARATOR_HEIGHT 5
|
---|
120 |
|
---|
121 | /* (other menu->FocusedItem values give the position of the focused item) */
|
---|
122 | #define NO_SELECTED_ITEM 0xffff
|
---|
123 |
|
---|
124 | #define MENU_ITEM_TYPE(flags) \
|
---|
125 | ((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR))
|
---|
126 |
|
---|
127 | #define IS_STRING_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_STRING)
|
---|
128 | #define IS_BITMAP_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_BITMAP)
|
---|
129 |
|
---|
130 | #define IS_SYSTEM_MENU(menu) \
|
---|
131 | (!((menu)->wFlags & MF_POPUP) && (menu)->wFlags & MF_SYSMENU)
|
---|
132 |
|
---|
133 | #define IS_SYSTEM_POPUP(menu) \
|
---|
134 | ((menu)->wFlags & MF_POPUP && (menu)->wFlags & MF_SYSMENU)
|
---|
135 |
|
---|
136 | #define TYPE_MASK (MFT_STRING | MFT_BITMAP | MFT_OWNERDRAW | MFT_SEPARATOR | \
|
---|
137 | MFT_MENUBARBREAK | MFT_MENUBREAK | MFT_RADIOCHECK | \
|
---|
138 | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY | \
|
---|
139 | MF_POPUP | MF_SYSMENU | MF_HELP)
|
---|
140 | #define STATE_MASK (~TYPE_MASK)
|
---|
141 |
|
---|
142 | /* Dimension of the menu bitmaps */
|
---|
143 | static WORD check_bitmap_width = 0, check_bitmap_height = 0;
|
---|
144 | static WORD arrow_bitmap_width = 0, arrow_bitmap_height = 0;
|
---|
145 |
|
---|
146 | static HBITMAP hStdRadioCheck = 0;
|
---|
147 | static HBITMAP hStdCheck = 0;
|
---|
148 | static HBITMAP hStdMnArrow = 0;
|
---|
149 |
|
---|
150 | /* Minimze/restore/close buttons to be inserted in menubar */
|
---|
151 | static HBITMAP hBmpMinimize = 0;
|
---|
152 | static HBITMAP hBmpMinimizeD = 0;
|
---|
153 | static HBITMAP hBmpMaximize = 0;
|
---|
154 | static HBITMAP hBmpMaximizeD = 0;
|
---|
155 | static HBITMAP hBmpClose = 0;
|
---|
156 | static HBITMAP hBmpCloseD = 0;
|
---|
157 |
|
---|
158 |
|
---|
159 | static HBRUSH hShadeBrush = 0;
|
---|
160 | static HFONT hMenuFont = 0;
|
---|
161 | static HFONT hMenuFontBold = 0;
|
---|
162 |
|
---|
163 | static HMENU MENU_DefSysPopup = 0; /* Default system menu popup */
|
---|
164 |
|
---|
165 | /* Use global popup window because there's no way 2 menus can
|
---|
166 | * be tracked at the same time. */
|
---|
167 |
|
---|
168 | static HWND pTopPopupWnd = 0;
|
---|
169 | static UINT uSubPWndLevel = 0;
|
---|
170 |
|
---|
171 | /* Flag set by EndMenu() to force an exit from menu tracking */
|
---|
172 | static BOOL fEndMenu = FALSE;
|
---|
173 |
|
---|
174 |
|
---|
175 | /***********************************************************************
|
---|
176 | * debug_print_menuitem
|
---|
177 | *
|
---|
178 | * Print a menuitem in readable form.
|
---|
179 | */
|
---|
180 |
|
---|
181 | #define debug_print_menuitem(pre, mp, post) \
|
---|
182 | if(!TRACE_ON(menu)) ; else do_debug_print_menuitem(pre, mp, post)
|
---|
183 |
|
---|
184 | #define MENUOUT(text) \
|
---|
185 | DPRINTF("%s%s", (count++ ? "," : ""), (text))
|
---|
186 |
|
---|
187 | #define MENUFLAG(bit,text) \
|
---|
188 | do { \
|
---|
189 | if (flags & (bit)) { flags &= ~(bit); MENUOUT ((text)); } \
|
---|
190 | } while (0)
|
---|
191 |
|
---|
192 | #if 0
|
---|
193 | static void do_debug_print_menuitem(const char *prefix, MENUITEM * mp,
|
---|
194 | const char *postfix)
|
---|
195 | {
|
---|
196 | TRACE("%s ", prefix);
|
---|
197 | if (mp) {
|
---|
198 | UINT flags = mp->fType;
|
---|
199 | int typ = MENU_ITEM_TYPE(flags);
|
---|
200 | DPRINTF( "{ ID=0x%x", mp->wID);
|
---|
201 | if (flags & MF_POPUP)
|
---|
202 | DPRINTF( ", Sub=0x%x", mp->hSubMenu);
|
---|
203 | if (flags) {
|
---|
204 | int count = 0;
|
---|
205 | DPRINTF( ", Typ=");
|
---|
206 | if (typ == MFT_STRING)
|
---|
207 | /* Nothing */ ;
|
---|
208 | else if (typ == MFT_SEPARATOR)
|
---|
209 | MENUOUT("sep");
|
---|
210 | else if (typ == MFT_OWNERDRAW)
|
---|
211 | MENUOUT("own");
|
---|
212 | else if (typ == MFT_BITMAP)
|
---|
213 | MENUOUT("bit");
|
---|
214 | else
|
---|
215 | MENUOUT("???");
|
---|
216 | flags -= typ;
|
---|
217 |
|
---|
218 | MENUFLAG(MF_POPUP, "pop");
|
---|
219 | MENUFLAG(MFT_MENUBARBREAK, "barbrk");
|
---|
220 | MENUFLAG(MFT_MENUBREAK, "brk");
|
---|
221 | MENUFLAG(MFT_RADIOCHECK, "radio");
|
---|
222 | MENUFLAG(MFT_RIGHTORDER, "rorder");
|
---|
223 | MENUFLAG(MF_SYSMENU, "sys");
|
---|
224 | MENUFLAG(MFT_RIGHTJUSTIFY, "right"); /* same as MF_HELP */
|
---|
225 |
|
---|
226 | if (flags)
|
---|
227 | DPRINTF( "+0x%x", flags);
|
---|
228 | }
|
---|
229 | flags = mp->fState;
|
---|
230 | if (flags) {
|
---|
231 | int count = 0;
|
---|
232 | DPRINTF( ", State=");
|
---|
233 | MENUFLAG(MFS_GRAYED, "grey");
|
---|
234 | MENUFLAG(MFS_DEFAULT, "default");
|
---|
235 | MENUFLAG(MFS_DISABLED, "dis");
|
---|
236 | MENUFLAG(MFS_CHECKED, "check");
|
---|
237 | MENUFLAG(MFS_HILITE, "hi");
|
---|
238 | MENUFLAG(MF_USECHECKBITMAPS, "usebit");
|
---|
239 | MENUFLAG(MF_MOUSESELECT, "mouse");
|
---|
240 | if (flags)
|
---|
241 | DPRINTF( "+0x%x", flags);
|
---|
242 | }
|
---|
243 | if (mp->hCheckBit)
|
---|
244 | DPRINTF( ", Chk=0x%x", mp->hCheckBit);
|
---|
245 | if (mp->hUnCheckBit)
|
---|
246 | DPRINTF( ", Unc=0x%x", mp->hUnCheckBit);
|
---|
247 |
|
---|
248 | if (typ == MFT_STRING) {
|
---|
249 | if (mp->text)
|
---|
250 | DPRINTF( ", Text=\"%s\"", mp->text);
|
---|
251 | else
|
---|
252 | DPRINTF( ", Text=Null");
|
---|
253 | } else if (mp->text == NULL)
|
---|
254 | /* Nothing */ ;
|
---|
255 | else
|
---|
256 | DPRINTF( ", Text=%p", mp->text);
|
---|
257 | if (mp->dwItemData)
|
---|
258 | DPRINTF( ", ItemData=0x%08lx", mp->dwItemData);
|
---|
259 | DPRINTF( " }");
|
---|
260 | } else {
|
---|
261 | DPRINTF( "NULL");
|
---|
262 | }
|
---|
263 |
|
---|
264 | DPRINTF(" %s\n", postfix);
|
---|
265 | }
|
---|
266 | #endif
|
---|
267 |
|
---|
268 | #undef MENUOUT
|
---|
269 | #undef MENUFLAG
|
---|
270 |
|
---|
271 | //#define USER_HEAP_ALLOC(size) HeapAlloc(GetProcessHeap(),0,size)
|
---|
272 | //#define USER_HEAP_FREE(handle) HeapFree(GetProcessHeap(),0,(LPVOID)handle)
|
---|
273 |
|
---|
274 | HMENU getMenu(HWND hwnd)
|
---|
275 | {
|
---|
276 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
277 |
|
---|
278 | return win32wnd ? win32wnd->GetMenu():(HMENU)0;
|
---|
279 | }
|
---|
280 |
|
---|
281 | VOID setMenu(HWND hwnd,HMENU hMenu)
|
---|
282 | {
|
---|
283 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
284 |
|
---|
285 | if (win32wnd) win32wnd->SetMenu(hMenu);
|
---|
286 | }
|
---|
287 |
|
---|
288 | HMENU getSysMenu(HWND hwnd)
|
---|
289 | {
|
---|
290 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
291 |
|
---|
292 | return win32wnd ? win32wnd->GetSysMenu():(HMENU)0;
|
---|
293 | }
|
---|
294 |
|
---|
295 | VOID setSysMenu(HWND hwnd,HMENU hMenu)
|
---|
296 | {
|
---|
297 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
298 |
|
---|
299 | win32wnd->SetSysMenu(hMenu);
|
---|
300 | }
|
---|
301 |
|
---|
302 | /***********************************************************************
|
---|
303 | * MENU_GetMenu
|
---|
304 | *
|
---|
305 | * Validate the given menu handle and returns the menu structure pointer.
|
---|
306 | */
|
---|
307 | POPUPMENU *MENU_GetMenu(HMENU hMenu)
|
---|
308 | {
|
---|
309 | POPUPMENU *menu;
|
---|
310 | menu = (POPUPMENU*)hMenu;
|
---|
311 | if (!IS_A_MENU(menu))
|
---|
312 | {
|
---|
313 | //ERR("invalid menu handle=%x, ptr=%p, magic=%x\n", hMenu, menu, menu? menu->wMagic:0);
|
---|
314 | menu = NULL;
|
---|
315 | }
|
---|
316 | return menu;
|
---|
317 | }
|
---|
318 |
|
---|
319 | /***********************************************************************
|
---|
320 | * MENU_CopySysPopup
|
---|
321 | *
|
---|
322 | * Return the default system menu.
|
---|
323 | */
|
---|
324 | static HMENU MENU_CopySysPopup(void)
|
---|
325 | {
|
---|
326 | HMENU hMenu = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU");
|
---|
327 |
|
---|
328 | if( hMenu ) {
|
---|
329 | POPUPMENU* menu = (POPUPMENU*)hMenu;
|
---|
330 | menu->wFlags |= MF_SYSMENU | MF_POPUP;
|
---|
331 | SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE);
|
---|
332 | }
|
---|
333 | else {
|
---|
334 | hMenu = 0;
|
---|
335 | //ERR("Unable to load default system menu\n" );
|
---|
336 | }
|
---|
337 |
|
---|
338 | //TRACE("returning %x.\n", hMenu );
|
---|
339 |
|
---|
340 | return hMenu;
|
---|
341 | }
|
---|
342 |
|
---|
343 | /***********************************************************************
|
---|
344 | * MENU_GetTopPopupWnd()
|
---|
345 | *
|
---|
346 | * Return the locked pointer pTopPopupWnd.
|
---|
347 | */
|
---|
348 | static HWND MENU_GetTopPopupWnd()
|
---|
349 | {
|
---|
350 | return pTopPopupWnd;
|
---|
351 | }
|
---|
352 | /***********************************************************************
|
---|
353 | * MENU_ReleaseTopPopupWnd()
|
---|
354 | *
|
---|
355 | * Realease the locked pointer pTopPopupWnd.
|
---|
356 | */
|
---|
357 | static void MENU_ReleaseTopPopupWnd()
|
---|
358 | {
|
---|
359 | }
|
---|
360 | /***********************************************************************
|
---|
361 | * MENU_DestroyTopPopupWnd()
|
---|
362 | *
|
---|
363 | * Destroy the locked pointer pTopPopupWnd.
|
---|
364 | */
|
---|
365 | static void MENU_DestroyTopPopupWnd()
|
---|
366 | {
|
---|
367 | pTopPopupWnd = NULL;
|
---|
368 | }
|
---|
369 |
|
---|
370 |
|
---|
371 |
|
---|
372 | /**********************************************************************
|
---|
373 | * MENU_GetSysMenu
|
---|
374 | *
|
---|
375 | * Create a copy of the system menu. System menu in Windows is
|
---|
376 | * a special menu-bar with the single entry - system menu popup.
|
---|
377 | * This popup is presented to the outside world as a "system menu".
|
---|
378 | * However, the real system menu handle is sometimes seen in the
|
---|
379 | * WM_MENUSELECT paramemters (and Word 6 likes it this way).
|
---|
380 | */
|
---|
381 | HMENU MENU_GetSysMenu( HWND hWnd, HMENU hPopupMenu )
|
---|
382 | {
|
---|
383 | HMENU hMenu;
|
---|
384 |
|
---|
385 | hMenu = CreateMenu();
|
---|
386 | if (hMenu)
|
---|
387 | {
|
---|
388 | POPUPMENU *menu = (POPUPMENU*)hMenu;
|
---|
389 | menu->wFlags = MF_SYSMENU;
|
---|
390 | menu->hWnd = hWnd;
|
---|
391 |
|
---|
392 | if (hPopupMenu == (HMENU)(-1))
|
---|
393 | hPopupMenu = MENU_CopySysPopup();
|
---|
394 | else if( !hPopupMenu ) hPopupMenu = MENU_DefSysPopup;
|
---|
395 |
|
---|
396 | if (hPopupMenu)
|
---|
397 | {
|
---|
398 | InsertMenuA( hMenu, -1, MF_SYSMENU | MF_POPUP | MF_BYPOSITION, hPopupMenu, NULL );
|
---|
399 |
|
---|
400 | menu->items[0].fType = MF_SYSMENU | MF_POPUP;
|
---|
401 | menu->items[0].fState = 0;
|
---|
402 | menu = (POPUPMENU*)hPopupMenu;
|
---|
403 | menu->wFlags |= MF_SYSMENU;
|
---|
404 |
|
---|
405 | //TRACE("GetSysMenu hMenu=%04x (%04x)\n", hMenu, hPopupMenu );
|
---|
406 | return hMenu;
|
---|
407 | }
|
---|
408 | DestroyMenu( hMenu );
|
---|
409 | }
|
---|
410 | //ERR("failed to load system menu!\n");
|
---|
411 | return 0;
|
---|
412 | }
|
---|
413 |
|
---|
414 |
|
---|
415 | /***********************************************************************
|
---|
416 | * MENU_Init
|
---|
417 | *
|
---|
418 | * Menus initialisation.
|
---|
419 | */
|
---|
420 | BOOL MENU_Init()
|
---|
421 | {
|
---|
422 | HBITMAP hBitmap;
|
---|
423 | NONCLIENTMETRICSA ncm;
|
---|
424 |
|
---|
425 | static unsigned char shade_bits[16] = { 0x55, 0, 0xAA, 0,
|
---|
426 | 0x55, 0, 0xAA, 0,
|
---|
427 | 0x55, 0, 0xAA, 0,
|
---|
428 | 0x55, 0, 0xAA, 0 };
|
---|
429 |
|
---|
430 | /* Load menu bitmaps */
|
---|
431 | hStdCheck = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_CHECK));
|
---|
432 | hStdRadioCheck = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_RADIOCHECK));
|
---|
433 | hStdMnArrow = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_MNARROW));
|
---|
434 | /* Load system buttons bitmaps */
|
---|
435 | hBmpMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));
|
---|
436 | hBmpMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));
|
---|
437 | hBmpMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));
|
---|
438 | hBmpMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));
|
---|
439 | hBmpClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE));
|
---|
440 | hBmpCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));
|
---|
441 |
|
---|
442 | if (hStdCheck)
|
---|
443 | {
|
---|
444 | BITMAP bm;
|
---|
445 | GetObjectA( hStdCheck, sizeof(bm), &bm );
|
---|
446 | check_bitmap_width = bm.bmWidth;
|
---|
447 | check_bitmap_height = bm.bmHeight;
|
---|
448 | } else
|
---|
449 | return FALSE;
|
---|
450 |
|
---|
451 | /* Assume that radio checks have the same size as regular check. */
|
---|
452 | if (!hStdRadioCheck)
|
---|
453 | return FALSE;
|
---|
454 |
|
---|
455 | if (hStdMnArrow)
|
---|
456 | {
|
---|
457 | BITMAP bm;
|
---|
458 | GetObjectA( hStdMnArrow, sizeof(bm), &bm );
|
---|
459 | arrow_bitmap_width = bm.bmWidth;
|
---|
460 | arrow_bitmap_height = bm.bmHeight;
|
---|
461 | } else
|
---|
462 | return FALSE;
|
---|
463 |
|
---|
464 | if (! (hBitmap = CreateBitmap( 8, 8, 1, 1, shade_bits)))
|
---|
465 | return FALSE;
|
---|
466 |
|
---|
467 | if(!(hShadeBrush = CreatePatternBrush( hBitmap )))
|
---|
468 | return FALSE;
|
---|
469 |
|
---|
470 | DeleteObject( hBitmap );
|
---|
471 | if (!(MENU_DefSysPopup = MENU_CopySysPopup()))
|
---|
472 | return FALSE;
|
---|
473 |
|
---|
474 | ncm.cbSize = sizeof (NONCLIENTMETRICSA);
|
---|
475 | if (!(SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSA), &ncm, 0)))
|
---|
476 | return FALSE;
|
---|
477 |
|
---|
478 | if (!(hMenuFont = CreateFontIndirectA( &ncm.lfMenuFont )))
|
---|
479 | return FALSE;
|
---|
480 |
|
---|
481 | ncm.lfMenuFont.lfWeight += 300;
|
---|
482 | if ( ncm.lfMenuFont.lfWeight > 1000)
|
---|
483 | ncm.lfMenuFont.lfWeight = 1000;
|
---|
484 |
|
---|
485 | if (!(hMenuFontBold = CreateFontIndirectA( &ncm.lfMenuFont )))
|
---|
486 | return FALSE;
|
---|
487 |
|
---|
488 | return TRUE;
|
---|
489 | }
|
---|
490 |
|
---|
491 | /***********************************************************************
|
---|
492 | * MENU_InitSysMenuPopup
|
---|
493 | *
|
---|
494 | * Grey the appropriate items in System menu.
|
---|
495 | */
|
---|
496 | static void MENU_InitSysMenuPopup( HMENU hmenu, DWORD style, DWORD clsStyle )
|
---|
497 | {
|
---|
498 | BOOL gray;
|
---|
499 |
|
---|
500 | gray = !(style & WS_THICKFRAME) || (style & (WS_MAXIMIZE | WS_MINIMIZE));
|
---|
501 | EnableMenuItem( hmenu, SC_SIZE, (gray ? MF_GRAYED : MF_ENABLED) );
|
---|
502 | gray = ((style & WS_MAXIMIZE) != 0);
|
---|
503 | EnableMenuItem( hmenu, SC_MOVE, (gray ? MF_GRAYED : MF_ENABLED) );
|
---|
504 | gray = !(style & WS_MINIMIZEBOX) || (style & WS_MINIMIZE);
|
---|
505 | EnableMenuItem( hmenu, SC_MINIMIZE, (gray ? MF_GRAYED : MF_ENABLED) );
|
---|
506 | gray = !(style & WS_MAXIMIZEBOX) || (style & WS_MAXIMIZE);
|
---|
507 | EnableMenuItem( hmenu, SC_MAXIMIZE, (gray ? MF_GRAYED : MF_ENABLED) );
|
---|
508 | gray = !(style & (WS_MAXIMIZE | WS_MINIMIZE));
|
---|
509 | EnableMenuItem( hmenu, SC_RESTORE, (gray ? MF_GRAYED : MF_ENABLED) );
|
---|
510 | gray = (clsStyle & CS_NOCLOSE) != 0;
|
---|
511 |
|
---|
512 | /* The menu item must keep its state if it's disabled */
|
---|
513 | if(gray)
|
---|
514 | EnableMenuItem( hmenu, SC_CLOSE, MF_GRAYED);
|
---|
515 | }
|
---|
516 |
|
---|
517 |
|
---|
518 | /******************************************************************************
|
---|
519 | *
|
---|
520 | * UINT32 MENU_GetStartOfNextColumn(
|
---|
521 | * HMENU32 hMenu )
|
---|
522 | *
|
---|
523 | *****************************************************************************/
|
---|
524 |
|
---|
525 | static UINT MENU_GetStartOfNextColumn(
|
---|
526 | HMENU hMenu )
|
---|
527 | {
|
---|
528 | POPUPMENU *menu = (POPUPMENU*)hMenu;
|
---|
529 | UINT i = menu->FocusedItem + 1;
|
---|
530 |
|
---|
531 | if(!menu)
|
---|
532 | return NO_SELECTED_ITEM;
|
---|
533 |
|
---|
534 | if( i == NO_SELECTED_ITEM )
|
---|
535 | return i;
|
---|
536 |
|
---|
537 | for( ; i < menu->nItems; ++i ) {
|
---|
538 | if (menu->items[i].fType & MF_MENUBARBREAK)
|
---|
539 | return i;
|
---|
540 | }
|
---|
541 |
|
---|
542 | return NO_SELECTED_ITEM;
|
---|
543 | }
|
---|
544 |
|
---|
545 |
|
---|
546 | /******************************************************************************
|
---|
547 | *
|
---|
548 | * UINT32 MENU_GetStartOfPrevColumn(
|
---|
549 | * HMENU32 hMenu )
|
---|
550 | *
|
---|
551 | *****************************************************************************/
|
---|
552 |
|
---|
553 | static UINT MENU_GetStartOfPrevColumn(
|
---|
554 | HMENU hMenu )
|
---|
555 | {
|
---|
556 | POPUPMENU const *menu = (POPUPMENU*)hMenu;
|
---|
557 | UINT i;
|
---|
558 |
|
---|
559 | if( !menu )
|
---|
560 | return NO_SELECTED_ITEM;
|
---|
561 |
|
---|
562 | if( menu->FocusedItem == 0 || menu->FocusedItem == NO_SELECTED_ITEM )
|
---|
563 | return NO_SELECTED_ITEM;
|
---|
564 |
|
---|
565 | /* Find the start of the column */
|
---|
566 |
|
---|
567 | for(i = menu->FocusedItem; i != 0 &&
|
---|
568 | !(menu->items[i].fType & MF_MENUBARBREAK);
|
---|
569 | --i); /* empty */
|
---|
570 |
|
---|
571 | if(i == 0)
|
---|
572 | return NO_SELECTED_ITEM;
|
---|
573 |
|
---|
574 | for(--i; i != 0; --i) {
|
---|
575 | if (menu->items[i].fType & MF_MENUBARBREAK)
|
---|
576 | break;
|
---|
577 | }
|
---|
578 |
|
---|
579 | //TRACE("ret %d.\n", i );
|
---|
580 |
|
---|
581 | return i;
|
---|
582 | }
|
---|
583 |
|
---|
584 |
|
---|
585 |
|
---|
586 | /***********************************************************************
|
---|
587 | * MENU_FindItem
|
---|
588 | *
|
---|
589 | * Find a menu item. Return a pointer on the item, and modifies *hmenu
|
---|
590 | * in case the item was in a sub-menu.
|
---|
591 | */
|
---|
592 | static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
|
---|
593 | {
|
---|
594 | POPUPMENU *menu;
|
---|
595 | UINT i;
|
---|
596 |
|
---|
597 | if (((*hmenu)==0xffff) || (!(menu = MENU_GetMenu(*hmenu)))) return NULL;
|
---|
598 | if (wFlags & MF_BYPOSITION)
|
---|
599 | {
|
---|
600 | if (*nPos >= menu->nItems) return NULL;
|
---|
601 | return &menu->items[*nPos];
|
---|
602 | }
|
---|
603 | else
|
---|
604 | {
|
---|
605 | MENUITEM *item = menu->items;
|
---|
606 |
|
---|
607 | for (i = 0; i < menu->nItems; i++, item++)
|
---|
608 | {
|
---|
609 | if (item->wID == *nPos)
|
---|
610 | {
|
---|
611 | *nPos = i;
|
---|
612 | return item;
|
---|
613 | }
|
---|
614 | else if (item->fType & MF_POPUP)
|
---|
615 | {
|
---|
616 | HMENU hsubmenu = item->hSubMenu;
|
---|
617 | MENUITEM *subitem = MENU_FindItem( &hsubmenu, nPos, wFlags );
|
---|
618 | if (subitem)
|
---|
619 | {
|
---|
620 | *hmenu = hsubmenu;
|
---|
621 | return subitem;
|
---|
622 | }
|
---|
623 | }
|
---|
624 | }
|
---|
625 | }
|
---|
626 | return NULL;
|
---|
627 | }
|
---|
628 |
|
---|
629 | /***********************************************************************
|
---|
630 | * MENU_FindSubMenu
|
---|
631 | *
|
---|
632 | * Find a Sub menu. Return the position of the submenu, and modifies
|
---|
633 | * *hmenu in case it is found in another sub-menu.
|
---|
634 | * If the submenu cannot be found, NO_SELECTED_ITEM is returned.
|
---|
635 | */
|
---|
636 | UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget )
|
---|
637 | {
|
---|
638 | POPUPMENU *menu;
|
---|
639 | UINT i;
|
---|
640 | MENUITEM *item;
|
---|
641 | if (((*hmenu)==0xffff) ||
|
---|
642 | (!(menu = MENU_GetMenu(*hmenu))))
|
---|
643 | return NO_SELECTED_ITEM;
|
---|
644 | item = menu->items;
|
---|
645 | for (i = 0; i < menu->nItems; i++, item++) {
|
---|
646 | if(!(item->fType & MF_POPUP)) continue;
|
---|
647 | if (item->hSubMenu == hSubTarget) {
|
---|
648 | return i;
|
---|
649 | }
|
---|
650 | else {
|
---|
651 | HMENU hsubmenu = item->hSubMenu;
|
---|
652 | UINT pos = MENU_FindSubMenu( &hsubmenu, hSubTarget );
|
---|
653 | if (pos != NO_SELECTED_ITEM) {
|
---|
654 | *hmenu = hsubmenu;
|
---|
655 | return pos;
|
---|
656 | }
|
---|
657 | }
|
---|
658 | }
|
---|
659 | return NO_SELECTED_ITEM;
|
---|
660 | }
|
---|
661 |
|
---|
662 | /***********************************************************************
|
---|
663 | * MENU_FreeItemData
|
---|
664 | */
|
---|
665 | static void MENU_FreeItemData( MENUITEM* item )
|
---|
666 | {
|
---|
667 | /* delete text */
|
---|
668 | if (IS_STRING_ITEM(item->fType) && item->text)
|
---|
669 | HeapFree(GetProcessHeap(), 0, item->text );
|
---|
670 | }
|
---|
671 |
|
---|
672 | /***********************************************************************
|
---|
673 | * MENU_FindItemByCoords
|
---|
674 | *
|
---|
675 | * Find the item at the specified coordinates (screen coords). Does
|
---|
676 | * not work for child windows and therefore should not be called for
|
---|
677 | * an arbitrary system menu.
|
---|
678 | */
|
---|
679 | static MENUITEM *MENU_FindItemByCoords( POPUPMENU *menu,
|
---|
680 | POINT pt, UINT *pos )
|
---|
681 | {
|
---|
682 | MENUITEM *item;
|
---|
683 | UINT i;
|
---|
684 | RECT wrect;
|
---|
685 |
|
---|
686 | if (!GetWindowRect(menu->hWnd,&wrect)) return NULL;
|
---|
687 | pt.x -= wrect.left;pt.y -= wrect.top;
|
---|
688 | item = menu->items;
|
---|
689 | for (i = 0; i < menu->nItems; i++, item++)
|
---|
690 | {
|
---|
691 | if ((pt.x >= item->rect.left) && (pt.x < item->rect.right) &&
|
---|
692 | (pt.y >= item->rect.top) && (pt.y < item->rect.bottom))
|
---|
693 | {
|
---|
694 | if (pos) *pos = i;
|
---|
695 | return item;
|
---|
696 | }
|
---|
697 | }
|
---|
698 | return NULL;
|
---|
699 | }
|
---|
700 |
|
---|
701 |
|
---|
702 | /***********************************************************************
|
---|
703 | * MENU_FindItemByKey
|
---|
704 | *
|
---|
705 | * Find the menu item selected by a key press.
|
---|
706 | * Return item id, -1 if none, -2 if we should close the menu.
|
---|
707 | */
|
---|
708 | static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu,
|
---|
709 | UINT key, BOOL forceMenuChar )
|
---|
710 | {
|
---|
711 | //TRACE("\tlooking for '%c' in [%04x]\n", (char)key, (UINT16)hmenu );
|
---|
712 |
|
---|
713 | if (!IsMenu( hmenu ))
|
---|
714 | {
|
---|
715 | hmenu = GetSubMenu(getSysMenu(hwndOwner), 0);
|
---|
716 | }
|
---|
717 |
|
---|
718 | if (hmenu)
|
---|
719 | {
|
---|
720 | POPUPMENU *menu = MENU_GetMenu(hmenu);
|
---|
721 | MENUITEM *item = menu->items;
|
---|
722 | LONG menuchar;
|
---|
723 |
|
---|
724 | if( !forceMenuChar )
|
---|
725 | {
|
---|
726 | UINT i;
|
---|
727 |
|
---|
728 | key = toupper(key);
|
---|
729 | for (i = 0; i < menu->nItems; i++, item++)
|
---|
730 | {
|
---|
731 | if (item->text && (IS_STRING_ITEM(item->fType)))
|
---|
732 | {
|
---|
733 | char *p = item->text - 2;
|
---|
734 | do
|
---|
735 | {
|
---|
736 | p = strchr (p + 2, '&');
|
---|
737 | }
|
---|
738 | while (p != NULL && p [1] == '&');
|
---|
739 | if (p && (toupper(p[1]) == key)) return i;
|
---|
740 | }
|
---|
741 | }
|
---|
742 | }
|
---|
743 | menuchar = SendMessageA( hwndOwner, WM_MENUCHAR,
|
---|
744 | MAKEWPARAM( key, menu->wFlags ), hmenu );
|
---|
745 | if (HIWORD(menuchar) == 2) return LOWORD(menuchar);
|
---|
746 | if (HIWORD(menuchar) == 1) return (UINT)(-2);
|
---|
747 | }
|
---|
748 | return (UINT)(-1);
|
---|
749 | }
|
---|
750 | /***********************************************************************
|
---|
751 | * MENU_LoadMagicItem
|
---|
752 | *
|
---|
753 | * Load the bitmap associated with the magic menu item and its style
|
---|
754 | */
|
---|
755 |
|
---|
756 | static HBITMAP MENU_LoadMagicItem(UINT id, BOOL hilite, DWORD dwItemData)
|
---|
757 | {
|
---|
758 | /*
|
---|
759 | * Magic menu item id's section
|
---|
760 | * These magic id's are used by windows to insert "standard" mdi
|
---|
761 | * buttons (minimize,restore,close) on menu. Under windows,
|
---|
762 | * these magic id's make sure the right things appear when those
|
---|
763 | * bitmap buttons are pressed/selected/released.
|
---|
764 | */
|
---|
765 |
|
---|
766 | switch(id & 0xffff)
|
---|
767 | { case HBMMENU_SYSTEM:
|
---|
768 | return (dwItemData) ?
|
---|
769 | (HBITMAP)dwItemData :
|
---|
770 | (hilite ? hBmpMinimizeD : hBmpMinimize);
|
---|
771 | case HBMMENU_MBAR_RESTORE:
|
---|
772 | return (hilite ? hBmpMaximizeD: hBmpMaximize);
|
---|
773 | case HBMMENU_MBAR_MINIMIZE:
|
---|
774 | return (hilite ? hBmpMinimizeD : hBmpMinimize);
|
---|
775 | case HBMMENU_MBAR_CLOSE:
|
---|
776 | return (hilite ? hBmpCloseD : hBmpClose);
|
---|
777 | case HBMMENU_CALLBACK:
|
---|
778 | case HBMMENU_MBAR_CLOSE_D:
|
---|
779 | case HBMMENU_MBAR_MINIMIZE_D:
|
---|
780 | case HBMMENU_POPUP_CLOSE:
|
---|
781 | case HBMMENU_POPUP_RESTORE:
|
---|
782 | case HBMMENU_POPUP_MAXIMIZE:
|
---|
783 | case HBMMENU_POPUP_MINIMIZE:
|
---|
784 | default:
|
---|
785 | //FIXME("Magic 0x%08x not implemented\n", id);
|
---|
786 | return 0;
|
---|
787 | }
|
---|
788 |
|
---|
789 | }
|
---|
790 |
|
---|
791 | /***********************************************************************
|
---|
792 | * MENU_CalcItemSize
|
---|
793 | *
|
---|
794 | * Calculate the size of the menu item and store it in lpitem->rect.
|
---|
795 | */
|
---|
796 | static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
|
---|
797 | INT orgX, INT orgY, BOOL menuBar )
|
---|
798 | {
|
---|
799 | char *p;
|
---|
800 |
|
---|
801 | //TRACE("dc=0x%04x owner=0x%04x (%d,%d)\n", hdc, hwndOwner, orgX, orgY);
|
---|
802 | //debug_print_menuitem("MENU_CalcItemSize: menuitem:", lpitem,
|
---|
803 | // (menuBar ? " (MenuBar)" : ""));
|
---|
804 |
|
---|
805 | SetRect( &lpitem->rect, orgX, orgY, orgX, orgY );
|
---|
806 |
|
---|
807 | if (lpitem->fType & MF_OWNERDRAW)
|
---|
808 | {
|
---|
809 | MEASUREITEMSTRUCT mis;
|
---|
810 | mis.CtlType = ODT_MENU;
|
---|
811 | mis.CtlID = 0;
|
---|
812 | mis.itemID = lpitem->wID;
|
---|
813 | mis.itemData = (DWORD)lpitem->dwItemData;
|
---|
814 | mis.itemHeight = 0;
|
---|
815 | mis.itemWidth = 0;
|
---|
816 | SendMessageA( hwndOwner, WM_MEASUREITEM, 0, (LPARAM)&mis );
|
---|
817 | lpitem->rect.bottom += mis.itemHeight;
|
---|
818 | lpitem->rect.right += mis.itemWidth;
|
---|
819 | //TRACE("id=%04x size=%dx%d\n",
|
---|
820 | // lpitem->wID, mis.itemWidth, mis.itemHeight);
|
---|
821 | return;
|
---|
822 | }
|
---|
823 |
|
---|
824 | if (lpitem->fType & MF_SEPARATOR)
|
---|
825 | {
|
---|
826 | lpitem->rect.bottom += SEPARATOR_HEIGHT;
|
---|
827 | return;
|
---|
828 | }
|
---|
829 |
|
---|
830 | if (!menuBar)
|
---|
831 | {
|
---|
832 | lpitem->rect.right += 2 * check_bitmap_width;
|
---|
833 | if (lpitem->fType & MF_POPUP)
|
---|
834 | lpitem->rect.right += arrow_bitmap_width;
|
---|
835 | }
|
---|
836 |
|
---|
837 | if (IS_BITMAP_ITEM(lpitem->fType))
|
---|
838 | {
|
---|
839 | BITMAP bm;
|
---|
840 | HBITMAP resBmp = 0;
|
---|
841 |
|
---|
842 | /* Check if there is a magic menu item associated with this item */
|
---|
843 | if((LOWORD((int)lpitem->text))<12)
|
---|
844 | {
|
---|
845 | resBmp = MENU_LoadMagicItem((int)lpitem->text, (lpitem->fType & MF_HILITE),
|
---|
846 | lpitem->dwItemData);
|
---|
847 | }
|
---|
848 | else
|
---|
849 | resBmp = (HBITMAP)lpitem->text;
|
---|
850 |
|
---|
851 | if (GetObjectA(resBmp, sizeof(bm), &bm ))
|
---|
852 | {
|
---|
853 | lpitem->rect.right += bm.bmWidth;
|
---|
854 | lpitem->rect.bottom += bm.bmHeight;
|
---|
855 |
|
---|
856 | }
|
---|
857 | }
|
---|
858 |
|
---|
859 |
|
---|
860 | /* If we get here, then it must be a text item */
|
---|
861 | if (IS_STRING_ITEM( lpitem->fType ))
|
---|
862 | { SIZE size;
|
---|
863 |
|
---|
864 | GetTextExtentPoint32A(hdc, lpitem->text, strlen(lpitem->text), &size);
|
---|
865 |
|
---|
866 | lpitem->rect.right += size.cx;
|
---|
867 | lpitem->rect.bottom += MAX (size.cy, GetSystemMetrics(SM_CYMENU)-1);
|
---|
868 | lpitem->xTab = 0;
|
---|
869 |
|
---|
870 | if (menuBar)
|
---|
871 | {
|
---|
872 | lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
|
---|
873 | }
|
---|
874 | else if ((p = strchr( lpitem->text, '\t' )) != NULL)
|
---|
875 | {
|
---|
876 | /* Item contains a tab (only meaningful in popup menus) */
|
---|
877 | GetTextExtentPoint32A(hdc, lpitem->text, (int)(p - lpitem->text) , &size);
|
---|
878 | lpitem->xTab = check_bitmap_width + MENU_TAB_SPACE + size.cx;
|
---|
879 | lpitem->rect.right += MENU_TAB_SPACE;
|
---|
880 | }
|
---|
881 | else
|
---|
882 | {
|
---|
883 | if (strchr( lpitem->text, '\b' ))
|
---|
884 | lpitem->rect.right += MENU_TAB_SPACE;
|
---|
885 | lpitem->xTab = lpitem->rect.right - check_bitmap_width
|
---|
886 | - arrow_bitmap_width;
|
---|
887 | }
|
---|
888 | }
|
---|
889 | //TRACE("(%d,%d)-(%d,%d)\n", lpitem->rect.left, lpitem->rect.top, lpitem->rect.right, lpitem->rect.bottom);
|
---|
890 | }
|
---|
891 |
|
---|
892 |
|
---|
893 | /***********************************************************************
|
---|
894 | * MENU_PopupMenuCalcSize
|
---|
895 | *
|
---|
896 | * Calculate the size of a popup menu.
|
---|
897 | */
|
---|
898 | static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, HWND hwndOwner )
|
---|
899 | {
|
---|
900 | MENUITEM *lpitem;
|
---|
901 | HDC hdc;
|
---|
902 | int start, i;
|
---|
903 | int orgX, orgY, maxX, maxTab, maxTabWidth;
|
---|
904 |
|
---|
905 | lppop->Width = lppop->Height = 0;
|
---|
906 | if (lppop->nItems == 0) return;
|
---|
907 | hdc = GetDC( 0 );
|
---|
908 |
|
---|
909 | SelectObject( hdc, hMenuFont);
|
---|
910 |
|
---|
911 | start = 0;
|
---|
912 | maxX = 2 ;
|
---|
913 |
|
---|
914 | while (start < lppop->nItems)
|
---|
915 | {
|
---|
916 | lpitem = &lppop->items[start];
|
---|
917 | orgX = maxX;
|
---|
918 | orgY = 2;
|
---|
919 |
|
---|
920 | maxTab = maxTabWidth = 0;
|
---|
921 |
|
---|
922 | /* Parse items until column break or end of menu */
|
---|
923 | for (i = start; i < lppop->nItems; i++, lpitem++)
|
---|
924 | {
|
---|
925 | if ((i != start) &&
|
---|
926 | (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
|
---|
927 |
|
---|
928 | MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, FALSE );
|
---|
929 |
|
---|
930 | if (lpitem->fType & MF_MENUBARBREAK) orgX++;
|
---|
931 | maxX = MAX( maxX, lpitem->rect.right );
|
---|
932 | orgY = lpitem->rect.bottom;
|
---|
933 | if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
|
---|
934 | {
|
---|
935 | maxTab = MAX( maxTab, lpitem->xTab );
|
---|
936 | maxTabWidth = MAX(maxTabWidth,lpitem->rect.right-lpitem->xTab);
|
---|
937 | }
|
---|
938 | }
|
---|
939 |
|
---|
940 | /* Finish the column (set all items to the largest width found) */
|
---|
941 | maxX = MAX( maxX, maxTab + maxTabWidth );
|
---|
942 | for (lpitem = &lppop->items[start]; start < i; start++, lpitem++)
|
---|
943 | {
|
---|
944 | lpitem->rect.right = maxX;
|
---|
945 | if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
|
---|
946 | lpitem->xTab = maxTab;
|
---|
947 |
|
---|
948 | }
|
---|
949 | lppop->Height = MAX( lppop->Height, orgY );
|
---|
950 | }
|
---|
951 |
|
---|
952 | lppop->Width = maxX;
|
---|
953 |
|
---|
954 | /* space for 3d border */
|
---|
955 | lppop->Height += 2;
|
---|
956 | lppop->Width += 2;
|
---|
957 |
|
---|
958 | ReleaseDC( 0, hdc );
|
---|
959 | }
|
---|
960 |
|
---|
961 |
|
---|
962 | /***********************************************************************
|
---|
963 | * MENU_MenuBarCalcSize
|
---|
964 | *
|
---|
965 | * FIXME: Word 6 implements its own MDI and its own 'close window' bitmap
|
---|
966 | * height is off by 1 pixel which causes lengthy window relocations when
|
---|
967 | * active document window is maximized/restored.
|
---|
968 | *
|
---|
969 | * Calculate the size of the menu bar.
|
---|
970 | */
|
---|
971 | static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect,
|
---|
972 | LPPOPUPMENU lppop, HWND hwndOwner )
|
---|
973 | {
|
---|
974 | MENUITEM *lpitem;
|
---|
975 | int start, i, orgX, orgY, maxY, helpPos;
|
---|
976 |
|
---|
977 | if ((lprect == NULL) || (lppop == NULL)) return;
|
---|
978 | if (lppop->nItems == 0) return;
|
---|
979 | //TRACE("left=%d top=%d right=%d bottom=%d\n",
|
---|
980 | // lprect->left, lprect->top, lprect->right, lprect->bottom);
|
---|
981 | lppop->Width = lprect->right - lprect->left;
|
---|
982 | lppop->Height = 0;
|
---|
983 | maxY = lprect->top;
|
---|
984 | start = 0;
|
---|
985 | helpPos = -1;
|
---|
986 | while (start < lppop->nItems)
|
---|
987 | {
|
---|
988 | lpitem = &lppop->items[start];
|
---|
989 | orgX = lprect->left;
|
---|
990 | orgY = maxY;
|
---|
991 |
|
---|
992 | /* Parse items until line break or end of menu */
|
---|
993 | for (i = start; i < lppop->nItems; i++, lpitem++)
|
---|
994 | {
|
---|
995 | if ((helpPos == -1) && (lpitem->fType & MF_HELP)) helpPos = i;
|
---|
996 | if ((i != start) &&
|
---|
997 | (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
|
---|
998 |
|
---|
999 | //TRACE("calling MENU_CalcItemSize org=(%d, %d)\n",
|
---|
1000 | // orgX, orgY );
|
---|
1001 | //debug_print_menuitem (" item: ", lpitem, "");
|
---|
1002 | MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, TRUE );
|
---|
1003 |
|
---|
1004 | if (lpitem->rect.right > lprect->right)
|
---|
1005 | {
|
---|
1006 | if (i != start) break;
|
---|
1007 | else lpitem->rect.right = lprect->right;
|
---|
1008 | }
|
---|
1009 | maxY = MAX( maxY, lpitem->rect.bottom );
|
---|
1010 | orgX = lpitem->rect.right;
|
---|
1011 | }
|
---|
1012 |
|
---|
1013 | /* Finish the line (set all items to the largest height found) */
|
---|
1014 | while (start < i) lppop->items[start++].rect.bottom = maxY;
|
---|
1015 | }
|
---|
1016 |
|
---|
1017 | lprect->bottom = maxY;
|
---|
1018 | lppop->Height = lprect->bottom - lprect->top;
|
---|
1019 |
|
---|
1020 | /* Flush right all magic items and items between the MF_HELP and */
|
---|
1021 | /* the last item (if several lines, only move the last line) */
|
---|
1022 | lpitem = &lppop->items[lppop->nItems-1];
|
---|
1023 | orgY = lpitem->rect.top;
|
---|
1024 | orgX = lprect->right;
|
---|
1025 | for (i = lppop->nItems - 1; i >= helpPos; i--, lpitem--)
|
---|
1026 | {
|
---|
1027 | if ( !IS_BITMAP_ITEM(lpitem->fType) && ((helpPos ==-1) ? TRUE : (helpPos>i) ))
|
---|
1028 | break; /* done */
|
---|
1029 | if (lpitem->rect.top != orgY) break; /* Other line */
|
---|
1030 | if (lpitem->rect.right >= orgX) break; /* Too far right already */
|
---|
1031 | lpitem->rect.left += orgX - lpitem->rect.right;
|
---|
1032 | lpitem->rect.right = orgX;
|
---|
1033 | orgX = lpitem->rect.left;
|
---|
1034 | }
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | /***********************************************************************
|
---|
1038 | * MENU_DrawMenuItem
|
---|
1039 | *
|
---|
1040 | * Draw a single menu item.
|
---|
1041 | */
|
---|
1042 | static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc, MENUITEM *lpitem,
|
---|
1043 | UINT height, BOOL menuBar, UINT odaction )
|
---|
1044 | {
|
---|
1045 | RECT rect;
|
---|
1046 |
|
---|
1047 | //debug_print_menuitem("MENU_DrawMenuItem: ", lpitem, "");
|
---|
1048 |
|
---|
1049 | if (lpitem->fType & MF_SYSMENU) return;
|
---|
1050 |
|
---|
1051 | if (lpitem->fType & MF_OWNERDRAW)
|
---|
1052 | {
|
---|
1053 | DRAWITEMSTRUCT dis;
|
---|
1054 |
|
---|
1055 | dis.CtlType = ODT_MENU;
|
---|
1056 | dis.CtlID = 0;
|
---|
1057 | dis.itemID = lpitem->wID;
|
---|
1058 | dis.itemData = (DWORD)lpitem->dwItemData;
|
---|
1059 | dis.itemState = 0;
|
---|
1060 | if (lpitem->fState & MF_CHECKED) dis.itemState |= ODS_CHECKED;
|
---|
1061 | if (lpitem->fState & MF_GRAYED) dis.itemState |= ODS_GRAYED;
|
---|
1062 | if (lpitem->fState & MF_HILITE) dis.itemState |= ODS_SELECTED;
|
---|
1063 | dis.itemAction = odaction; /* ODA_DRAWENTIRE | ODA_SELECT | ODA_FOCUS; */
|
---|
1064 | dis.hwndItem = hmenu;
|
---|
1065 | dis.hDC = hdc;
|
---|
1066 | dis.rcItem = lpitem->rect;
|
---|
1067 | //TRACE("Ownerdraw: owner=%04x itemID=%d, itemState=%d, itemAction=%d, "
|
---|
1068 | // "hwndItem=%04x, hdc=%04x, rcItem={%d,%d,%d,%d}\n", hwndOwner,
|
---|
1069 | // dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem,
|
---|
1070 | // dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
|
---|
1071 | // dis.rcItem.bottom);
|
---|
1072 | SendMessageA( hwndOwner, WM_DRAWITEM, 0, (LPARAM)&dis );
|
---|
1073 | return;
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | //TRACE("rect={%d,%d,%d,%d}\n", lpitem->rect.left, lpitem->rect.top,
|
---|
1077 | // lpitem->rect.right,lpitem->rect.bottom);
|
---|
1078 |
|
---|
1079 | if (menuBar && (lpitem->fType & MF_SEPARATOR)) return;
|
---|
1080 |
|
---|
1081 | rect = lpitem->rect;
|
---|
1082 |
|
---|
1083 | if ((lpitem->fState & MF_HILITE) && !(IS_BITMAP_ITEM(lpitem->fType)))
|
---|
1084 | FillRect( hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT) );
|
---|
1085 | else {
|
---|
1086 | //SvL: TODO: Bug in GDI32; draws black rectangle instead of menu color
|
---|
1087 | /// for everything except the 1st menu item
|
---|
1088 | RECT dummy = rect;
|
---|
1089 | dummy.bottom = dummy.top+1;
|
---|
1090 | dummy.right = dummy.right+1;
|
---|
1091 | FillRect( hdc, &dummy, GetSysColorBrush(COLOR_HIGHLIGHT) );
|
---|
1092 | FillRect( hdc, &rect, GetSysColorBrush(COLOR_MENU) );
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | SetBkMode( hdc, TRANSPARENT );
|
---|
1096 |
|
---|
1097 | /* vertical separator */
|
---|
1098 | if (!menuBar && (lpitem->fType & MF_MENUBARBREAK))
|
---|
1099 | {
|
---|
1100 | RECT rc = rect;
|
---|
1101 | rc.top = 3;
|
---|
1102 | rc.bottom = height - 3;
|
---|
1103 | DrawEdge (hdc, &rc, EDGE_ETCHED, BF_LEFT);
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | /* horizontal separator */
|
---|
1107 | if (lpitem->fType & MF_SEPARATOR)
|
---|
1108 | {
|
---|
1109 | RECT rc = rect;
|
---|
1110 | rc.left++;
|
---|
1111 | rc.right--;
|
---|
1112 | rc.top += SEPARATOR_HEIGHT / 2;
|
---|
1113 | DrawEdge (hdc, &rc, EDGE_ETCHED, BF_TOP);
|
---|
1114 | return;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | /* Setup colors */
|
---|
1118 |
|
---|
1119 | if ((lpitem->fState & MF_HILITE) && !(IS_BITMAP_ITEM(lpitem->fType)) )
|
---|
1120 | {
|
---|
1121 | if (lpitem->fState & MF_GRAYED)
|
---|
1122 | SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
|
---|
1123 | else
|
---|
1124 | SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
|
---|
1125 | SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
|
---|
1126 | }
|
---|
1127 | else
|
---|
1128 | {
|
---|
1129 | if (lpitem->fState & MF_GRAYED)
|
---|
1130 | SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
|
---|
1131 | else
|
---|
1132 | SetTextColor( hdc, GetSysColor( COLOR_MENUTEXT ) );
|
---|
1133 | SetBkColor( hdc, GetSysColor( COLOR_MENU ) );
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 | /* helper lines for debugging */
|
---|
1137 | /* FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
|
---|
1138 | SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
|
---|
1139 | MoveTo( hdc, rect.left, (rect.top + rect.bottom)/2,NULL);
|
---|
1140 | LineTo( hdc, rect.right, (rect.top + rect.bottom)/2 );
|
---|
1141 | */
|
---|
1142 |
|
---|
1143 | if (!menuBar)
|
---|
1144 | {
|
---|
1145 | INT y = rect.top + rect.bottom;
|
---|
1146 |
|
---|
1147 | /* Draw the check mark
|
---|
1148 | *
|
---|
1149 | * FIXME:
|
---|
1150 | * Custom checkmark bitmaps are monochrome but not always 1bpp.
|
---|
1151 | */
|
---|
1152 |
|
---|
1153 | if (lpitem->fState & MF_CHECKED)
|
---|
1154 | {
|
---|
1155 | HBITMAP bm = lpitem->hCheckBit ? lpitem->hCheckBit :
|
---|
1156 | ((lpitem->fType & MFT_RADIOCHECK) ? hStdRadioCheck : hStdCheck);
|
---|
1157 | HDC hdcMem = CreateCompatibleDC( hdc );
|
---|
1158 |
|
---|
1159 | SelectObject( hdcMem, bm );
|
---|
1160 | BitBlt( hdc, rect.left, (y - check_bitmap_height) / 2,
|
---|
1161 | check_bitmap_width, check_bitmap_height,
|
---|
1162 | hdcMem, 0, 0, (lpitem->fState & MF_HILITE) ? MERGEPAINT : SRCAND );
|
---|
1163 | DeleteDC( hdcMem );
|
---|
1164 | }
|
---|
1165 | else if (lpitem->hUnCheckBit)
|
---|
1166 | {
|
---|
1167 | HDC hdcMem = CreateCompatibleDC( hdc );
|
---|
1168 |
|
---|
1169 | SelectObject( hdcMem, lpitem->hUnCheckBit );
|
---|
1170 | BitBlt( hdc, rect.left, (y - check_bitmap_height) / 2,
|
---|
1171 | check_bitmap_width, check_bitmap_height,
|
---|
1172 | hdcMem, 0, 0, (lpitem->fState & MF_HILITE) ? MERGEPAINT : SRCAND );
|
---|
1173 | DeleteDC( hdcMem );
|
---|
1174 | }
|
---|
1175 |
|
---|
1176 | /* Draw the popup-menu arrow */
|
---|
1177 | if (lpitem->fType & MF_POPUP)
|
---|
1178 | {
|
---|
1179 | HDC hdcMem = CreateCompatibleDC( hdc );
|
---|
1180 |
|
---|
1181 | SelectObject( hdcMem, hStdMnArrow );
|
---|
1182 | BitBlt( hdc, rect.right - arrow_bitmap_width - 1,
|
---|
1183 | (y - arrow_bitmap_height) / 2,
|
---|
1184 | arrow_bitmap_width, arrow_bitmap_height,
|
---|
1185 | hdcMem, 0, 0, (lpitem->fState & MF_HILITE) ? MERGEPAINT : SRCAND );
|
---|
1186 | DeleteDC( hdcMem );
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | rect.left += check_bitmap_width;
|
---|
1190 | rect.right -= arrow_bitmap_width;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | /* Draw the item text or bitmap */
|
---|
1194 | if (IS_BITMAP_ITEM(lpitem->fType))
|
---|
1195 | { int top;
|
---|
1196 |
|
---|
1197 | HBITMAP resBmp = 0;
|
---|
1198 |
|
---|
1199 | HDC hdcMem = CreateCompatibleDC( hdc );
|
---|
1200 |
|
---|
1201 | /*
|
---|
1202 | * Check if there is a magic menu item associated with this item
|
---|
1203 | * and load the appropriate bitmap
|
---|
1204 | */
|
---|
1205 | if((LOWORD((int)lpitem->text)) < 12)
|
---|
1206 | {
|
---|
1207 | resBmp = MENU_LoadMagicItem((int)lpitem->text, (lpitem->fState & MF_HILITE),
|
---|
1208 | lpitem->dwItemData);
|
---|
1209 | }
|
---|
1210 | else
|
---|
1211 | resBmp = (HBITMAP)lpitem->text;
|
---|
1212 |
|
---|
1213 | if (resBmp)
|
---|
1214 | {
|
---|
1215 | BITMAP bm;
|
---|
1216 | GetObjectA( resBmp, sizeof(bm), &bm );
|
---|
1217 |
|
---|
1218 | SelectObject(hdcMem,resBmp );
|
---|
1219 |
|
---|
1220 | /* handle fontsize > bitmap_height */
|
---|
1221 | top = ((rect.bottom-rect.top)>bm.bmHeight) ?
|
---|
1222 | rect.top+(rect.bottom-rect.top-bm.bmHeight)/2 : rect.top;
|
---|
1223 |
|
---|
1224 | BitBlt( hdc, rect.left, top, rect.right - rect.left,
|
---|
1225 | rect.bottom - rect.top, hdcMem, 0, 0, SRCCOPY );
|
---|
1226 | }
|
---|
1227 | DeleteDC( hdcMem );
|
---|
1228 |
|
---|
1229 | return;
|
---|
1230 |
|
---|
1231 | }
|
---|
1232 | /* No bitmap - process text if present */
|
---|
1233 | else if (IS_STRING_ITEM(lpitem->fType))
|
---|
1234 | {
|
---|
1235 | register int i;
|
---|
1236 | HFONT hfontOld = 0;
|
---|
1237 |
|
---|
1238 | UINT uFormat = (menuBar) ?
|
---|
1239 | DT_CENTER | DT_VCENTER | DT_SINGLELINE :
|
---|
1240 | DT_LEFT | DT_VCENTER | DT_SINGLELINE;
|
---|
1241 |
|
---|
1242 | if ( lpitem->fState & MFS_DEFAULT )
|
---|
1243 | {
|
---|
1244 | hfontOld = SelectObject( hdc, hMenuFontBold);
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 | if (menuBar)
|
---|
1248 | {
|
---|
1249 | rect.left += MENU_BAR_ITEMS_SPACE / 2;
|
---|
1250 | rect.right -= MENU_BAR_ITEMS_SPACE / 2;
|
---|
1251 | i = strlen( lpitem->text );
|
---|
1252 | }
|
---|
1253 | else
|
---|
1254 | {
|
---|
1255 | for (i = 0; lpitem->text[i]; i++)
|
---|
1256 | if ((lpitem->text[i] == '\t') || (lpitem->text[i] == '\b'))
|
---|
1257 | break;
|
---|
1258 | }
|
---|
1259 |
|
---|
1260 | if(lpitem->fState & MF_GRAYED)
|
---|
1261 | {
|
---|
1262 | if (!(lpitem->fState & MF_HILITE) )
|
---|
1263 | {
|
---|
1264 | ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
|
---|
1265 | SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
|
---|
1266 | DrawTextA( hdc, lpitem->text, i, &rect, uFormat );
|
---|
1267 | --rect.left; --rect.top; --rect.right; --rect.bottom;
|
---|
1268 | }
|
---|
1269 | SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
|
---|
1270 | }
|
---|
1271 |
|
---|
1272 | DrawTextA( hdc, lpitem->text, i, &rect, uFormat);
|
---|
1273 |
|
---|
1274 | /* paint the shortcut text */
|
---|
1275 | if (lpitem->text[i]) /* There's a tab or flush-right char */
|
---|
1276 | {
|
---|
1277 | if (lpitem->text[i] == '\t')
|
---|
1278 | {
|
---|
1279 | rect.left = lpitem->xTab;
|
---|
1280 | uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
|
---|
1281 | }
|
---|
1282 | else
|
---|
1283 | {
|
---|
1284 | uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE;
|
---|
1285 | }
|
---|
1286 |
|
---|
1287 | if(lpitem->fState & MF_GRAYED)
|
---|
1288 | {
|
---|
1289 | if (!(lpitem->fState & MF_HILITE) )
|
---|
1290 | {
|
---|
1291 | ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
|
---|
1292 | SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
|
---|
1293 | DrawTextA( hdc, lpitem->text + i + 1, -1, &rect, uFormat );
|
---|
1294 | --rect.left; --rect.top; --rect.right; --rect.bottom;
|
---|
1295 | }
|
---|
1296 | SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
|
---|
1297 | }
|
---|
1298 | DrawTextA( hdc, lpitem->text + i + 1, -1, &rect, uFormat );
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | if (hfontOld)
|
---|
1302 | SelectObject (hdc, hfontOld);
|
---|
1303 | }
|
---|
1304 | }
|
---|
1305 |
|
---|
1306 |
|
---|
1307 | /***********************************************************************
|
---|
1308 | * MENU_DrawPopupMenu
|
---|
1309 | *
|
---|
1310 | * Paint a popup menu.
|
---|
1311 | */
|
---|
1312 | static void MENU_DrawPopupMenu( HWND hwnd, HDC hdc, HMENU hmenu )
|
---|
1313 | {
|
---|
1314 | HBRUSH hPrevBrush = 0;
|
---|
1315 | RECT rect;
|
---|
1316 |
|
---|
1317 | //TRACE("wnd=0x%04x dc=0x%04x menu=0x%04x\n", hwnd, hdc, hmenu);
|
---|
1318 |
|
---|
1319 | GetClientRect( hwnd, &rect );
|
---|
1320 |
|
---|
1321 | if((hPrevBrush = SelectObject( hdc, GetSysColorBrush(COLOR_MENU) ))
|
---|
1322 | && (SelectObject( hdc, hMenuFont)))
|
---|
1323 | {
|
---|
1324 | HPEN hPrevPen;
|
---|
1325 |
|
---|
1326 | Rectangle( hdc, rect.left, rect.top, rect.right, rect.bottom );
|
---|
1327 |
|
---|
1328 | hPrevPen = SelectObject( hdc, GetStockObject( NULL_PEN ) );
|
---|
1329 | if( hPrevPen )
|
---|
1330 | {
|
---|
1331 | INT ropPrev, i;
|
---|
1332 | POPUPMENU *menu;
|
---|
1333 |
|
---|
1334 | /* draw 3-d shade */
|
---|
1335 | DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT);
|
---|
1336 |
|
---|
1337 | /* draw menu items */
|
---|
1338 |
|
---|
1339 | menu = MENU_GetMenu(hmenu);
|
---|
1340 | if (menu && menu->nItems)
|
---|
1341 | {
|
---|
1342 | MENUITEM *item;
|
---|
1343 | UINT u;
|
---|
1344 |
|
---|
1345 | for (u = menu->nItems, item = menu->items; u > 0; u--, item++)
|
---|
1346 | MENU_DrawMenuItem( hwnd, hmenu, menu->hwndOwner, hdc, item,
|
---|
1347 | menu->Height, FALSE, ODA_DRAWENTIRE );
|
---|
1348 |
|
---|
1349 | }
|
---|
1350 | } else
|
---|
1351 | {
|
---|
1352 | SelectObject( hdc, hPrevBrush );
|
---|
1353 | }
|
---|
1354 | }
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | /***********************************************************************
|
---|
1358 | * MENU_DrawMenuBar
|
---|
1359 | *
|
---|
1360 | * Paint a menu bar. Returns the height of the menu bar.
|
---|
1361 | * called from [windows/nonclient.c]
|
---|
1362 | */
|
---|
1363 | UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd,
|
---|
1364 | BOOL suppress_draw)
|
---|
1365 | {
|
---|
1366 | LPPOPUPMENU lppop;
|
---|
1367 | UINT i,retvalue;
|
---|
1368 | HFONT hfontOld = 0;
|
---|
1369 |
|
---|
1370 | lppop = MENU_GetMenu(getMenu(hwnd));
|
---|
1371 | if (lppop == NULL || lprect == NULL)
|
---|
1372 | {
|
---|
1373 | retvalue = GetSystemMetrics(SM_CYMENU);
|
---|
1374 | goto END;
|
---|
1375 | }
|
---|
1376 |
|
---|
1377 | //TRACE("(%04x, %p, %p)\n", hDC, lprect, lppop);
|
---|
1378 |
|
---|
1379 | hfontOld = SelectObject( hDC, hMenuFont);
|
---|
1380 |
|
---|
1381 | if (lppop->Height == 0)
|
---|
1382 | MENU_MenuBarCalcSize(hDC, lprect, lppop, hwnd);
|
---|
1383 |
|
---|
1384 | lprect->bottom = lprect->top + lppop->Height;
|
---|
1385 |
|
---|
1386 | if (suppress_draw)
|
---|
1387 | {
|
---|
1388 | retvalue = lppop->Height;
|
---|
1389 | goto END;
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | HDC memDC;
|
---|
1393 | HBITMAP memBmp,oldBmp;
|
---|
1394 | RECT r;
|
---|
1395 | HFONT oldMemFont;
|
---|
1396 |
|
---|
1397 | memDC = CreateCompatibleDC(hDC);
|
---|
1398 | r = *lprect;
|
---|
1399 | r.right -= r.left;
|
---|
1400 | r.bottom -= r.top;
|
---|
1401 | r.left = r.top = 0;
|
---|
1402 | memBmp = CreateCompatibleBitmap(hDC,r.right,r.bottom+1);
|
---|
1403 | oldBmp = SelectObject(memDC,memBmp);
|
---|
1404 | oldMemFont = SelectObject(memDC,hMenuFont);
|
---|
1405 |
|
---|
1406 | FillRect(memDC,&r,GetSysColorBrush(COLOR_MENU));
|
---|
1407 |
|
---|
1408 | SelectObject(memDC,GetSysColorPen(COLOR_3DFACE));
|
---|
1409 | MoveToEx(memDC,r.left,r.bottom,NULL);
|
---|
1410 | LineTo(memDC,r.right,r.bottom);
|
---|
1411 |
|
---|
1412 | if (lppop->nItems == 0)
|
---|
1413 | {
|
---|
1414 | retvalue = GetSystemMetrics(SM_CYMENU);
|
---|
1415 | } else
|
---|
1416 | {
|
---|
1417 | for (i = 0; i < lppop->nItems; i++)
|
---|
1418 | {
|
---|
1419 | OffsetRect(&lppop->items[i].rect,-lprect->left,-lprect->top);
|
---|
1420 | MENU_DrawMenuItem( hwnd,getMenu(hwnd), GetWindow(hwnd,GW_OWNER),
|
---|
1421 | memDC, &lppop->items[i], lppop->Height, TRUE, ODA_DRAWENTIRE );
|
---|
1422 | OffsetRect(&lppop->items[i].rect,lprect->left,lprect->top);
|
---|
1423 | }
|
---|
1424 | retvalue = lppop->Height;
|
---|
1425 | }
|
---|
1426 |
|
---|
1427 | BitBlt(hDC,lprect->left,lprect->top,lprect->right-lprect->left,lprect->bottom-lprect->top+1,memDC,0,0,SRCCOPY);
|
---|
1428 | SelectObject(memDC,oldBmp);
|
---|
1429 | if (oldMemFont) SelectObject(memDC,oldMemFont);
|
---|
1430 | DeleteObject(memBmp);
|
---|
1431 | DeleteDC(memDC);
|
---|
1432 |
|
---|
1433 | END:
|
---|
1434 | if (hfontOld)
|
---|
1435 | SelectObject (hDC, hfontOld);
|
---|
1436 |
|
---|
1437 | return retvalue;
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | /***********************************************************************
|
---|
1441 | * MENU_PatchResidentPopup
|
---|
1442 | */
|
---|
1443 | BOOL MENU_PatchResidentPopup( HQUEUE checkQueue, HWND checkWnd )
|
---|
1444 | {
|
---|
1445 | HWND pTPWnd = MENU_GetTopPopupWnd();
|
---|
1446 | #if 0 //CB: todo
|
---|
1447 | if( pTPWnd )
|
---|
1448 | {
|
---|
1449 | HTASK hTask = 0;
|
---|
1450 |
|
---|
1451 | //TRACE("patching resident popup: %04x %04x [%04x %04x]\n",
|
---|
1452 | // checkQueue, checkWnd ? checkWnd->hwndSelf : 0, pTPWnd->hmemTaskQ,
|
---|
1453 | // pTPWnd->owner ? pTPWnd->owner->hwndSelf : 0);
|
---|
1454 |
|
---|
1455 | switch( checkQueue )
|
---|
1456 | {
|
---|
1457 | case 0: /* checkWnd is the new popup owner */
|
---|
1458 | if( checkWnd )
|
---|
1459 | {
|
---|
1460 | pTPWnd->owner = checkWnd;
|
---|
1461 | if( pTPWnd->hmemTaskQ != checkWnd->hmemTaskQ )
|
---|
1462 | hTask = QUEUE_GetQueueTask( checkWnd->hmemTaskQ );
|
---|
1463 | }
|
---|
1464 | break;
|
---|
1465 |
|
---|
1466 | case 0xFFFF: /* checkWnd is destroyed */
|
---|
1467 | if( pTPWnd->owner == checkWnd )
|
---|
1468 | pTPWnd->owner = NULL;
|
---|
1469 | MENU_ReleaseTopPopupWnd();
|
---|
1470 | return TRUE;
|
---|
1471 |
|
---|
1472 | default: /* checkQueue is exiting */
|
---|
1473 | if( pTPWnd->hmemTaskQ == checkQueue )
|
---|
1474 | {
|
---|
1475 | hTask = QUEUE_GetQueueTask( pTPWnd->hmemTaskQ );
|
---|
1476 | hTask = TASK_GetNextTask( hTask );
|
---|
1477 | }
|
---|
1478 | break;
|
---|
1479 | }
|
---|
1480 |
|
---|
1481 | if( hTask )
|
---|
1482 | {
|
---|
1483 | TDB* task = (TDB*)GlobalLock( hTask );
|
---|
1484 | if( task )
|
---|
1485 | {
|
---|
1486 | pTPWnd->hInstance = task->hInstance;
|
---|
1487 | pTPWnd->hmemTaskQ = task->hQueue;
|
---|
1488 | MENU_ReleaseTopPopupWnd();
|
---|
1489 | return TRUE;
|
---|
1490 | }
|
---|
1491 | //else WARN("failed to patch resident popup.\n");
|
---|
1492 | }
|
---|
1493 | }
|
---|
1494 | #endif
|
---|
1495 | MENU_ReleaseTopPopupWnd();
|
---|
1496 | return FALSE;
|
---|
1497 | }
|
---|
1498 |
|
---|
1499 | /***********************************************************************
|
---|
1500 | * MENU_ShowPopup
|
---|
1501 | *
|
---|
1502 | * Display a popup menu.
|
---|
1503 | */
|
---|
1504 | static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id,
|
---|
1505 | INT x, INT y, INT xanchor, INT yanchor )
|
---|
1506 | {
|
---|
1507 | POPUPMENU *menu;
|
---|
1508 |
|
---|
1509 | //TRACE("owner=0x%04x hmenu=0x%04x id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n",
|
---|
1510 | //hwndOwner, hmenu, id, x, y, xanchor, yanchor);
|
---|
1511 |
|
---|
1512 | if (!(menu = MENU_GetMenu(hmenu))) return FALSE;
|
---|
1513 | if (menu->FocusedItem != NO_SELECTED_ITEM)
|
---|
1514 | {
|
---|
1515 | menu->items[menu->FocusedItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
|
---|
1516 | menu->FocusedItem = NO_SELECTED_ITEM;
|
---|
1517 | }
|
---|
1518 |
|
---|
1519 | /* store the owner for DrawItem*/
|
---|
1520 | menu->hwndOwner = hwndOwner;
|
---|
1521 |
|
---|
1522 | if(IsWindow(hwndOwner))
|
---|
1523 | {
|
---|
1524 | UINT width, height;
|
---|
1525 |
|
---|
1526 | MENU_PopupMenuCalcSize( menu, hwndOwner );
|
---|
1527 |
|
---|
1528 | /* adjust popup menu pos so that it fits within the desktop */
|
---|
1529 |
|
---|
1530 | width = menu->Width + GetSystemMetrics(SM_CXBORDER);
|
---|
1531 | height = menu->Height + GetSystemMetrics(SM_CYBORDER);
|
---|
1532 |
|
---|
1533 | if( x + width > GetSystemMetrics(SM_CXSCREEN ))
|
---|
1534 | {
|
---|
1535 | if( xanchor )
|
---|
1536 | x -= width - xanchor;
|
---|
1537 | if( x + width > GetSystemMetrics(SM_CXSCREEN))
|
---|
1538 | x = GetSystemMetrics(SM_CXSCREEN) - width;
|
---|
1539 | }
|
---|
1540 | if( x < 0 ) x = 0;
|
---|
1541 |
|
---|
1542 | if( y + height > GetSystemMetrics(SM_CYSCREEN ))
|
---|
1543 | {
|
---|
1544 | if( yanchor )
|
---|
1545 | y -= height + yanchor;
|
---|
1546 | if( y + height > GetSystemMetrics(SM_CYSCREEN ))
|
---|
1547 | y = GetSystemMetrics(SM_CYSCREEN) - height;
|
---|
1548 | }
|
---|
1549 | if( y < 0 ) y = 0;
|
---|
1550 |
|
---|
1551 | /* NOTE: In Windows, top menu popup is not owned. */
|
---|
1552 | if (!pTopPopupWnd) /* create top level popup menu window */
|
---|
1553 | {
|
---|
1554 | assert( uSubPWndLevel == 0 );
|
---|
1555 |
|
---|
1556 | pTopPopupWnd = CreateWindowA( POPUPMENUCLASSNAME, NULL,
|
---|
1557 | WS_POPUP, x, y, width, height,
|
---|
1558 | hwndOwner, 0, GetWindowLongA(hwndOwner,GWL_HINSTANCE),
|
---|
1559 | (LPVOID)hmenu );
|
---|
1560 | if (!pTopPopupWnd)
|
---|
1561 | {
|
---|
1562 | return FALSE;
|
---|
1563 | }
|
---|
1564 | menu->hWnd = pTopPopupWnd;
|
---|
1565 | MENU_ReleaseTopPopupWnd();
|
---|
1566 | }
|
---|
1567 | else
|
---|
1568 | if( uSubPWndLevel )
|
---|
1569 | {
|
---|
1570 | /* create a new window for the submenu */
|
---|
1571 |
|
---|
1572 | menu->hWnd = CreateWindowA( POPUPMENUCLASSNAME, NULL,
|
---|
1573 | WS_POPUP, x, y, width, height,
|
---|
1574 | hwndOwner, 0, GetWindowLongA(hwndOwner,GWL_HINSTANCE),
|
---|
1575 | (LPVOID)hmenu );
|
---|
1576 | if( !menu->hWnd )
|
---|
1577 | {
|
---|
1578 | return FALSE;
|
---|
1579 | }
|
---|
1580 | }
|
---|
1581 | else /* top level popup menu window already exists */
|
---|
1582 | {
|
---|
1583 | HWND pTPWnd = MENU_GetTopPopupWnd();
|
---|
1584 | menu->hWnd = pTPWnd;
|
---|
1585 |
|
---|
1586 | MENU_PatchResidentPopup( 0, hwndOwner );
|
---|
1587 | SendMessageA( pTPWnd, MM_SETMENUHANDLE, (WPARAM)hmenu, 0L);
|
---|
1588 |
|
---|
1589 | /* adjust its size */
|
---|
1590 |
|
---|
1591 | SetWindowPos( menu->hWnd, 0, x, y, width, height,
|
---|
1592 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW);
|
---|
1593 | MENU_ReleaseTopPopupWnd();
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 | uSubPWndLevel++; /* menu level counter */
|
---|
1597 |
|
---|
1598 | /* Display the window */
|
---|
1599 |
|
---|
1600 | SetWindowPos( menu->hWnd, HWND_TOP, 0, 0, 0, 0,
|
---|
1601 | SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );
|
---|
1602 | UpdateWindow( menu->hWnd );
|
---|
1603 | return TRUE;
|
---|
1604 | }
|
---|
1605 | return FALSE;
|
---|
1606 | }
|
---|
1607 |
|
---|
1608 |
|
---|
1609 | /***********************************************************************
|
---|
1610 | * MENU_SelectItem
|
---|
1611 | */
|
---|
1612 | static void MENU_SelectItem( HWND hwndOwner, HMENU hmenu, UINT wIndex,
|
---|
1613 | BOOL sendMenuSelect, HMENU topmenu )
|
---|
1614 | {
|
---|
1615 | LPPOPUPMENU lppop;
|
---|
1616 | HDC hdc;
|
---|
1617 |
|
---|
1618 | //TRACE("owner=0x%04x menu=0x%04x index=0x%04x select=0x%04x\n", hwndOwner, hmenu, wIndex, sendMenuSelect);
|
---|
1619 |
|
---|
1620 | lppop = MENU_GetMenu(hmenu);
|
---|
1621 | if ((!lppop) || (!lppop->nItems)) return;
|
---|
1622 |
|
---|
1623 | if (lppop->FocusedItem == wIndex) return;
|
---|
1624 | if (lppop->wFlags & MF_POPUP) hdc = GetDC( lppop->hWnd );
|
---|
1625 | else hdc = GetDCEx( lppop->hWnd, 0, DCX_CACHE | DCX_WINDOW);
|
---|
1626 |
|
---|
1627 | SelectObject( hdc, hMenuFont);
|
---|
1628 |
|
---|
1629 | /* Clear previous highlighted item */
|
---|
1630 | if (lppop->FocusedItem != NO_SELECTED_ITEM)
|
---|
1631 | {
|
---|
1632 | lppop->items[lppop->FocusedItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
|
---|
1633 | MENU_DrawMenuItem(lppop->hWnd, hmenu, hwndOwner, hdc,&lppop->items[lppop->FocusedItem],
|
---|
1634 | lppop->Height, !(lppop->wFlags & MF_POPUP),
|
---|
1635 | ODA_SELECT );
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | /* Highlight new item (if any) */
|
---|
1639 | lppop->FocusedItem = wIndex;
|
---|
1640 | if (lppop->FocusedItem != NO_SELECTED_ITEM)
|
---|
1641 | {
|
---|
1642 | if(!(lppop->items[wIndex].fType & MF_SEPARATOR)) {
|
---|
1643 | lppop->items[wIndex].fState |= MF_HILITE;
|
---|
1644 | MENU_DrawMenuItem( lppop->hWnd, hmenu, hwndOwner, hdc,
|
---|
1645 | &lppop->items[wIndex], lppop->Height,
|
---|
1646 | !(lppop->wFlags & MF_POPUP), ODA_SELECT );
|
---|
1647 | }
|
---|
1648 | if (sendMenuSelect)
|
---|
1649 | {
|
---|
1650 | MENUITEM *ip = &lppop->items[lppop->FocusedItem];
|
---|
1651 | SendMessageA( hwndOwner, WM_MENUSELECT,
|
---|
1652 | MAKELONG(ip->fType & MF_POPUP ? wIndex: ip->wID,
|
---|
1653 | ip->fType | ip->fState | MF_MOUSESELECT |
|
---|
1654 | (lppop->wFlags & MF_SYSMENU)), hmenu);
|
---|
1655 | }
|
---|
1656 | }
|
---|
1657 | else if (sendMenuSelect) {
|
---|
1658 | if(topmenu){
|
---|
1659 | int pos;
|
---|
1660 | if((pos=MENU_FindSubMenu(&topmenu, hmenu))!=NO_SELECTED_ITEM){
|
---|
1661 | POPUPMENU *ptm = (POPUPMENU*)topmenu;
|
---|
1662 | MENUITEM *ip = &ptm->items[pos];
|
---|
1663 | SendMessageA( hwndOwner, WM_MENUSELECT, MAKELONG(pos,
|
---|
1664 | ip->fType | ip->fState | MF_MOUSESELECT |
|
---|
1665 | (ptm->wFlags & MF_SYSMENU)), topmenu);
|
---|
1666 | }
|
---|
1667 | }
|
---|
1668 | }
|
---|
1669 | ReleaseDC( lppop->hWnd, hdc );
|
---|
1670 | }
|
---|
1671 |
|
---|
1672 |
|
---|
1673 | /***********************************************************************
|
---|
1674 | * MENU_MoveSelection
|
---|
1675 | *
|
---|
1676 | * Moves currently selected item according to the offset parameter.
|
---|
1677 | * If there is no selection then it should select the last item if
|
---|
1678 | * offset is ITEM_PREV or the first item if offset is ITEM_NEXT.
|
---|
1679 | */
|
---|
1680 | static void MENU_MoveSelection( HWND hwndOwner, HMENU hmenu, INT offset )
|
---|
1681 | {
|
---|
1682 | INT i;
|
---|
1683 | POPUPMENU *menu;
|
---|
1684 |
|
---|
1685 | //TRACE("hwnd=0x%04x hmenu=0x%04x off=0x%04x\n", hwndOwner, hmenu, offset);
|
---|
1686 |
|
---|
1687 | menu = MENU_GetMenu(hmenu);
|
---|
1688 | if ((!menu) || (!menu->items)) return;
|
---|
1689 |
|
---|
1690 | if ( menu->FocusedItem != NO_SELECTED_ITEM )
|
---|
1691 | {
|
---|
1692 | if( menu->nItems == 1 ) return; else
|
---|
1693 | for (i = menu->FocusedItem + offset ; i >= 0 && i < menu->nItems
|
---|
1694 | ; i += offset)
|
---|
1695 | if (!(menu->items[i].fType & MF_SEPARATOR))
|
---|
1696 | {
|
---|
1697 | MENU_SelectItem( hwndOwner, hmenu, i, TRUE, 0 );
|
---|
1698 | return;
|
---|
1699 | }
|
---|
1700 | }
|
---|
1701 |
|
---|
1702 | for ( i = (offset > 0) ? 0 : menu->nItems - 1;
|
---|
1703 | i >= 0 && i < menu->nItems ; i += offset)
|
---|
1704 | if (!(menu->items[i].fType & MF_SEPARATOR))
|
---|
1705 | {
|
---|
1706 | MENU_SelectItem( hwndOwner, hmenu, i, TRUE, 0 );
|
---|
1707 | return;
|
---|
1708 | }
|
---|
1709 | }
|
---|
1710 |
|
---|
1711 |
|
---|
1712 | /**********************************************************************
|
---|
1713 | * MENU_SetItemData
|
---|
1714 | *
|
---|
1715 | * Set an item flags, id and text ptr. Called by InsertMenu() and
|
---|
1716 | * ModifyMenu().
|
---|
1717 | */
|
---|
1718 | static BOOL MENU_SetItemData( MENUITEM *item, UINT flags, UINT id,
|
---|
1719 | LPCSTR str )
|
---|
1720 | {
|
---|
1721 | LPSTR prevText = IS_STRING_ITEM(item->fType) ? item->text : NULL;
|
---|
1722 |
|
---|
1723 | //debug_print_menuitem("MENU_SetItemData from: ", item, "");
|
---|
1724 |
|
---|
1725 |
|
---|
1726 | if (IS_STRING_ITEM(flags))
|
---|
1727 | {
|
---|
1728 | if (!str || !*str)
|
---|
1729 | {
|
---|
1730 | flags |= MF_SEPARATOR;
|
---|
1731 | item->text = NULL;
|
---|
1732 | }
|
---|
1733 | else
|
---|
1734 | {
|
---|
1735 | LPSTR text;
|
---|
1736 | /* Item beginning with a backspace is a help item */
|
---|
1737 | if (*str == '\b')
|
---|
1738 | {
|
---|
1739 | flags |= MF_HELP;
|
---|
1740 | str++;
|
---|
1741 | }
|
---|
1742 | if (!(text = HEAP_strdupA(GetProcessHeap(), 0, str ))) return FALSE;
|
---|
1743 | item->text = text;
|
---|
1744 | }
|
---|
1745 | }
|
---|
1746 | else if (IS_BITMAP_ITEM(flags))
|
---|
1747 | item->text = (LPSTR)(HBITMAP)LOWORD(str);
|
---|
1748 | else item->text = NULL;
|
---|
1749 |
|
---|
1750 | if (flags & MF_OWNERDRAW)
|
---|
1751 | item->dwItemData = (DWORD)str;
|
---|
1752 | else
|
---|
1753 | item->dwItemData = 0;
|
---|
1754 |
|
---|
1755 | if ((item->fType & MF_POPUP) && (flags & MF_POPUP) && (item->hSubMenu != id) )
|
---|
1756 | DestroyMenu( item->hSubMenu ); /* ModifyMenu() spec */
|
---|
1757 |
|
---|
1758 | if (flags & MF_POPUP)
|
---|
1759 | {
|
---|
1760 | POPUPMENU *menu = MENU_GetMenu((UINT)id);
|
---|
1761 | if (menu) menu->wFlags |= MF_POPUP;
|
---|
1762 | else
|
---|
1763 | {
|
---|
1764 | item->wID = 0;
|
---|
1765 | item->hSubMenu = 0;
|
---|
1766 | item->fType = 0;
|
---|
1767 | item->fState = 0;
|
---|
1768 | return FALSE;
|
---|
1769 | }
|
---|
1770 | }
|
---|
1771 |
|
---|
1772 | item->wID = id;
|
---|
1773 | if (flags & MF_POPUP)
|
---|
1774 | item->hSubMenu = id;
|
---|
1775 |
|
---|
1776 | if ((item->fType & MF_POPUP) && !(flags & MF_POPUP) )
|
---|
1777 | flags |= MF_POPUP; /* keep popup */
|
---|
1778 |
|
---|
1779 | item->fType = flags & TYPE_MASK;
|
---|
1780 | item->fState = (flags & STATE_MASK) &
|
---|
1781 | ~(MF_HILITE | MF_MOUSESELECT | MF_BYPOSITION);
|
---|
1782 |
|
---|
1783 |
|
---|
1784 | /* Don't call SetRectEmpty here! */
|
---|
1785 |
|
---|
1786 |
|
---|
1787 | if (prevText) HeapFree(GetProcessHeap(), 0, prevText );
|
---|
1788 |
|
---|
1789 | //debug_print_menuitem("MENU_SetItemData to : ", item, "");
|
---|
1790 | return TRUE;
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 |
|
---|
1794 | /**********************************************************************
|
---|
1795 | * MENU_InsertItem
|
---|
1796 | *
|
---|
1797 | * Insert a new item into a menu.
|
---|
1798 | */
|
---|
1799 | static MENUITEM *MENU_InsertItem( HMENU hMenu, UINT pos, UINT flags )
|
---|
1800 | {
|
---|
1801 | MENUITEM *newItems;
|
---|
1802 | POPUPMENU *menu;
|
---|
1803 |
|
---|
1804 | if (!(menu = MENU_GetMenu(hMenu)))
|
---|
1805 | return NULL;
|
---|
1806 |
|
---|
1807 | /* Find where to insert new item */
|
---|
1808 |
|
---|
1809 | if ((pos==(UINT)-1) || ((flags & MF_BYPOSITION) && (pos == menu->nItems)))
|
---|
1810 | {
|
---|
1811 | /* Special case: append to menu */
|
---|
1812 | /* Some programs specify the menu length to do that */
|
---|
1813 | pos = menu->nItems;
|
---|
1814 | } else
|
---|
1815 | {
|
---|
1816 | if (!MENU_FindItem( &hMenu, &pos, flags ))
|
---|
1817 | {
|
---|
1818 | //FIXME("item %x not found\n", pos );
|
---|
1819 | return NULL;
|
---|
1820 | }
|
---|
1821 | if (!(menu = MENU_GetMenu(hMenu)))
|
---|
1822 | return NULL;
|
---|
1823 | }
|
---|
1824 |
|
---|
1825 | /* Create new items array */
|
---|
1826 |
|
---|
1827 | newItems = (MENUITEM*)HeapAlloc(GetProcessHeap(), 0, sizeof(MENUITEM) * (menu->nItems+1) );
|
---|
1828 | if (!newItems)
|
---|
1829 | {
|
---|
1830 | //WARN("allocation failed\n" );
|
---|
1831 | return NULL;
|
---|
1832 | }
|
---|
1833 | if (menu->nItems > 0)
|
---|
1834 | {
|
---|
1835 | /* Copy the old array into the new */
|
---|
1836 | if (pos > 0) memcpy( newItems, menu->items, pos * sizeof(MENUITEM) );
|
---|
1837 | if (pos < menu->nItems) memcpy( &newItems[pos+1], &menu->items[pos],
|
---|
1838 | (menu->nItems-pos)*sizeof(MENUITEM) );
|
---|
1839 | HeapFree(GetProcessHeap(), 0, menu->items );
|
---|
1840 | }
|
---|
1841 | menu->items = newItems;
|
---|
1842 | menu->nItems++;
|
---|
1843 | memset( &newItems[pos], 0, sizeof(*newItems) );
|
---|
1844 | menu->Height = 0; /* force size recalculate */
|
---|
1845 | return &newItems[pos];
|
---|
1846 | }
|
---|
1847 |
|
---|
1848 |
|
---|
1849 | /**********************************************************************
|
---|
1850 | * MENU_ParseResource
|
---|
1851 | *
|
---|
1852 | * Parse a standard menu resource and add items to the menu.
|
---|
1853 | * Return a pointer to the end of the resource.
|
---|
1854 | */
|
---|
1855 | static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu, BOOL unicode )
|
---|
1856 | {
|
---|
1857 | WORD flags, id = 0;
|
---|
1858 | LPCSTR str;
|
---|
1859 |
|
---|
1860 | do
|
---|
1861 | {
|
---|
1862 | flags = GET_WORD(res);
|
---|
1863 | res += sizeof(WORD);
|
---|
1864 | if (!(flags & MF_POPUP))
|
---|
1865 | {
|
---|
1866 | id = GET_WORD(res);
|
---|
1867 | res += sizeof(WORD);
|
---|
1868 | }
|
---|
1869 | //if (!IS_STRING_ITEM(flags))
|
---|
1870 | // ERR("not a string item %04x\n", flags );
|
---|
1871 | str = res;
|
---|
1872 | if (!unicode) res += strlen(str) + 1;
|
---|
1873 | else res += (lstrlenW((LPCWSTR)str) + 1) * sizeof(WCHAR);
|
---|
1874 | if (flags & MF_POPUP)
|
---|
1875 | {
|
---|
1876 | HMENU hSubMenu = CreatePopupMenu();
|
---|
1877 | if (!hSubMenu) return NULL;
|
---|
1878 | if (!(res = MENU_ParseResource( res, hSubMenu, unicode )))
|
---|
1879 | return NULL;
|
---|
1880 | if (!unicode) AppendMenuA( hMenu, flags, (UINT)hSubMenu, str );
|
---|
1881 | else AppendMenuW( hMenu, flags, (UINT)hSubMenu, (LPCWSTR)str );
|
---|
1882 | }
|
---|
1883 | else /* Not a popup */
|
---|
1884 | {
|
---|
1885 | if (!unicode) AppendMenuA( hMenu, flags, id, *str ? str : NULL );
|
---|
1886 | else AppendMenuW( hMenu, flags, id,
|
---|
1887 | *(LPCWSTR)str ? (LPCWSTR)str : NULL );
|
---|
1888 | }
|
---|
1889 | } while (!(flags & MF_END));
|
---|
1890 | return res;
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 |
|
---|
1894 | /**********************************************************************
|
---|
1895 | * MENUEX_ParseResource
|
---|
1896 | *
|
---|
1897 | * Parse an extended menu resource and add items to the menu.
|
---|
1898 | * Return a pointer to the end of the resource.
|
---|
1899 | */
|
---|
1900 | static LPCSTR MENUEX_ParseResource( LPCSTR res, HMENU hMenu)
|
---|
1901 | {
|
---|
1902 | WORD resinfo;
|
---|
1903 | do {
|
---|
1904 | MENUITEMINFOW mii;
|
---|
1905 |
|
---|
1906 | mii.cbSize = sizeof(mii);
|
---|
1907 | mii.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
|
---|
1908 | mii.fType = GET_DWORD(res);
|
---|
1909 | res += sizeof(DWORD);
|
---|
1910 | mii.fState = GET_DWORD(res);
|
---|
1911 | res += sizeof(DWORD);
|
---|
1912 | mii.wID = GET_DWORD(res);
|
---|
1913 | res += sizeof(DWORD);
|
---|
1914 | resinfo = GET_WORD(res);
|
---|
1915 | res += sizeof(WORD);
|
---|
1916 | /* Align the text on a word boundary. */
|
---|
1917 | res += (~((int)res - 1)) & 1;
|
---|
1918 | mii.dwTypeData = (LPWSTR) res;
|
---|
1919 | res += (1 + lstrlenW(mii.dwTypeData)) * sizeof(WCHAR);
|
---|
1920 | /* Align the following fields on a dword boundary. */
|
---|
1921 | res += (~((int)res - 1)) & 3;
|
---|
1922 |
|
---|
1923 | /* FIXME: This is inefficient and cannot be optimised away by gcc. */
|
---|
1924 | {
|
---|
1925 | LPSTR newstr = HEAP_strdupWtoA(GetProcessHeap(),
|
---|
1926 | 0, mii.dwTypeData);
|
---|
1927 | //TRACE("Menu item: [%08x,%08x,%04x,%04x,%s]\n",
|
---|
1928 | // mii.fType, mii.fState, mii.wID, resinfo, newstr);
|
---|
1929 | HeapFree( GetProcessHeap(), 0, newstr );
|
---|
1930 | }
|
---|
1931 |
|
---|
1932 | if (resinfo & 1) { /* Pop-up? */
|
---|
1933 | /* DWORD helpid = GET_DWORD(res); FIXME: use this. */
|
---|
1934 | res += sizeof(DWORD);
|
---|
1935 | mii.hSubMenu = CreatePopupMenu();
|
---|
1936 | if (!mii.hSubMenu)
|
---|
1937 | return NULL;
|
---|
1938 | if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) {
|
---|
1939 | DestroyMenu(mii.hSubMenu);
|
---|
1940 | return NULL;
|
---|
1941 | }
|
---|
1942 | mii.fMask |= MIIM_SUBMENU;
|
---|
1943 | mii.fType |= MF_POPUP;
|
---|
1944 | }
|
---|
1945 | InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii);
|
---|
1946 | } while (!(resinfo & MF_END));
|
---|
1947 | return res;
|
---|
1948 | }
|
---|
1949 |
|
---|
1950 |
|
---|
1951 | /***********************************************************************
|
---|
1952 | * MENU_GetSubPopup
|
---|
1953 | *
|
---|
1954 | * Return the handle of the selected sub-popup menu (if any).
|
---|
1955 | */
|
---|
1956 | static HMENU MENU_GetSubPopup( HMENU hmenu )
|
---|
1957 | {
|
---|
1958 | POPUPMENU *menu;
|
---|
1959 | MENUITEM *item;
|
---|
1960 |
|
---|
1961 | menu = MENU_GetMenu(hmenu);
|
---|
1962 |
|
---|
1963 | if ((!menu) || (menu->FocusedItem == NO_SELECTED_ITEM)) return 0;
|
---|
1964 |
|
---|
1965 | item = &menu->items[menu->FocusedItem];
|
---|
1966 | if ((item->fType & MF_POPUP) && (item->fState & MF_MOUSESELECT))
|
---|
1967 | return item->hSubMenu;
|
---|
1968 | return 0;
|
---|
1969 | }
|
---|
1970 |
|
---|
1971 |
|
---|
1972 | /***********************************************************************
|
---|
1973 | * MENU_HideSubPopups
|
---|
1974 | *
|
---|
1975 | * Hide the sub-popup menus of this menu.
|
---|
1976 | */
|
---|
1977 | static void MENU_HideSubPopups( HWND hwndOwner, HMENU hmenu,
|
---|
1978 | BOOL sendMenuSelect )
|
---|
1979 | {
|
---|
1980 | POPUPMENU *menu = MENU_GetMenu(hmenu);
|
---|
1981 |
|
---|
1982 | //TRACE("owner=0x%04x hmenu=0x%04x 0x%04x\n", hwndOwner, hmenu, sendMenuSelect);
|
---|
1983 |
|
---|
1984 | if (menu && uSubPWndLevel)
|
---|
1985 | {
|
---|
1986 | HMENU hsubmenu;
|
---|
1987 | POPUPMENU *submenu;
|
---|
1988 | MENUITEM *item;
|
---|
1989 |
|
---|
1990 | if (menu->FocusedItem != NO_SELECTED_ITEM)
|
---|
1991 | {
|
---|
1992 | item = &menu->items[menu->FocusedItem];
|
---|
1993 | if (!(item->fType & MF_POPUP) ||
|
---|
1994 | !(item->fState & MF_MOUSESELECT)) return;
|
---|
1995 | item->fState &= ~MF_MOUSESELECT;
|
---|
1996 | hsubmenu = item->hSubMenu;
|
---|
1997 | } else return;
|
---|
1998 |
|
---|
1999 | submenu = MENU_GetMenu(hsubmenu);
|
---|
2000 | MENU_HideSubPopups( hwndOwner, hsubmenu, FALSE );
|
---|
2001 | MENU_SelectItem( hwndOwner, hsubmenu, NO_SELECTED_ITEM, sendMenuSelect, 0 );
|
---|
2002 |
|
---|
2003 | if (submenu->hWnd == MENU_GetTopPopupWnd() )
|
---|
2004 | {
|
---|
2005 | ShowWindow( submenu->hWnd, SW_HIDE );
|
---|
2006 | uSubPWndLevel = 0;
|
---|
2007 | }
|
---|
2008 | else
|
---|
2009 | {
|
---|
2010 | DestroyWindow( submenu->hWnd );
|
---|
2011 | submenu->hWnd = 0;
|
---|
2012 | }
|
---|
2013 | MENU_ReleaseTopPopupWnd();
|
---|
2014 | }
|
---|
2015 | }
|
---|
2016 |
|
---|
2017 |
|
---|
2018 | /***********************************************************************
|
---|
2019 | * MENU_ShowSubPopup
|
---|
2020 | *
|
---|
2021 | * Display the sub-menu of the selected item of this menu.
|
---|
2022 | * Return the handle of the submenu, or hmenu if no submenu to display.
|
---|
2023 | */
|
---|
2024 | static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
|
---|
2025 | BOOL selectFirst, UINT wFlags,POINT *pt)
|
---|
2026 | {
|
---|
2027 | RECT rect;
|
---|
2028 | POPUPMENU *menu;
|
---|
2029 | MENUITEM *item;
|
---|
2030 | HDC hdc;
|
---|
2031 |
|
---|
2032 | //TRACE("owner=0x%04x hmenu=0x%04x 0x%04x\n", hwndOwner, hmenu, selectFirst);
|
---|
2033 |
|
---|
2034 | if (!(menu = MENU_GetMenu(hmenu))) return hmenu;
|
---|
2035 |
|
---|
2036 | if (menu->FocusedItem == NO_SELECTED_ITEM)
|
---|
2037 | {
|
---|
2038 | return hmenu;
|
---|
2039 | }
|
---|
2040 |
|
---|
2041 | item = &menu->items[menu->FocusedItem];
|
---|
2042 | if (!(item->fType & MF_POPUP) ||
|
---|
2043 | (item->fState & (MF_GRAYED | MF_DISABLED)))
|
---|
2044 | {
|
---|
2045 | return hmenu;
|
---|
2046 | }
|
---|
2047 |
|
---|
2048 | /* message must be send before using item,
|
---|
2049 | because nearly everything may by changed by the application ! */
|
---|
2050 |
|
---|
2051 | /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
|
---|
2052 | if (!(wFlags & TPM_NONOTIFY))
|
---|
2053 | SendMessageA( hwndOwner, WM_INITMENUPOPUP, item->hSubMenu,
|
---|
2054 | MAKELONG( menu->FocusedItem, IS_SYSTEM_MENU(menu) ));
|
---|
2055 |
|
---|
2056 | item = &menu->items[menu->FocusedItem];
|
---|
2057 | rect = item->rect;
|
---|
2058 |
|
---|
2059 | /* correct item if modified as a reaction to WM_INITMENUPOPUP-message */
|
---|
2060 | if (!(item->fState & MF_HILITE))
|
---|
2061 | {
|
---|
2062 | if (menu->wFlags & MF_POPUP) hdc = GetDC( menu->hWnd );
|
---|
2063 | else hdc = GetDCEx( menu->hWnd, 0, DCX_CACHE | DCX_WINDOW);
|
---|
2064 |
|
---|
2065 | SelectObject( hdc, hMenuFont);
|
---|
2066 |
|
---|
2067 | item->fState |= MF_HILITE;
|
---|
2068 | MENU_DrawMenuItem( menu->hWnd, hmenu, hwndOwner, hdc, item, menu->Height, !(menu->wFlags & MF_POPUP), ODA_DRAWENTIRE );
|
---|
2069 | ReleaseDC( menu->hWnd, hdc );
|
---|
2070 | }
|
---|
2071 | if (!item->rect.top && !item->rect.left && !item->rect.bottom && !item->rect.right)
|
---|
2072 | item->rect = rect;
|
---|
2073 |
|
---|
2074 | item->fState |= MF_MOUSESELECT;
|
---|
2075 |
|
---|
2076 | if (IS_SYSTEM_MENU(menu))
|
---|
2077 | {
|
---|
2078 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(menu->hWnd);
|
---|
2079 |
|
---|
2080 | MENU_InitSysMenuPopup(item->hSubMenu,GetWindowLongA(menu->hWnd,GWL_STYLE), GetClassLongA(menu->hWnd, GCL_STYLE));
|
---|
2081 |
|
---|
2082 | if ((wFlags & TPM_CAPTIONSYSMENU) && pt)
|
---|
2083 | {
|
---|
2084 | rect.top = pt->y;
|
---|
2085 | rect.left = pt->x;
|
---|
2086 | rect.bottom = rect.right = 0;
|
---|
2087 | } else
|
---|
2088 | {
|
---|
2089 | if (win32wnd) win32wnd->GetSysPopupPos(&rect);
|
---|
2090 | rect.top = rect.bottom;
|
---|
2091 | rect.right = GetSystemMetrics(SM_CXSIZE);
|
---|
2092 | rect.bottom = GetSystemMetrics(SM_CYSIZE);
|
---|
2093 | }
|
---|
2094 | }
|
---|
2095 | else
|
---|
2096 | {
|
---|
2097 | if (menu->wFlags & MF_POPUP)
|
---|
2098 | {
|
---|
2099 | RECT rectWindow;
|
---|
2100 |
|
---|
2101 | GetWindowRect(menu->hWnd,&rectWindow);
|
---|
2102 | rect.left = rectWindow.left + item->rect.right-arrow_bitmap_width;
|
---|
2103 | rect.top = rectWindow.top + item->rect.top;
|
---|
2104 | rect.right = item->rect.left - item->rect.right + 2*arrow_bitmap_width;
|
---|
2105 | rect.bottom = item->rect.top - item->rect.bottom;
|
---|
2106 | }
|
---|
2107 | else
|
---|
2108 | {
|
---|
2109 | RECT rectWindow;
|
---|
2110 |
|
---|
2111 | GetWindowRect(menu->hWnd,&rectWindow);
|
---|
2112 | rect.left = rectWindow.left + item->rect.left;
|
---|
2113 | rect.top = rectWindow.top + item->rect.bottom;
|
---|
2114 | rect.right = item->rect.right - item->rect.left;
|
---|
2115 | rect.bottom = item->rect.bottom - item->rect.top;
|
---|
2116 | }
|
---|
2117 | }
|
---|
2118 |
|
---|
2119 | MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem,
|
---|
2120 | rect.left, rect.top, rect.right, rect.bottom );
|
---|
2121 | if (selectFirst)
|
---|
2122 | MENU_MoveSelection( hwndOwner, item->hSubMenu, ITEM_NEXT );
|
---|
2123 | return item->hSubMenu;
|
---|
2124 | }
|
---|
2125 |
|
---|
2126 | /***********************************************************************
|
---|
2127 | * MENU_PtMenu
|
---|
2128 | *
|
---|
2129 | * Walks menu chain trying to find a menu pt maps to.
|
---|
2130 | */
|
---|
2131 | static HMENU MENU_PtMenu(HMENU hMenu,POINT pt,BOOL inMenuBar)
|
---|
2132 | {
|
---|
2133 | POPUPMENU *menu = MENU_GetMenu(hMenu);
|
---|
2134 | register UINT ht = menu->FocusedItem;
|
---|
2135 |
|
---|
2136 | /* try subpopup first (if any) */
|
---|
2137 | ht = (ht != NO_SELECTED_ITEM &&
|
---|
2138 | (menu->items[ht].fType & MF_POPUP) &&
|
---|
2139 | (menu->items[ht].fState & MF_MOUSESELECT))
|
---|
2140 | ? (UINT) MENU_PtMenu(menu->items[ht].hSubMenu,pt,inMenuBar) : 0;
|
---|
2141 |
|
---|
2142 | if( !ht ) /* check the current window (avoiding WM_HITTEST) */
|
---|
2143 | {
|
---|
2144 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(menu->hWnd);
|
---|
2145 | if(win32wnd==NULL)
|
---|
2146 | DebugInt3();
|
---|
2147 |
|
---|
2148 | ht = win32wnd->HandleNCHitTest(pt);
|
---|
2149 | if( menu->wFlags & MF_POPUP )
|
---|
2150 | ht = (ht != (UINT)HTNOWHERE &&
|
---|
2151 | ht != (UINT)HTERROR) ? (UINT)hMenu : 0;
|
---|
2152 | else
|
---|
2153 | {
|
---|
2154 | ht = ((ht == HTSYSMENU) && !inMenuBar) ? (UINT)(getSysMenu(menu->hWnd))
|
---|
2155 | : ((ht == HTMENU) && inMenuBar) ? (UINT)(getMenu(menu->hWnd)) : 0;
|
---|
2156 | }
|
---|
2157 | }
|
---|
2158 | return (HMENU)ht;
|
---|
2159 | }
|
---|
2160 |
|
---|
2161 | /***********************************************************************
|
---|
2162 | * MENU_ExecFocusedItem
|
---|
2163 | *
|
---|
2164 | * Execute a menu item (for instance when user pressed Enter).
|
---|
2165 | * Return the wID of the executed item. Otherwise, -1 indicating
|
---|
2166 | * that no menu item wase executed;
|
---|
2167 | * Have to receive the flags for the TrackPopupMenu options to avoid
|
---|
2168 | * sending unwanted message.
|
---|
2169 | *
|
---|
2170 | */
|
---|
2171 | static INT MENU_ExecFocusedItem( MTRACKER* pmt, HMENU hMenu, UINT wFlags )
|
---|
2172 | {
|
---|
2173 | MENUITEM *item;
|
---|
2174 | POPUPMENU *menu = MENU_GetMenu(hMenu);
|
---|
2175 |
|
---|
2176 | //TRACE("%p hmenu=0x%04x\n", pmt, hMenu);
|
---|
2177 |
|
---|
2178 | if (!menu || !menu->nItems ||
|
---|
2179 | (menu->FocusedItem == NO_SELECTED_ITEM)) return -1;
|
---|
2180 |
|
---|
2181 | item = &menu->items[menu->FocusedItem];
|
---|
2182 |
|
---|
2183 | //TRACE("%08x %08x %08x\n",
|
---|
2184 | // hMenu, item->wID, item->hSubMenu);
|
---|
2185 |
|
---|
2186 | if (!(item->fType & MF_POPUP))
|
---|
2187 | {
|
---|
2188 | if (!(item->fState & (MF_GRAYED | MF_DISABLED)))
|
---|
2189 | {
|
---|
2190 | /* If TPM_RETURNCMD is set you return the id, but
|
---|
2191 | do not send a message to the owner */
|
---|
2192 | if(!(wFlags & TPM_RETURNCMD))
|
---|
2193 | {
|
---|
2194 | if( menu->wFlags & MF_SYSMENU )
|
---|
2195 | PostMessageA( pmt->hOwnerWnd, WM_SYSCOMMAND, item->wID,
|
---|
2196 | MAKELPARAM(pmt->pt.x, pmt->pt.y) );
|
---|
2197 | else
|
---|
2198 | PostMessageA( pmt->hOwnerWnd, WM_COMMAND, item->wID, 0 );
|
---|
2199 | }
|
---|
2200 | return item->wID;
|
---|
2201 | }
|
---|
2202 | }
|
---|
2203 | else
|
---|
2204 | pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hMenu, TRUE, wFlags,&pmt->pt);
|
---|
2205 |
|
---|
2206 | return -1;
|
---|
2207 | }
|
---|
2208 |
|
---|
2209 | /***********************************************************************
|
---|
2210 | * MENU_SwitchTracking
|
---|
2211 | *
|
---|
2212 | * Helper function for menu navigation routines.
|
---|
2213 | */
|
---|
2214 | static void MENU_SwitchTracking( MTRACKER* pmt, HMENU hPtMenu, UINT id )
|
---|
2215 | {
|
---|
2216 | POPUPMENU *ptmenu = MENU_GetMenu(hPtMenu);
|
---|
2217 | POPUPMENU *topmenu = MENU_GetMenu(pmt->hTopMenu);
|
---|
2218 |
|
---|
2219 | //TRACE("%p hmenu=0x%04x 0x%04x\n", pmt, hPtMenu, id);
|
---|
2220 |
|
---|
2221 | if( pmt->hTopMenu != hPtMenu &&
|
---|
2222 | !((ptmenu->wFlags | topmenu->wFlags) & MF_POPUP) )
|
---|
2223 | {
|
---|
2224 | /* both are top level menus (system and menu-bar) */
|
---|
2225 | MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
|
---|
2226 | MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, NO_SELECTED_ITEM, FALSE, 0 );
|
---|
2227 | pmt->hTopMenu = hPtMenu;
|
---|
2228 | }
|
---|
2229 | else MENU_HideSubPopups( pmt->hOwnerWnd, hPtMenu, FALSE );
|
---|
2230 | MENU_SelectItem( pmt->hOwnerWnd, hPtMenu, id, TRUE, 0 );
|
---|
2231 | }
|
---|
2232 |
|
---|
2233 |
|
---|
2234 | /***********************************************************************
|
---|
2235 | * MENU_ButtonDown
|
---|
2236 | *
|
---|
2237 | * Return TRUE if we can go on with menu tracking.
|
---|
2238 | */
|
---|
2239 | static BOOL MENU_ButtonDown( MTRACKER* pmt, HMENU hPtMenu, UINT wFlags )
|
---|
2240 | {
|
---|
2241 | //TRACE("%p hmenu=0x%04x\n", pmt, hPtMenu);
|
---|
2242 |
|
---|
2243 | if (hPtMenu)
|
---|
2244 | {
|
---|
2245 | UINT id = 0;
|
---|
2246 | POPUPMENU *ptmenu = MENU_GetMenu(hPtMenu);
|
---|
2247 | MENUITEM *item;
|
---|
2248 |
|
---|
2249 | if( IS_SYSTEM_MENU(ptmenu) )
|
---|
2250 | item = ptmenu->items;
|
---|
2251 | else
|
---|
2252 | item = MENU_FindItemByCoords( ptmenu, pmt->pt, &id );
|
---|
2253 |
|
---|
2254 | if( item )
|
---|
2255 | {
|
---|
2256 | if( ptmenu->FocusedItem != id )
|
---|
2257 | MENU_SwitchTracking( pmt, hPtMenu, id );
|
---|
2258 |
|
---|
2259 | /* If the popup menu is not already "popped" */
|
---|
2260 | if(!(item->fState & MF_MOUSESELECT ))
|
---|
2261 | {
|
---|
2262 | pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,hPtMenu,FALSE,wFlags,&pmt->pt);
|
---|
2263 | }
|
---|
2264 |
|
---|
2265 | return TRUE;
|
---|
2266 | }
|
---|
2267 | /* Else the click was on the menu bar, finish the tracking */
|
---|
2268 | }
|
---|
2269 | return FALSE;
|
---|
2270 | }
|
---|
2271 |
|
---|
2272 | /***********************************************************************
|
---|
2273 | * MENU_ButtonUp
|
---|
2274 | *
|
---|
2275 | * Return the value of MENU_ExecFocusedItem if
|
---|
2276 | * the selected item was not a popup. Else open the popup.
|
---|
2277 | * A -1 return value indicates that we go on with menu tracking.
|
---|
2278 | *
|
---|
2279 | */
|
---|
2280 | static INT MENU_ButtonUp( MTRACKER* pmt, HMENU hPtMenu, UINT wFlags)
|
---|
2281 | {
|
---|
2282 | //TRACE("%p hmenu=0x%04x\n", pmt, hPtMenu);
|
---|
2283 |
|
---|
2284 | if (hPtMenu)
|
---|
2285 | {
|
---|
2286 | UINT id = 0;
|
---|
2287 | POPUPMENU *ptmenu = MENU_GetMenu(hPtMenu);
|
---|
2288 | MENUITEM *item;
|
---|
2289 |
|
---|
2290 | if( IS_SYSTEM_MENU(ptmenu) )
|
---|
2291 | item = ptmenu->items;
|
---|
2292 | else
|
---|
2293 | item = MENU_FindItemByCoords( ptmenu, pmt->pt, &id );
|
---|
2294 |
|
---|
2295 | if( item && (ptmenu->FocusedItem == id ))
|
---|
2296 | {
|
---|
2297 | if( !(item->fType & MF_POPUP) )
|
---|
2298 | return MENU_ExecFocusedItem( pmt, hPtMenu, wFlags);
|
---|
2299 |
|
---|
2300 | /* If we are dealing with the top-level menu and that this */
|
---|
2301 | /* is a click on an already "poppped" item */
|
---|
2302 | /* Stop the menu tracking and close the opened submenus */
|
---|
2303 | if((pmt->hTopMenu == hPtMenu) && (ptmenu->bTimeToHide == TRUE))
|
---|
2304 | return 0;
|
---|
2305 | }
|
---|
2306 | ptmenu->bTimeToHide = TRUE;
|
---|
2307 | }
|
---|
2308 | return -1;
|
---|
2309 | }
|
---|
2310 |
|
---|
2311 |
|
---|
2312 | /***********************************************************************
|
---|
2313 | * MENU_MouseMove
|
---|
2314 | *
|
---|
2315 | * Return TRUE if we can go on with menu tracking.
|
---|
2316 | */
|
---|
2317 | static BOOL MENU_MouseMove( MTRACKER* pmt, HMENU hPtMenu, UINT wFlags )
|
---|
2318 | {
|
---|
2319 | UINT id = NO_SELECTED_ITEM;
|
---|
2320 | POPUPMENU *ptmenu = NULL;
|
---|
2321 |
|
---|
2322 | if( hPtMenu )
|
---|
2323 | {
|
---|
2324 | ptmenu = MENU_GetMenu(hPtMenu);
|
---|
2325 | if( IS_SYSTEM_MENU(ptmenu) )
|
---|
2326 | id = 0;
|
---|
2327 | else
|
---|
2328 | MENU_FindItemByCoords( ptmenu, pmt->pt, &id );
|
---|
2329 | }
|
---|
2330 |
|
---|
2331 | if( id == NO_SELECTED_ITEM )
|
---|
2332 | {
|
---|
2333 | MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
|
---|
2334 | NO_SELECTED_ITEM, TRUE, pmt->hTopMenu);
|
---|
2335 |
|
---|
2336 | }
|
---|
2337 | else if( ptmenu->FocusedItem != id )
|
---|
2338 | {
|
---|
2339 | MENU_SwitchTracking( pmt, hPtMenu, id );
|
---|
2340 | pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags,&pmt->pt);
|
---|
2341 | }
|
---|
2342 | return TRUE;
|
---|
2343 | }
|
---|
2344 |
|
---|
2345 |
|
---|
2346 | /***********************************************************************
|
---|
2347 | * MENU_DoNextMenu
|
---|
2348 | *
|
---|
2349 | * NOTE: WM_NEXTMENU documented in Win32 is a bit different.
|
---|
2350 | */
|
---|
2351 | static LRESULT MENU_DoNextMenu( MTRACKER* pmt, UINT vk )
|
---|
2352 | {
|
---|
2353 | POPUPMENU *menu = MENU_GetMenu(pmt->hTopMenu);
|
---|
2354 |
|
---|
2355 | if( (vk == VK_LEFT && menu->FocusedItem == 0 ) ||
|
---|
2356 | (vk == VK_RIGHT && menu->FocusedItem == menu->nItems - 1))
|
---|
2357 | {
|
---|
2358 | HMENU hNewMenu;
|
---|
2359 | HWND hNewWnd;
|
---|
2360 | UINT id = 0;
|
---|
2361 | LRESULT l = SendMessageA( pmt->hOwnerWnd, WM_NEXTMENU, vk,
|
---|
2362 | (IS_SYSTEM_MENU(menu)) ? GetSubMenu(pmt->hTopMenu,0) : pmt->hTopMenu );
|
---|
2363 |
|
---|
2364 | //TRACE("%04x [%04x] -> %04x [%04x]\n",
|
---|
2365 | // (UINT16)pmt->hCurrentMenu, (UINT16)pmt->hOwnerWnd, LOWORD(l), HIWORD(l) );
|
---|
2366 |
|
---|
2367 | if( l == 0 )
|
---|
2368 | {
|
---|
2369 | hNewWnd = pmt->hOwnerWnd;
|
---|
2370 | if( IS_SYSTEM_MENU(menu) )
|
---|
2371 | {
|
---|
2372 | /* switch to the menu bar */
|
---|
2373 |
|
---|
2374 | if( (GetWindowLongA(pmt->hOwnerWnd,GWL_STYLE) & WS_CHILD) || !getMenu(pmt->hOwnerWnd) )
|
---|
2375 | {
|
---|
2376 | return FALSE;
|
---|
2377 | }
|
---|
2378 |
|
---|
2379 | hNewMenu = getMenu(pmt->hOwnerWnd);
|
---|
2380 | if( vk == VK_LEFT )
|
---|
2381 | {
|
---|
2382 | menu = MENU_GetMenu(hNewMenu);
|
---|
2383 | id = menu->nItems - 1;
|
---|
2384 | }
|
---|
2385 | }
|
---|
2386 | else if( GetWindowLongA(pmt->hOwnerWnd,GWL_STYLE) & WS_SYSMENU )
|
---|
2387 | {
|
---|
2388 | /* switch to the system menu */
|
---|
2389 | hNewMenu = getSysMenu(pmt->hOwnerWnd);
|
---|
2390 | }
|
---|
2391 | else
|
---|
2392 | {
|
---|
2393 | return FALSE;
|
---|
2394 | }
|
---|
2395 | }
|
---|
2396 | else /* application returned a new menu to switch to */
|
---|
2397 | {
|
---|
2398 | hNewMenu = LOWORD(l); hNewWnd = HIWORD(l);
|
---|
2399 |
|
---|
2400 | if( IsMenu(hNewMenu) && IsWindow(hNewWnd) )
|
---|
2401 | {
|
---|
2402 | if( (GetWindowLongA(hNewWnd,GWL_STYLE) & WS_SYSMENU) &&
|
---|
2403 | GetSubMenu(getSysMenu(hNewWnd), 0) == hNewMenu )
|
---|
2404 | {
|
---|
2405 | /* get the real system menu */
|
---|
2406 | hNewMenu = getSysMenu(hNewWnd);
|
---|
2407 | }
|
---|
2408 | else if( (GetWindowLongA(hNewWnd,GWL_STYLE) & WS_CHILD) || (getMenu(hNewWnd) != hNewMenu) )
|
---|
2409 | {
|
---|
2410 | /* FIXME: Not sure what to do here, perhaps,
|
---|
2411 | * try to track hNewMenu as a popup? */
|
---|
2412 |
|
---|
2413 | //TRACE(" -- got confused.\n");
|
---|
2414 | return FALSE;
|
---|
2415 | }
|
---|
2416 | }
|
---|
2417 | else return FALSE;
|
---|
2418 | }
|
---|
2419 |
|
---|
2420 | if( hNewMenu != pmt->hTopMenu )
|
---|
2421 | {
|
---|
2422 | MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, NO_SELECTED_ITEM,
|
---|
2423 | FALSE, 0 );
|
---|
2424 | if( pmt->hCurrentMenu != pmt->hTopMenu )
|
---|
2425 | MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
|
---|
2426 | }
|
---|
2427 |
|
---|
2428 | if( hNewWnd != pmt->hOwnerWnd )
|
---|
2429 | {
|
---|
2430 | ReleaseCapture();
|
---|
2431 | pmt->hOwnerWnd = hNewWnd;
|
---|
2432 | SetCapture(pmt->hOwnerWnd); //SvL: Don't know if this is good enough
|
---|
2433 | //EVENT_Capture( pmt->hOwnerWnd, HTMENU ); //CB: todo
|
---|
2434 | }
|
---|
2435 |
|
---|
2436 | pmt->hTopMenu = pmt->hCurrentMenu = hNewMenu; /* all subpopups are hidden */
|
---|
2437 | MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, id, TRUE, 0 );
|
---|
2438 |
|
---|
2439 | return TRUE;
|
---|
2440 | }
|
---|
2441 | return FALSE;
|
---|
2442 | }
|
---|
2443 |
|
---|
2444 | /***********************************************************************
|
---|
2445 | * MENU_SuspendPopup
|
---|
2446 | *
|
---|
2447 | * The idea is not to show the popup if the next input message is
|
---|
2448 | * going to hide it anyway.
|
---|
2449 | */
|
---|
2450 | static BOOL MENU_SuspendPopup( MTRACKER* pmt, UINT uMsg )
|
---|
2451 | {
|
---|
2452 | MSG msg;
|
---|
2453 |
|
---|
2454 | msg.hwnd = pmt->hOwnerWnd;
|
---|
2455 |
|
---|
2456 | PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_REMOVE);
|
---|
2457 | pmt->trackFlags |= TF_SKIPREMOVE;
|
---|
2458 |
|
---|
2459 | switch( uMsg )
|
---|
2460 | {
|
---|
2461 | case WM_KEYDOWN:
|
---|
2462 | PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
|
---|
2463 | if( msg.message == WM_KEYUP || msg.message == WM_PAINT )
|
---|
2464 | {
|
---|
2465 | PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_REMOVE);
|
---|
2466 | PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
|
---|
2467 | if( msg.message == WM_KEYDOWN &&
|
---|
2468 | (msg.wParam == VK_LEFT || msg.wParam == VK_RIGHT))
|
---|
2469 | {
|
---|
2470 | pmt->trackFlags |= TF_SUSPENDPOPUP;
|
---|
2471 | return TRUE;
|
---|
2472 | }
|
---|
2473 | }
|
---|
2474 | break;
|
---|
2475 | }
|
---|
2476 |
|
---|
2477 | /* failures go through this */
|
---|
2478 | pmt->trackFlags &= ~TF_SUSPENDPOPUP;
|
---|
2479 | return FALSE;
|
---|
2480 | }
|
---|
2481 |
|
---|
2482 | /***********************************************************************
|
---|
2483 | * MENU_KeyLeft
|
---|
2484 | *
|
---|
2485 | * Handle a VK_LEFT key event in a menu.
|
---|
2486 | */
|
---|
2487 | static void MENU_KeyLeft( MTRACKER* pmt, UINT wFlags )
|
---|
2488 | {
|
---|
2489 | POPUPMENU *menu;
|
---|
2490 | HMENU hmenutmp, hmenuprev;
|
---|
2491 | UINT prevcol;
|
---|
2492 |
|
---|
2493 | hmenuprev = hmenutmp = pmt->hTopMenu;
|
---|
2494 | menu = MENU_GetMenu(hmenutmp);
|
---|
2495 |
|
---|
2496 | /* Try to move 1 column left (if possible) */
|
---|
2497 | if( (prevcol = MENU_GetStartOfPrevColumn( pmt->hCurrentMenu )) !=
|
---|
2498 | NO_SELECTED_ITEM ) {
|
---|
2499 |
|
---|
2500 | MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
|
---|
2501 | prevcol, TRUE, 0 );
|
---|
2502 | return;
|
---|
2503 | }
|
---|
2504 |
|
---|
2505 | /* close topmost popup */
|
---|
2506 | while (hmenutmp != pmt->hCurrentMenu)
|
---|
2507 | {
|
---|
2508 | hmenuprev = hmenutmp;
|
---|
2509 | hmenutmp = MENU_GetSubPopup( hmenuprev );
|
---|
2510 | }
|
---|
2511 |
|
---|
2512 | MENU_HideSubPopups( pmt->hOwnerWnd, hmenuprev, TRUE );
|
---|
2513 | pmt->hCurrentMenu = hmenuprev;
|
---|
2514 |
|
---|
2515 | if ( (hmenuprev == pmt->hTopMenu) && !(menu->wFlags & MF_POPUP) )
|
---|
2516 | {
|
---|
2517 | /* move menu bar selection if no more popups are left */
|
---|
2518 |
|
---|
2519 | if( !MENU_DoNextMenu( pmt, VK_LEFT) )
|
---|
2520 | MENU_MoveSelection( pmt->hOwnerWnd, pmt->hTopMenu, ITEM_PREV );
|
---|
2521 |
|
---|
2522 | if ( hmenuprev != hmenutmp || pmt->trackFlags & TF_SUSPENDPOPUP )
|
---|
2523 | {
|
---|
2524 | /* A sublevel menu was displayed - display the next one
|
---|
2525 | * unless there is another displacement coming up */
|
---|
2526 |
|
---|
2527 | if( !MENU_SuspendPopup( pmt, WM_KEYDOWN ) )
|
---|
2528 | pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
|
---|
2529 | pmt->hTopMenu, TRUE, wFlags,&pmt->pt);
|
---|
2530 | }
|
---|
2531 | }
|
---|
2532 | }
|
---|
2533 |
|
---|
2534 |
|
---|
2535 | /***********************************************************************
|
---|
2536 | * MENU_KeyRight
|
---|
2537 | *
|
---|
2538 | * Handle a VK_RIGHT key event in a menu.
|
---|
2539 | */
|
---|
2540 | static void MENU_KeyRight( MTRACKER* pmt, UINT wFlags )
|
---|
2541 | {
|
---|
2542 | HMENU hmenutmp;
|
---|
2543 | POPUPMENU *menu = MENU_GetMenu(pmt->hTopMenu);
|
---|
2544 | UINT nextcol;
|
---|
2545 |
|
---|
2546 | //TRACE("MENU_KeyRight called, cur %x (%s), top %x (%s).\n",
|
---|
2547 | // pmt->hCurrentMenu,
|
---|
2548 | // ((POPUPMENU *)USER_HEAP_LIN_ADDR(pmt->hCurrentMenu))->
|
---|
2549 | // items[0].text,
|
---|
2550 | // pmt->hTopMenu, menu->items[0].text );
|
---|
2551 |
|
---|
2552 | if ( (menu->wFlags & MF_POPUP) || (pmt->hCurrentMenu != pmt->hTopMenu))
|
---|
2553 | {
|
---|
2554 | /* If already displaying a popup, try to display sub-popup */
|
---|
2555 |
|
---|
2556 | hmenutmp = pmt->hCurrentMenu;
|
---|
2557 | pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hmenutmp, TRUE, wFlags,&pmt->pt);
|
---|
2558 |
|
---|
2559 | /* if subpopup was displayed then we are done */
|
---|
2560 | if (hmenutmp != pmt->hCurrentMenu) return;
|
---|
2561 | }
|
---|
2562 |
|
---|
2563 | /* Check to see if there's another column */
|
---|
2564 | if( (nextcol = MENU_GetStartOfNextColumn( pmt->hCurrentMenu )) !=
|
---|
2565 | NO_SELECTED_ITEM ) {
|
---|
2566 | //TRACE("Going to %d.\n", nextcol );
|
---|
2567 | MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
|
---|
2568 | nextcol, TRUE, 0 );
|
---|
2569 | return;
|
---|
2570 | }
|
---|
2571 |
|
---|
2572 | if (!(menu->wFlags & MF_POPUP)) /* menu bar tracking */
|
---|
2573 | {
|
---|
2574 | if( pmt->hCurrentMenu != pmt->hTopMenu )
|
---|
2575 | {
|
---|
2576 | MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
|
---|
2577 | hmenutmp = pmt->hCurrentMenu = pmt->hTopMenu;
|
---|
2578 | } else hmenutmp = 0;
|
---|
2579 |
|
---|
2580 | /* try to move to the next item */
|
---|
2581 | if( !MENU_DoNextMenu( pmt, VK_RIGHT) )
|
---|
2582 | MENU_MoveSelection( pmt->hOwnerWnd, pmt->hTopMenu, ITEM_NEXT );
|
---|
2583 |
|
---|
2584 | if( hmenutmp || pmt->trackFlags & TF_SUSPENDPOPUP )
|
---|
2585 | if( !MENU_SuspendPopup(pmt, WM_KEYDOWN) )
|
---|
2586 | pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
|
---|
2587 | pmt->hTopMenu, TRUE, wFlags,&pmt->pt);
|
---|
2588 | }
|
---|
2589 | }
|
---|
2590 |
|
---|
2591 | VOID MENU_DispatchMouseMsg(MSG *msg)
|
---|
2592 | {
|
---|
2593 | LONG hittest;
|
---|
2594 |
|
---|
2595 | hittest = SendMessageA(msg->hwnd,WM_NCHITTEST,0,MAKELONG(msg->pt.x,msg->pt.y));
|
---|
2596 | if (hittest != HTCLIENT)
|
---|
2597 | SendMessageA(msg->hwnd,msg->message+WM_NCMOUSEMOVE-WM_MOUSEMOVE,hittest,MAKELONG(msg->pt.x,msg->pt.y));
|
---|
2598 | else
|
---|
2599 | DispatchMessageA(msg);
|
---|
2600 | }
|
---|
2601 |
|
---|
2602 | /***********************************************************************
|
---|
2603 | * MENU_TrackMenu
|
---|
2604 | *
|
---|
2605 | * Menu tracking code.
|
---|
2606 | */
|
---|
2607 | static INT MENU_TrackMenu(HMENU hmenu,UINT wFlags,INT x,INT y,HWND hwnd,BOOL inMenuBar,const RECT *lprect)
|
---|
2608 | {
|
---|
2609 | MSG msg;
|
---|
2610 | POPUPMENU *menu;
|
---|
2611 | BOOL fRemove;
|
---|
2612 | INT executedMenuId = -1;
|
---|
2613 | MTRACKER mt;
|
---|
2614 | BOOL enterIdleSent = FALSE;
|
---|
2615 |
|
---|
2616 | mt.trackFlags = 0;
|
---|
2617 | mt.hCurrentMenu = hmenu;
|
---|
2618 | mt.hTopMenu = hmenu;
|
---|
2619 | mt.hOwnerWnd = hwnd;
|
---|
2620 | mt.pt.x = x;
|
---|
2621 | mt.pt.y = y;
|
---|
2622 |
|
---|
2623 | //TRACE("hmenu=0x%04x flags=0x%08x (%d,%d) hwnd=0x%04x (%d,%d)-(%d,%d)\n",
|
---|
2624 | // hmenu, wFlags, x, y, hwnd, (lprect) ? lprect->left : 0, (lprect) ? lprect->top : 0,
|
---|
2625 | // (lprect) ? lprect->right : 0, (lprect) ? lprect->bottom : 0);
|
---|
2626 |
|
---|
2627 | fEndMenu = FALSE;
|
---|
2628 | if (!(menu = MENU_GetMenu(hmenu))) return FALSE;
|
---|
2629 |
|
---|
2630 | if (wFlags & TPM_BUTTONDOWN)
|
---|
2631 | {
|
---|
2632 | /* Get the result in order to start the tracking or not */
|
---|
2633 | fRemove = MENU_ButtonDown( &mt, hmenu, wFlags );
|
---|
2634 | fEndMenu = !fRemove;
|
---|
2635 | }
|
---|
2636 |
|
---|
2637 | //EVENT_Capture( mt.hOwnerWnd, HTMENU ); //CB: todo
|
---|
2638 | //SvL: Set keyboard & mouse event capture
|
---|
2639 | SetCapture(mt.hOwnerWnd);
|
---|
2640 |
|
---|
2641 | while (!fEndMenu)
|
---|
2642 | {
|
---|
2643 | menu = MENU_GetMenu(mt.hCurrentMenu);
|
---|
2644 | msg.hwnd = (wFlags & TPM_ENTERIDLEEX && menu->wFlags & MF_POPUP) ? menu->hWnd : 0;
|
---|
2645 |
|
---|
2646 | /* we have to keep the message in the queue until it's
|
---|
2647 | * clear that menu loop is not over yet. */
|
---|
2648 | // if (!GetMessageA(&msg,msg.hwnd,0,0)) break;
|
---|
2649 | //SvL: Getting messages for only the menu delays background paints (i.e. VPBuddy logo)
|
---|
2650 | if (!GetMessageA(&msg,0,0,0)) break;
|
---|
2651 | TranslateMessage( &msg );
|
---|
2652 | mt.pt = msg.pt;
|
---|
2653 |
|
---|
2654 | if ( (msg.hwnd==menu->hWnd) || (msg.message!=WM_TIMER) )
|
---|
2655 | enterIdleSent=FALSE;
|
---|
2656 |
|
---|
2657 | fRemove = FALSE;
|
---|
2658 | if((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST))
|
---|
2659 | {
|
---|
2660 | /* Find a menu for this mouse event */
|
---|
2661 | POINT pt = msg.pt;
|
---|
2662 |
|
---|
2663 | hmenu = MENU_PtMenu(mt.hTopMenu,pt,inMenuBar);
|
---|
2664 |
|
---|
2665 | //CB: todo: Win32 dispatches at least some mouse messages!
|
---|
2666 |
|
---|
2667 | switch(msg.message)
|
---|
2668 | {
|
---|
2669 | /* no WM_NC... messages in captured state */
|
---|
2670 |
|
---|
2671 | case WM_RBUTTONDBLCLK:
|
---|
2672 | case WM_RBUTTONDOWN:
|
---|
2673 | if (!(wFlags & TPM_RIGHTBUTTON)) break;
|
---|
2674 | /* fall through */
|
---|
2675 | case WM_LBUTTONDBLCLK:
|
---|
2676 | case WM_LBUTTONDOWN:
|
---|
2677 | /* If the message belongs to the menu, removes it from the queue */
|
---|
2678 | /* Else, end menu tracking */
|
---|
2679 | fRemove = MENU_ButtonDown( &mt, hmenu, wFlags );
|
---|
2680 | fEndMenu = !fRemove;
|
---|
2681 | break;
|
---|
2682 |
|
---|
2683 | case WM_RBUTTONUP:
|
---|
2684 | if (!(wFlags & TPM_RIGHTBUTTON)) break;
|
---|
2685 | /* fall through */
|
---|
2686 | case WM_LBUTTONUP:
|
---|
2687 | /* Check if a menu was selected by the mouse */
|
---|
2688 | if (hmenu)
|
---|
2689 | {
|
---|
2690 | executedMenuId = MENU_ButtonUp( &mt, hmenu, wFlags);
|
---|
2691 |
|
---|
2692 | /* End the loop if executedMenuId is an item ID */
|
---|
2693 | /* or if the job was done (executedMenuId = 0). */
|
---|
2694 | fEndMenu = fRemove = (executedMenuId != -1);
|
---|
2695 | }
|
---|
2696 | /* No menu was selected by the mouse */
|
---|
2697 | /* if the function was called by TrackPopupMenu, continue
|
---|
2698 | with the menu tracking. If not, stop it */
|
---|
2699 | else
|
---|
2700 | fEndMenu = ((wFlags & TPM_POPUPMENU) ? FALSE : TRUE);
|
---|
2701 |
|
---|
2702 | break;
|
---|
2703 |
|
---|
2704 | case WM_MOUSEMOVE:
|
---|
2705 | /* In win95 winelook, the selected menu item must be changed every time the
|
---|
2706 | mouse moves. In Win31 winelook, the mouse button has to be held down */
|
---|
2707 |
|
---|
2708 | fEndMenu |= !MENU_MouseMove( &mt, hmenu, wFlags );
|
---|
2709 | //CB: dispatch message
|
---|
2710 | if (!fEndMenu && !hmenu) DispatchMessageA(&msg);
|
---|
2711 |
|
---|
2712 | } /* switch(msg.message) - mouse */
|
---|
2713 | }
|
---|
2714 | else if ((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST))
|
---|
2715 | {
|
---|
2716 | fRemove = TRUE; /* Keyboard messages are always removed */
|
---|
2717 | switch(msg.message)
|
---|
2718 | {
|
---|
2719 | case WM_KEYDOWN:
|
---|
2720 | switch(msg.wParam)
|
---|
2721 | {
|
---|
2722 | case VK_HOME:
|
---|
2723 | case VK_END:
|
---|
2724 | MENU_SelectItem( mt.hOwnerWnd, mt.hCurrentMenu,
|
---|
2725 | NO_SELECTED_ITEM, FALSE, 0 );
|
---|
2726 | /* fall through */
|
---|
2727 | case VK_UP:
|
---|
2728 | MENU_MoveSelection( mt.hOwnerWnd, mt.hCurrentMenu,
|
---|
2729 | (msg.wParam == VK_HOME)? ITEM_NEXT : ITEM_PREV );
|
---|
2730 | break;
|
---|
2731 |
|
---|
2732 | case VK_DOWN: /* If on menu bar, pull-down the menu */
|
---|
2733 |
|
---|
2734 | menu = MENU_GetMenu(mt.hCurrentMenu);
|
---|
2735 | if (!(menu->wFlags & MF_POPUP))
|
---|
2736 | mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, mt.hTopMenu, TRUE, wFlags,&mt.pt);
|
---|
2737 | else /* otherwise try to move selection */
|
---|
2738 | MENU_MoveSelection( mt.hOwnerWnd, mt.hCurrentMenu, ITEM_NEXT );
|
---|
2739 | break;
|
---|
2740 |
|
---|
2741 | case VK_LEFT:
|
---|
2742 | MENU_KeyLeft( &mt, wFlags );
|
---|
2743 | break;
|
---|
2744 |
|
---|
2745 | case VK_RIGHT:
|
---|
2746 | MENU_KeyRight( &mt, wFlags );
|
---|
2747 | break;
|
---|
2748 |
|
---|
2749 | case VK_ESCAPE:
|
---|
2750 | fEndMenu = TRUE;
|
---|
2751 | break;
|
---|
2752 |
|
---|
2753 | default:
|
---|
2754 | break;
|
---|
2755 | }
|
---|
2756 | break; /* WM_KEYDOWN */
|
---|
2757 |
|
---|
2758 | case WM_SYSKEYDOWN:
|
---|
2759 | switch(msg.wParam)
|
---|
2760 | {
|
---|
2761 | case VK_MENU:
|
---|
2762 | fEndMenu = TRUE;
|
---|
2763 | break;
|
---|
2764 |
|
---|
2765 | }
|
---|
2766 | break; /* WM_SYSKEYDOWN */
|
---|
2767 |
|
---|
2768 | case WM_CHAR:
|
---|
2769 | {
|
---|
2770 | UINT pos;
|
---|
2771 |
|
---|
2772 | if (msg.wParam == '\r' || msg.wParam == ' ')
|
---|
2773 | {
|
---|
2774 | executedMenuId = MENU_ExecFocusedItem(&mt,mt.hCurrentMenu, wFlags);
|
---|
2775 | fEndMenu = (executedMenuId != -1);
|
---|
2776 |
|
---|
2777 | break;
|
---|
2778 | }
|
---|
2779 |
|
---|
2780 | /* Hack to avoid control chars. */
|
---|
2781 | /* We will find a better way real soon... */
|
---|
2782 | if ((msg.wParam <= 32) || (msg.wParam >= 127)) break;
|
---|
2783 |
|
---|
2784 | pos = MENU_FindItemByKey( mt.hOwnerWnd, mt.hCurrentMenu,
|
---|
2785 | LOWORD(msg.wParam), FALSE );
|
---|
2786 | if (pos == (UINT)-2) fEndMenu = TRUE;
|
---|
2787 | else if (pos == (UINT)-1) MessageBeep(0);
|
---|
2788 | else
|
---|
2789 | {
|
---|
2790 | MENU_SelectItem( mt.hOwnerWnd, mt.hCurrentMenu, pos,
|
---|
2791 | TRUE, 0 );
|
---|
2792 | executedMenuId = MENU_ExecFocusedItem(&mt,mt.hCurrentMenu, wFlags);
|
---|
2793 | fEndMenu = (executedMenuId != -1);
|
---|
2794 | }
|
---|
2795 | }
|
---|
2796 | break;
|
---|
2797 | } /* switch(msg.message) - kbd */
|
---|
2798 | }
|
---|
2799 | else
|
---|
2800 | {
|
---|
2801 | DispatchMessageA( &msg );
|
---|
2802 | }
|
---|
2803 |
|
---|
2804 | if (!fEndMenu) fRemove = TRUE;
|
---|
2805 |
|
---|
2806 | /* finally remove message from the queue */
|
---|
2807 |
|
---|
2808 | if (fRemove && !(mt.trackFlags & TF_SKIPREMOVE) )
|
---|
2809 | PeekMessageA( &msg, 0, msg.message, msg.message, PM_REMOVE );
|
---|
2810 | else mt.trackFlags &= ~TF_SKIPREMOVE;
|
---|
2811 | }
|
---|
2812 |
|
---|
2813 | ReleaseCapture();
|
---|
2814 |
|
---|
2815 | menu = MENU_GetMenu(mt.hTopMenu);
|
---|
2816 |
|
---|
2817 | if( IsWindow( mt.hOwnerWnd ) )
|
---|
2818 | {
|
---|
2819 | MENU_HideSubPopups( mt.hOwnerWnd, mt.hTopMenu, FALSE );
|
---|
2820 |
|
---|
2821 | if (menu && menu->wFlags & MF_POPUP)
|
---|
2822 | {
|
---|
2823 | ShowWindow( menu->hWnd, SW_HIDE );
|
---|
2824 | uSubPWndLevel = 0;
|
---|
2825 | }
|
---|
2826 | MENU_SelectItem( mt.hOwnerWnd, mt.hTopMenu, NO_SELECTED_ITEM, FALSE, 0 );
|
---|
2827 | SendMessageA( mt.hOwnerWnd, WM_MENUSELECT, MAKELONG(0,0xffff), 0 );
|
---|
2828 | }
|
---|
2829 |
|
---|
2830 | /* Reset the variable for hiding menu */
|
---|
2831 | menu->bTimeToHide = FALSE;
|
---|
2832 |
|
---|
2833 | /* The return value is only used by TrackPopupMenu */
|
---|
2834 | return ((executedMenuId != -1) ? executedMenuId : 0);
|
---|
2835 | }
|
---|
2836 |
|
---|
2837 | /***********************************************************************
|
---|
2838 | * MENU_InitTracking
|
---|
2839 | */
|
---|
2840 | static BOOL MENU_InitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT wFlags)
|
---|
2841 | {
|
---|
2842 | //TRACE("hwnd=0x%04x hmenu=0x%04x\n", hWnd, hMenu);
|
---|
2843 |
|
---|
2844 | HideCaret(0);
|
---|
2845 |
|
---|
2846 | /* Send WM_ENTERMENULOOP and WM_INITMENU message only if TPM_NONOTIFY flag is not specified */
|
---|
2847 | if (!(wFlags & TPM_NONOTIFY))
|
---|
2848 | SendMessageA( hWnd, WM_ENTERMENULOOP, bPopup, 0 );
|
---|
2849 |
|
---|
2850 | SendMessageA( hWnd, WM_SETCURSOR, hWnd, HTCAPTION );
|
---|
2851 |
|
---|
2852 | if (!(wFlags & TPM_NONOTIFY))
|
---|
2853 | SendMessageA( hWnd, WM_INITMENU, hMenu, 0 );
|
---|
2854 |
|
---|
2855 | return TRUE;
|
---|
2856 | }
|
---|
2857 | /***********************************************************************
|
---|
2858 | * MENU_ExitTracking
|
---|
2859 | */
|
---|
2860 | static BOOL MENU_ExitTracking(HWND hWnd)
|
---|
2861 | {
|
---|
2862 | //TRACE("hwnd=0x%04x\n", hWnd);
|
---|
2863 |
|
---|
2864 | SendMessageA( hWnd, WM_EXITMENULOOP, 0, 0 );
|
---|
2865 | ShowCaret(0);
|
---|
2866 | return TRUE;
|
---|
2867 | }
|
---|
2868 |
|
---|
2869 | /***********************************************************************
|
---|
2870 | * MENU_TrackMouseMenuBar
|
---|
2871 | *
|
---|
2872 | * Menu-bar tracking upon a mouse event. Called from NC_HandleSysCommand().
|
---|
2873 | */
|
---|
2874 | void MENU_TrackMouseMenuBar( HWND hWnd, INT ht, POINT pt )
|
---|
2875 | {
|
---|
2876 | HMENU hMenu = (ht == 0) ? getMenu(hWnd):getSysMenu(hWnd);
|
---|
2877 | UINT wFlags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON;
|
---|
2878 |
|
---|
2879 | //TRACE("pwnd=%p ht=0x%04x (%ld,%ld)\n", wndPtr, ht, pt.x, pt.y);
|
---|
2880 |
|
---|
2881 | if (IsMenu(hMenu))
|
---|
2882 | {
|
---|
2883 | if (ht == HTCAPTION) wFlags |= TPM_CAPTIONSYSMENU | TPM_RIGHTBUTTON;
|
---|
2884 | if (IsIconic(hWnd)) wFlags |= TPM_BOTTOMALIGN; //CB: todo: for minimized windows
|
---|
2885 |
|
---|
2886 | MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
|
---|
2887 | MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd,ht == 0, NULL );
|
---|
2888 | MENU_ExitTracking(hWnd);
|
---|
2889 | }
|
---|
2890 | }
|
---|
2891 |
|
---|
2892 |
|
---|
2893 | /***********************************************************************
|
---|
2894 | * MENU_TrackKbdMenuBar
|
---|
2895 | *
|
---|
2896 | * Menu-bar tracking upon a keyboard event. Called from NC_HandleSysCommand().
|
---|
2897 | */
|
---|
2898 | void MENU_TrackKbdMenuBar( HWND hWnd, UINT wParam, INT vkey)
|
---|
2899 | {
|
---|
2900 | UINT uItem = NO_SELECTED_ITEM;
|
---|
2901 | HMENU hTrackMenu;
|
---|
2902 | UINT wFlags = TPM_ENTERIDLEEX | TPM_LEFTALIGN | TPM_LEFTBUTTON;
|
---|
2903 |
|
---|
2904 | /* find window that has a menu */
|
---|
2905 |
|
---|
2906 | while(GetWindowLongA(hWnd,GWL_STYLE) & WS_CHILD)
|
---|
2907 | if( !(hWnd = GetParent(hWnd)) ) return;
|
---|
2908 |
|
---|
2909 | /* check if we have to track a system menu */
|
---|
2910 |
|
---|
2911 | if( (GetWindowLongA(hWnd,GWL_STYLE) & (WS_CHILD | WS_MINIMIZE)) ||
|
---|
2912 | !getMenu(hWnd) || vkey == VK_SPACE )
|
---|
2913 | {
|
---|
2914 | if( !(GetWindowLongA(hWnd,GWL_STYLE) & WS_SYSMENU) ) return;
|
---|
2915 | hTrackMenu = getSysMenu(hWnd);
|
---|
2916 | uItem = 0;
|
---|
2917 | wParam |= HTSYSMENU; /* prevent item lookup */
|
---|
2918 | }
|
---|
2919 | else
|
---|
2920 | hTrackMenu = getMenu(hWnd);
|
---|
2921 |
|
---|
2922 | if (IsMenu( hTrackMenu ))
|
---|
2923 | {
|
---|
2924 | MENU_InitTracking( hWnd, hTrackMenu, FALSE, wFlags );
|
---|
2925 |
|
---|
2926 | if( vkey && vkey != VK_SPACE )
|
---|
2927 | {
|
---|
2928 | uItem = MENU_FindItemByKey( hWnd, hTrackMenu,
|
---|
2929 | vkey, (wParam & HTSYSMENU) );
|
---|
2930 | if( uItem >= (UINT)(-2) )
|
---|
2931 | {
|
---|
2932 | if( uItem == (UINT)(-1) ) MessageBeep(0);
|
---|
2933 | hTrackMenu = 0;
|
---|
2934 | }
|
---|
2935 | }
|
---|
2936 |
|
---|
2937 | if( hTrackMenu )
|
---|
2938 | {
|
---|
2939 | MENU_SelectItem( hWnd, hTrackMenu, uItem, TRUE, 0 );
|
---|
2940 |
|
---|
2941 | if( uItem == NO_SELECTED_ITEM )
|
---|
2942 | MENU_MoveSelection( hWnd, hTrackMenu, ITEM_NEXT );
|
---|
2943 | else if( vkey )
|
---|
2944 | PostMessageA( hWnd, WM_KEYDOWN, VK_DOWN, 0L );
|
---|
2945 |
|
---|
2946 | MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hWnd,TRUE, NULL );
|
---|
2947 | }
|
---|
2948 |
|
---|
2949 | MENU_ExitTracking (hWnd);
|
---|
2950 | }
|
---|
2951 | }
|
---|
2952 |
|
---|
2953 |
|
---|
2954 | /**********************************************************************
|
---|
2955 | * TrackPopupMenu (USER32.549)
|
---|
2956 | *
|
---|
2957 | * Like the win32 API, the function return the command ID only if the
|
---|
2958 | * flag TPM_RETURNCMD is on.
|
---|
2959 | *
|
---|
2960 | */
|
---|
2961 | BOOL WINAPI TrackPopupMenu( HMENU hMenu, UINT wFlags, INT x, INT y,
|
---|
2962 | INT nReserved, HWND hWnd, const RECT *lpRect )
|
---|
2963 | {
|
---|
2964 | BOOL ret = FALSE;
|
---|
2965 |
|
---|
2966 | dprintf(("USER32: TrackPopupMenu"));
|
---|
2967 |
|
---|
2968 | MENU_InitTracking(hWnd, hMenu, TRUE, wFlags);
|
---|
2969 |
|
---|
2970 | /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */
|
---|
2971 | if (!(wFlags & TPM_NONOTIFY))
|
---|
2972 | SendMessageA( hWnd, WM_INITMENUPOPUP, hMenu, 0);
|
---|
2973 |
|
---|
2974 | if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 ))
|
---|
2975 | ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd,FALSE, lpRect );
|
---|
2976 | MENU_ExitTracking(hWnd);
|
---|
2977 |
|
---|
2978 | if( (!(wFlags & TPM_RETURNCMD)) && (ret != FALSE) )
|
---|
2979 | ret = 1;
|
---|
2980 |
|
---|
2981 | return ret;
|
---|
2982 | }
|
---|
2983 |
|
---|
2984 | /**********************************************************************
|
---|
2985 | * TrackPopupMenuEx (USER32.550)
|
---|
2986 | */
|
---|
2987 | BOOL WINAPI TrackPopupMenuEx( HMENU hMenu, UINT wFlags, INT x, INT y,
|
---|
2988 | HWND hWnd, LPTPMPARAMS lpTpm )
|
---|
2989 | {
|
---|
2990 | dprintf(("USER32: TrackPopupMenuEx"));
|
---|
2991 | //FIXME("not fully implemented\n" );
|
---|
2992 | return TrackPopupMenu( hMenu, wFlags, x, y, 0, hWnd,
|
---|
2993 | lpTpm ? &lpTpm->rcExclude : NULL );
|
---|
2994 | }
|
---|
2995 |
|
---|
2996 | /***********************************************************************
|
---|
2997 | * PopupMenuWndProc
|
---|
2998 | *
|
---|
2999 | * NOTE: Windows has totally different (and undocumented) popup wndproc.
|
---|
3000 | */
|
---|
3001 | LRESULT WINAPI PopupMenuWndProc( HWND hwnd, UINT message, WPARAM wParam,
|
---|
3002 | LPARAM lParam )
|
---|
3003 | {
|
---|
3004 | LRESULT retvalue;
|
---|
3005 |
|
---|
3006 | //TRACE("hwnd=0x%04x msg=0x%04x wp=0x%04x lp=0x%08lx\n",
|
---|
3007 | //hwnd, message, wParam, lParam);
|
---|
3008 |
|
---|
3009 | switch(message)
|
---|
3010 | {
|
---|
3011 | case WM_CREATE:
|
---|
3012 | {
|
---|
3013 | CREATESTRUCTA *cs = (CREATESTRUCTA*)lParam;
|
---|
3014 | SetWindowLongA( hwnd, 0, (LONG)cs->lpCreateParams );
|
---|
3015 | retvalue = 0;
|
---|
3016 | goto END;
|
---|
3017 | }
|
---|
3018 |
|
---|
3019 | case WM_MOUSEACTIVATE: /* We don't want to be activated */
|
---|
3020 | retvalue = MA_NOACTIVATE;
|
---|
3021 | goto END;
|
---|
3022 |
|
---|
3023 | case WM_PAINT:
|
---|
3024 | {
|
---|
3025 | PAINTSTRUCT ps;
|
---|
3026 | BeginPaint( hwnd, &ps );
|
---|
3027 | MENU_DrawPopupMenu( hwnd, ps.hdc,
|
---|
3028 | (HMENU)GetWindowLongA( hwnd, 0 ) );
|
---|
3029 | EndPaint( hwnd, &ps );
|
---|
3030 | retvalue = 0;
|
---|
3031 | goto END;
|
---|
3032 | }
|
---|
3033 | case WM_ERASEBKGND:
|
---|
3034 | retvalue = 1;
|
---|
3035 | goto END;
|
---|
3036 |
|
---|
3037 | case WM_DESTROY:
|
---|
3038 |
|
---|
3039 | /* zero out global pointer in case resident popup window
|
---|
3040 | * was somehow destroyed. */
|
---|
3041 |
|
---|
3042 | if(MENU_GetTopPopupWnd() )
|
---|
3043 | {
|
---|
3044 | if( hwnd == pTopPopupWnd )
|
---|
3045 | {
|
---|
3046 | //ERR("resident popup destroyed!\n");
|
---|
3047 |
|
---|
3048 | MENU_DestroyTopPopupWnd();
|
---|
3049 | uSubPWndLevel = 0;
|
---|
3050 | }
|
---|
3051 | else
|
---|
3052 | uSubPWndLevel--;
|
---|
3053 | MENU_ReleaseTopPopupWnd();
|
---|
3054 | }
|
---|
3055 | break;
|
---|
3056 |
|
---|
3057 | case WM_SHOWWINDOW:
|
---|
3058 |
|
---|
3059 | if( wParam )
|
---|
3060 | {
|
---|
3061 | //if( !(*(HMENU*)wndPtr->wExtra) )
|
---|
3062 | // ERR("no menu to display\n");
|
---|
3063 | }
|
---|
3064 | else
|
---|
3065 | SetWindowLongA(hwnd,0,0);
|
---|
3066 | break;
|
---|
3067 |
|
---|
3068 | case MM_SETMENUHANDLE:
|
---|
3069 |
|
---|
3070 | SetWindowLongA(hwnd,0,wParam);
|
---|
3071 | break;
|
---|
3072 |
|
---|
3073 | case MM_GETMENUHANDLE:
|
---|
3074 |
|
---|
3075 | retvalue = GetWindowLongA(hwnd,0);
|
---|
3076 | goto END;
|
---|
3077 |
|
---|
3078 | default:
|
---|
3079 | retvalue = DefWindowProcA( hwnd, message, wParam, lParam );
|
---|
3080 | goto END;
|
---|
3081 | }
|
---|
3082 | retvalue = 0;
|
---|
3083 | END:
|
---|
3084 | return retvalue;
|
---|
3085 | }
|
---|
3086 |
|
---|
3087 |
|
---|
3088 | /***********************************************************************
|
---|
3089 | * MENU_GetMenuBarHeight
|
---|
3090 | *
|
---|
3091 | * Compute the size of the menu bar height. Used by NC_HandleNCCalcSize().
|
---|
3092 | */
|
---|
3093 | UINT MENU_GetMenuBarHeight(HWND hwnd,UINT menubarWidth,INT orgX,INT orgY)
|
---|
3094 | {
|
---|
3095 | HDC hdc;
|
---|
3096 | RECT rectBar;
|
---|
3097 | LPPOPUPMENU lppop;
|
---|
3098 | UINT retvalue;
|
---|
3099 |
|
---|
3100 | //TRACE("HWND 0x%x, width %d, at (%d, %d).\n",
|
---|
3101 | // hwnd, menubarWidth, orgX, orgY );
|
---|
3102 |
|
---|
3103 | if (!(lppop = MENU_GetMenu(getMenu(hwnd))))
|
---|
3104 | {
|
---|
3105 | return 0;
|
---|
3106 | }
|
---|
3107 |
|
---|
3108 | hdc = GetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW );
|
---|
3109 | SelectObject( hdc, hMenuFont);
|
---|
3110 | SetRect(&rectBar, orgX, orgY, orgX+menubarWidth, orgY+GetSystemMetrics(SM_CYMENU));
|
---|
3111 | MENU_MenuBarCalcSize( hdc, &rectBar, lppop, hwnd );
|
---|
3112 | ReleaseDC( hwnd, hdc );
|
---|
3113 | retvalue = lppop->Height;
|
---|
3114 | return retvalue;
|
---|
3115 | }
|
---|
3116 |
|
---|
3117 |
|
---|
3118 | /*******************************************************************
|
---|
3119 | * ChangeMenu32A (USER32.23)
|
---|
3120 | */
|
---|
3121 | BOOL WINAPI ChangeMenuA( HMENU hMenu, UINT pos, LPCSTR data,
|
---|
3122 | UINT id, UINT flags )
|
---|
3123 | {
|
---|
3124 | dprintf(("USER32: ChangeMenuA"));
|
---|
3125 |
|
---|
3126 | //TRACE("menu=%08x pos=%d data=%08lx id=%08x flags=%08x\n",
|
---|
3127 | // hMenu, pos, (DWORD)data, id, flags );
|
---|
3128 | if (flags & MF_APPEND) return AppendMenuA( hMenu, flags & ~MF_APPEND,
|
---|
3129 | id, data );
|
---|
3130 | if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE);
|
---|
3131 | if (flags & MF_CHANGE) return ModifyMenuA(hMenu, pos, flags & ~MF_CHANGE,
|
---|
3132 | id, data );
|
---|
3133 | if (flags & MF_REMOVE) return RemoveMenu( hMenu,
|
---|
3134 | flags & MF_BYPOSITION ? pos : id,
|
---|
3135 | flags & ~MF_REMOVE );
|
---|
3136 | /* Default: MF_INSERT */
|
---|
3137 | return InsertMenuA( hMenu, pos, flags, id, data );
|
---|
3138 | }
|
---|
3139 |
|
---|
3140 |
|
---|
3141 | /*******************************************************************
|
---|
3142 | * ChangeMenu32W (USER32.24)
|
---|
3143 | */
|
---|
3144 | BOOL WINAPI ChangeMenuW( HMENU hMenu, UINT pos, LPCWSTR data,
|
---|
3145 | UINT id, UINT flags )
|
---|
3146 | {
|
---|
3147 | dprintf(("USER32: ChangeMenuW"));
|
---|
3148 |
|
---|
3149 | //TRACE("menu=%08x pos=%d data=%08lx id=%08x flags=%08x\n",
|
---|
3150 | // hMenu, pos, (DWORD)data, id, flags );
|
---|
3151 | if (flags & MF_APPEND) return AppendMenuW( hMenu, flags & ~MF_APPEND,
|
---|
3152 | id, data );
|
---|
3153 | if (flags & MF_DELETE) return DeleteMenu(hMenu, pos, flags & ~MF_DELETE);
|
---|
3154 | if (flags & MF_CHANGE) return ModifyMenuW(hMenu, pos, flags & ~MF_CHANGE,
|
---|
3155 | id, data );
|
---|
3156 | if (flags & MF_REMOVE) return RemoveMenu( hMenu,
|
---|
3157 | flags & MF_BYPOSITION ? pos : id,
|
---|
3158 | flags & ~MF_REMOVE );
|
---|
3159 | /* Default: MF_INSERT */
|
---|
3160 | return InsertMenuW( hMenu, pos, flags, id, data );
|
---|
3161 | }
|
---|
3162 |
|
---|
3163 |
|
---|
3164 | /*******************************************************************
|
---|
3165 | * CheckMenuItem (USER32.46)
|
---|
3166 | */
|
---|
3167 | DWORD WINAPI CheckMenuItem( HMENU hMenu, UINT id, UINT flags )
|
---|
3168 | {
|
---|
3169 | MENUITEM *item;
|
---|
3170 | DWORD ret;
|
---|
3171 |
|
---|
3172 | dprintf(("USER32: CheckMenuItem %x %x %x", hMenu, id, flags));
|
---|
3173 |
|
---|
3174 | //TRACE("menu=%04x id=%04x flags=%04x\n", hMenu, id, flags );
|
---|
3175 | if (!(item = MENU_FindItem( &hMenu, &id, flags ))) return -1;
|
---|
3176 | ret = item->fState & MF_CHECKED;
|
---|
3177 | if (flags & MF_CHECKED) item->fState |= MF_CHECKED;
|
---|
3178 | else item->fState &= ~MF_CHECKED;
|
---|
3179 | return ret;
|
---|
3180 | }
|
---|
3181 |
|
---|
3182 |
|
---|
3183 | /**********************************************************************
|
---|
3184 | * EnableMenuItem32 (USER32.170)
|
---|
3185 | */
|
---|
3186 | ULONG WINAPI EnableMenuItem( HMENU hMenu, UINT wItemID, UINT wFlags )
|
---|
3187 | {
|
---|
3188 | UINT oldflags;
|
---|
3189 | MENUITEM *item;
|
---|
3190 | POPUPMENU *menu;
|
---|
3191 |
|
---|
3192 | dprintf(("USER32: EnableMenuItem %x %x %x", hMenu, wItemID, wFlags));
|
---|
3193 |
|
---|
3194 | //TRACE("(%04x, %04X, %04X) !\n",
|
---|
3195 | // hMenu, wItemID, wFlags);
|
---|
3196 |
|
---|
3197 | /* Get the Popupmenu to access the owner menu */
|
---|
3198 | if (!(menu = MENU_GetMenu(hMenu)))
|
---|
3199 | return (UINT)-1;
|
---|
3200 |
|
---|
3201 | if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags )))
|
---|
3202 | return (UINT)-1;
|
---|
3203 |
|
---|
3204 | oldflags = item->fState & (MF_GRAYED | MF_DISABLED);
|
---|
3205 | item->fState ^= (oldflags ^ wFlags) & (MF_GRAYED | MF_DISABLED);
|
---|
3206 |
|
---|
3207 | /* In win95 if the close item in the system menu change update the close button */
|
---|
3208 | if((item->wID == SC_CLOSE) && (oldflags != wFlags))
|
---|
3209 | {
|
---|
3210 | if (menu->hSysMenuOwner != 0)
|
---|
3211 | {
|
---|
3212 | POPUPMENU* parentMenu;
|
---|
3213 |
|
---|
3214 | /* Get the parent menu to access*/
|
---|
3215 | if (!(parentMenu = MENU_GetMenu(menu->hSysMenuOwner)))
|
---|
3216 | return (UINT)-1;
|
---|
3217 |
|
---|
3218 | /* Refresh the frame to reflect the change*/
|
---|
3219 | SetWindowPos(parentMenu->hWnd, 0, 0, 0, 0, 0,
|
---|
3220 | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
|
---|
3221 | }
|
---|
3222 | }
|
---|
3223 |
|
---|
3224 | return oldflags;
|
---|
3225 | }
|
---|
3226 |
|
---|
3227 |
|
---|
3228 | /*******************************************************************
|
---|
3229 | * GetMenuString32A (USER32.268)
|
---|
3230 | */
|
---|
3231 | INT WINAPI GetMenuStringA(
|
---|
3232 | HMENU hMenu, /* [in] menuhandle */
|
---|
3233 | UINT wItemID, /* [in] menu item (dep. on wFlags) */
|
---|
3234 | LPSTR str, /* [out] outbuffer. If NULL, func returns entry length*/
|
---|
3235 | INT nMaxSiz, /* [in] length of buffer. if 0, func returns entry len*/
|
---|
3236 | UINT wFlags /* [in] MF_ flags */
|
---|
3237 | ) {
|
---|
3238 | MENUITEM *item;
|
---|
3239 |
|
---|
3240 | dprintf(("USER32: GetMenuStringA %x %d %d %x", hMenu, wItemID, nMaxSiz, wFlags));
|
---|
3241 |
|
---|
3242 | //TRACE("menu=%04x item=%04x ptr=%p len=%d flags=%04x\n",
|
---|
3243 | // hMenu, wItemID, str, nMaxSiz, wFlags );
|
---|
3244 | if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
|
---|
3245 | if (!IS_STRING_ITEM(item->fType)) return 0;
|
---|
3246 | if (!str || !nMaxSiz) return strlen(item->text);
|
---|
3247 | str[0] = '\0';
|
---|
3248 | lstrcpynA( str, item->text, nMaxSiz );
|
---|
3249 | //TRACE("returning '%s'\n", str );
|
---|
3250 | return strlen(str);
|
---|
3251 | }
|
---|
3252 |
|
---|
3253 |
|
---|
3254 | /*******************************************************************
|
---|
3255 | * GetMenuString32W (USER32.269)
|
---|
3256 | */
|
---|
3257 | INT WINAPI GetMenuStringW( HMENU hMenu, UINT wItemID,
|
---|
3258 | LPWSTR str, INT nMaxSiz, UINT wFlags )
|
---|
3259 | {
|
---|
3260 | MENUITEM *item;
|
---|
3261 |
|
---|
3262 | dprintf(("USER32: GetMenuStringW"));
|
---|
3263 |
|
---|
3264 | //TRACE("menu=%04x item=%04x ptr=%p len=%d flags=%04x\n",
|
---|
3265 | // hMenu, wItemID, str, nMaxSiz, wFlags );
|
---|
3266 | if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
|
---|
3267 | if (!IS_STRING_ITEM(item->fType)) return 0;
|
---|
3268 | if (!str || !nMaxSiz) return strlen(item->text);
|
---|
3269 | str[0] = '\0';
|
---|
3270 | lstrcpynAtoW( str, item->text, nMaxSiz );
|
---|
3271 | return lstrlenW(str);
|
---|
3272 | }
|
---|
3273 |
|
---|
3274 |
|
---|
3275 | /**********************************************************************
|
---|
3276 | * HiliteMenuItem32 (USER32.318)
|
---|
3277 | */
|
---|
3278 | BOOL WINAPI HiliteMenuItem( HWND hWnd, HMENU hMenu, UINT wItemID,
|
---|
3279 | UINT wHilite )
|
---|
3280 | {
|
---|
3281 | LPPOPUPMENU menu;
|
---|
3282 |
|
---|
3283 | dprintf(("USER32: HiliteMenuItem"));
|
---|
3284 |
|
---|
3285 | //TRACE("(%04x, %04x, %04x, %04x);\n",
|
---|
3286 | // hWnd, hMenu, wItemID, wHilite);
|
---|
3287 | if (!MENU_FindItem( &hMenu, &wItemID, wHilite )) return FALSE;
|
---|
3288 | if (!(menu = MENU_GetMenu(hMenu))) return FALSE;
|
---|
3289 | if (menu->FocusedItem == wItemID) return TRUE;
|
---|
3290 | MENU_HideSubPopups( hWnd, hMenu, FALSE );
|
---|
3291 | MENU_SelectItem( hWnd, hMenu, wItemID, TRUE, 0 );
|
---|
3292 | return TRUE;
|
---|
3293 | }
|
---|
3294 |
|
---|
3295 |
|
---|
3296 | /**********************************************************************
|
---|
3297 | * GetMenuState (USER32.267)
|
---|
3298 | */
|
---|
3299 | UINT WINAPI GetMenuState( HMENU hMenu, UINT wItemID, UINT wFlags )
|
---|
3300 | {
|
---|
3301 | MENUITEM *item;
|
---|
3302 |
|
---|
3303 | dprintf(("USER32: GetMenuState %d %d",wItemID,wFlags));
|
---|
3304 |
|
---|
3305 | //TRACE("(menu=%04x, id=%04x, flags=%04x);\n",
|
---|
3306 | // hMenu, wItemID, wFlags);
|
---|
3307 |
|
---|
3308 | if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return -1;
|
---|
3309 |
|
---|
3310 | //debug_print_menuitem (" item: ", item, "");
|
---|
3311 | if (item->fType & MF_POPUP)
|
---|
3312 | {
|
---|
3313 | POPUPMENU *menu = MENU_GetMenu(item->hSubMenu);
|
---|
3314 | if (!menu) return -1;
|
---|
3315 | else return (menu->nItems << 8) | ((item->fState|item->fType) & 0xff);
|
---|
3316 | }
|
---|
3317 | else
|
---|
3318 | {
|
---|
3319 | /* We used to (from way back then) mask the result to 0xff. */
|
---|
3320 | /* I don't know why and it seems wrong as the documented */
|
---|
3321 | /* return flag MF_SEPARATOR is outside that mask. */
|
---|
3322 | return (item->fType | item->fState);
|
---|
3323 | }
|
---|
3324 | }
|
---|
3325 |
|
---|
3326 |
|
---|
3327 | /**********************************************************************
|
---|
3328 | * GetMenuItemCount32 (USER32.262)
|
---|
3329 | */
|
---|
3330 | INT WINAPI GetMenuItemCount( HMENU hMenu )
|
---|
3331 | {
|
---|
3332 | LPPOPUPMENU menu = MENU_GetMenu(hMenu);
|
---|
3333 |
|
---|
3334 | dprintf(("USER32: GetMenuItemCount"));
|
---|
3335 |
|
---|
3336 | if (!menu) return -1;
|
---|
3337 | //TRACE("(%04x) returning %d\n",
|
---|
3338 | // hMenu, menu->nItems );
|
---|
3339 | return menu->nItems;
|
---|
3340 | }
|
---|
3341 |
|
---|
3342 | /**********************************************************************
|
---|
3343 | * GetMenuItemID32 (USER32.263)
|
---|
3344 | */
|
---|
3345 | UINT WINAPI GetMenuItemID( HMENU hMenu, INT nPos )
|
---|
3346 | {
|
---|
3347 | MENUITEM * lpmi;
|
---|
3348 |
|
---|
3349 | dprintf(("USER32: GetMenuItemID"));
|
---|
3350 |
|
---|
3351 | if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return 0;
|
---|
3352 | if (lpmi->fType & MF_POPUP) return -1;
|
---|
3353 | return lpmi->wID;
|
---|
3354 |
|
---|
3355 | }
|
---|
3356 |
|
---|
3357 | /*******************************************************************
|
---|
3358 | * InsertMenu32A (USER32.322)
|
---|
3359 | */
|
---|
3360 | BOOL WINAPI InsertMenuA( HMENU hMenu, UINT pos, UINT flags,
|
---|
3361 | UINT id, LPCSTR str )
|
---|
3362 | {
|
---|
3363 | MENUITEM *item;
|
---|
3364 |
|
---|
3365 | if (IS_STRING_ITEM(flags) && str)
|
---|
3366 | dprintf(("USER32: InsertMenuA %x %d %x %d %s", hMenu, pos, flags, id, str));
|
---|
3367 | // TRACE("hMenu %04x, pos %d, flags %08x, "
|
---|
3368 | // "id %04x, str '%s'\n",
|
---|
3369 | // hMenu, pos, flags, id, str );
|
---|
3370 | else // TRACE("hMenu %04x, pos %d, flags %08x, "
|
---|
3371 | dprintf(("USER32: InsertMenuA %x %d %x %d %x", hMenu, pos, flags, id, str));
|
---|
3372 | // "id %04x, str %08lx (not a string)\n",
|
---|
3373 | // hMenu, pos, flags, id, (DWORD)str );
|
---|
3374 |
|
---|
3375 | if (!(item = MENU_InsertItem( hMenu, pos, flags ))) return FALSE;
|
---|
3376 |
|
---|
3377 | if (!(MENU_SetItemData( item, flags, id, str )))
|
---|
3378 | {
|
---|
3379 | RemoveMenu( hMenu, pos, flags );
|
---|
3380 | return FALSE;
|
---|
3381 | }
|
---|
3382 |
|
---|
3383 | if (flags & MF_POPUP) /* Set the MF_POPUP flag on the popup-menu */
|
---|
3384 | (MENU_GetMenu((HMENU)id))->wFlags |= MF_POPUP;
|
---|
3385 |
|
---|
3386 | item->hCheckBit = item->hUnCheckBit = 0;
|
---|
3387 | return TRUE;
|
---|
3388 | }
|
---|
3389 |
|
---|
3390 |
|
---|
3391 | /*******************************************************************
|
---|
3392 | * InsertMenu32W (USER32.325)
|
---|
3393 | */
|
---|
3394 | BOOL WINAPI InsertMenuW( HMENU hMenu, UINT pos, UINT flags,
|
---|
3395 | UINT id, LPCWSTR str )
|
---|
3396 | {
|
---|
3397 | BOOL ret;
|
---|
3398 |
|
---|
3399 | if (IS_STRING_ITEM(flags) && str)
|
---|
3400 | {
|
---|
3401 | LPSTR newstr = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
3402 | ret = InsertMenuA( hMenu, pos, flags, id, newstr );
|
---|
3403 | HeapFree( GetProcessHeap(), 0, newstr );
|
---|
3404 | return ret;
|
---|
3405 | }
|
---|
3406 | else return InsertMenuA( hMenu, pos, flags, id, (LPCSTR)str );
|
---|
3407 | }
|
---|
3408 |
|
---|
3409 |
|
---|
3410 | /*******************************************************************
|
---|
3411 | * AppendMenu32A (USER32.5)
|
---|
3412 | */
|
---|
3413 | BOOL WINAPI AppendMenuA( HMENU hMenu, UINT flags,
|
---|
3414 | UINT id, LPCSTR data )
|
---|
3415 | {
|
---|
3416 | dprintf(("USER32: AppendMenuA"));
|
---|
3417 |
|
---|
3418 | return InsertMenuA( hMenu, -1, flags | MF_BYPOSITION, id, data );
|
---|
3419 | }
|
---|
3420 |
|
---|
3421 |
|
---|
3422 | /*******************************************************************
|
---|
3423 | * AppendMenu32W (USER32.6)
|
---|
3424 | */
|
---|
3425 | BOOL WINAPI AppendMenuW( HMENU hMenu, UINT flags,
|
---|
3426 | UINT id, LPCWSTR data )
|
---|
3427 | {
|
---|
3428 | dprintf(("USER32: AppendMenuW %x %x %d %x", hMenu, flags, id, data));
|
---|
3429 |
|
---|
3430 | return InsertMenuW( hMenu, -1, flags | MF_BYPOSITION, id, data );
|
---|
3431 | }
|
---|
3432 |
|
---|
3433 |
|
---|
3434 | /**********************************************************************
|
---|
3435 | * RemoveMenu (USER32.441)
|
---|
3436 | */
|
---|
3437 | BOOL WINAPI RemoveMenu( HMENU hMenu, UINT nPos, UINT wFlags )
|
---|
3438 | {
|
---|
3439 | LPPOPUPMENU menu;
|
---|
3440 | MENUITEM *item;
|
---|
3441 |
|
---|
3442 | dprintf(("USER32: RemoveMenu %x %d %x", hMenu, nPos, wFlags));
|
---|
3443 |
|
---|
3444 | //TRACE("(menu=%04x pos=%04x flags=%04x)\n",hMenu, nPos, wFlags);
|
---|
3445 | if (!(item = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE;
|
---|
3446 | if (!(menu = MENU_GetMenu(hMenu))) return FALSE;
|
---|
3447 |
|
---|
3448 | /* Remove item */
|
---|
3449 |
|
---|
3450 | MENU_FreeItemData( item );
|
---|
3451 |
|
---|
3452 | if (--menu->nItems == 0)
|
---|
3453 | {
|
---|
3454 | HeapFree(GetProcessHeap(), 0, menu->items );
|
---|
3455 | menu->items = NULL;
|
---|
3456 | }
|
---|
3457 | else
|
---|
3458 | {
|
---|
3459 | while(nPos < menu->nItems)
|
---|
3460 | {
|
---|
3461 | *item = *(item+1);
|
---|
3462 | item++;
|
---|
3463 | nPos++;
|
---|
3464 | }
|
---|
3465 | menu->items = (MENUITEM*)HeapReAlloc(GetProcessHeap(), 0, menu->items,
|
---|
3466 | menu->nItems * sizeof(MENUITEM) );
|
---|
3467 | }
|
---|
3468 | return TRUE;
|
---|
3469 | }
|
---|
3470 |
|
---|
3471 |
|
---|
3472 | /**********************************************************************
|
---|
3473 | * DeleteMenu32 (USER32.129)
|
---|
3474 | */
|
---|
3475 | BOOL WINAPI DeleteMenu( HMENU hMenu, UINT nPos, UINT wFlags )
|
---|
3476 | {
|
---|
3477 | MENUITEM *item = MENU_FindItem( &hMenu, &nPos, wFlags );
|
---|
3478 |
|
---|
3479 | dprintf(("USER32: DeleteMenu %x %d %x", hMenu, nPos, wFlags));
|
---|
3480 |
|
---|
3481 | if (!item) return FALSE;
|
---|
3482 | if (item->fType & MF_POPUP) DestroyMenu( item->hSubMenu );
|
---|
3483 | /* nPos is now the position of the item */
|
---|
3484 | RemoveMenu( hMenu, nPos, wFlags | MF_BYPOSITION );
|
---|
3485 | return TRUE;
|
---|
3486 | }
|
---|
3487 |
|
---|
3488 |
|
---|
3489 | /*******************************************************************
|
---|
3490 | * ModifyMenu32A (USER32.397)
|
---|
3491 | */
|
---|
3492 | BOOL WINAPI ModifyMenuA( HMENU hMenu, UINT pos, UINT flags,
|
---|
3493 | UINT id, LPCSTR str )
|
---|
3494 | {
|
---|
3495 | MENUITEM *item;
|
---|
3496 |
|
---|
3497 |
|
---|
3498 | if (IS_STRING_ITEM(flags))
|
---|
3499 | {
|
---|
3500 | dprintf(("USER32: ModifyMenuA, %x %d %x %d %s", hMenu, pos, flags, id, str));
|
---|
3501 | //TRACE("%04x %d %04x %04x '%s'\n",
|
---|
3502 | // hMenu, pos, flags, id, str ? str : "#NULL#" );
|
---|
3503 | if (!str) return FALSE;
|
---|
3504 | }
|
---|
3505 | else
|
---|
3506 | {
|
---|
3507 | dprintf(("USER32: ModifyMenuA, %x %d %x %d %x", hMenu, pos, flags, id, str));
|
---|
3508 | //TRACE("%04x %d %04x %04x %08lx\n",
|
---|
3509 | // hMenu, pos, flags, id, (DWORD)str );
|
---|
3510 | }
|
---|
3511 |
|
---|
3512 | if (!(item = MENU_FindItem( &hMenu, &pos, flags ))) return FALSE;
|
---|
3513 | return MENU_SetItemData( item, flags, id, str );
|
---|
3514 | }
|
---|
3515 |
|
---|
3516 |
|
---|
3517 | /*******************************************************************
|
---|
3518 | * ModifyMenu32W (USER32.398)
|
---|
3519 | */
|
---|
3520 | BOOL WINAPI ModifyMenuW( HMENU hMenu, UINT pos, UINT flags,
|
---|
3521 | UINT id, LPCWSTR str )
|
---|
3522 | {
|
---|
3523 | BOOL ret;
|
---|
3524 |
|
---|
3525 | if (IS_STRING_ITEM(flags) && str)
|
---|
3526 | {
|
---|
3527 | LPSTR newstr = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
3528 | ret = ModifyMenuA( hMenu, pos, flags, id, newstr );
|
---|
3529 | HeapFree( GetProcessHeap(), 0, newstr );
|
---|
3530 | return ret;
|
---|
3531 | }
|
---|
3532 | else return ModifyMenuA( hMenu, pos, flags, id, (LPCSTR)str );
|
---|
3533 | }
|
---|
3534 |
|
---|
3535 |
|
---|
3536 | /**********************************************************************
|
---|
3537 | * CreatePopupMenu32 (USER32.82)
|
---|
3538 | */
|
---|
3539 | HMENU WINAPI CreatePopupMenu(void)
|
---|
3540 | {
|
---|
3541 | HMENU hmenu;
|
---|
3542 | POPUPMENU *menu;
|
---|
3543 |
|
---|
3544 | dprintf(("USER32: CreatePopupMenu"));
|
---|
3545 |
|
---|
3546 | if (!(hmenu = CreateMenu())) return 0;
|
---|
3547 | menu = (POPUPMENU*)hmenu;
|
---|
3548 | menu->wFlags |= MF_POPUP;
|
---|
3549 | menu->bTimeToHide = FALSE;
|
---|
3550 | return hmenu;
|
---|
3551 | }
|
---|
3552 |
|
---|
3553 |
|
---|
3554 | /**********************************************************************
|
---|
3555 | * GetMenuCheckMarkDimensions (USER.417) (USER32.258)
|
---|
3556 | */
|
---|
3557 | DWORD WINAPI GetMenuCheckMarkDimensions(void)
|
---|
3558 | {
|
---|
3559 | dprintf(("USER32: GetMenuCheckMarkDimensions"));
|
---|
3560 |
|
---|
3561 | return MAKELONG( check_bitmap_width, check_bitmap_height );
|
---|
3562 | }
|
---|
3563 |
|
---|
3564 |
|
---|
3565 | /**********************************************************************
|
---|
3566 | * SetMenuItemBitmaps32 (USER32.490)
|
---|
3567 | */
|
---|
3568 | BOOL WINAPI SetMenuItemBitmaps(HMENU hMenu, UINT nPos, UINT wFlags,
|
---|
3569 | HBITMAP hNewUnCheck, HBITMAP hNewCheck)
|
---|
3570 | {
|
---|
3571 | MENUITEM *item;
|
---|
3572 |
|
---|
3573 | dprintf(("USER32: SetMenuItemBitmaps %x %d %x %x %x", hMenu, nPos, wFlags, hNewCheck, hNewUnCheck));
|
---|
3574 |
|
---|
3575 | //TRACE("(%04x, %04x, %04x, %04x, %04x)\n",
|
---|
3576 | // hMenu, nPos, wFlags, hNewCheck, hNewUnCheck);
|
---|
3577 | if (!(item = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE;
|
---|
3578 |
|
---|
3579 | if (!hNewCheck && !hNewUnCheck)
|
---|
3580 | {
|
---|
3581 | item->fState &= ~MF_USECHECKBITMAPS;
|
---|
3582 | }
|
---|
3583 | else /* Install new bitmaps */
|
---|
3584 | {
|
---|
3585 | item->hCheckBit = hNewCheck;
|
---|
3586 | item->hUnCheckBit = hNewUnCheck;
|
---|
3587 | item->fState |= MF_USECHECKBITMAPS;
|
---|
3588 | }
|
---|
3589 | return TRUE;
|
---|
3590 | }
|
---|
3591 |
|
---|
3592 |
|
---|
3593 | /**********************************************************************
|
---|
3594 | * CreateMenu (USER32.81)
|
---|
3595 | */
|
---|
3596 | HMENU WINAPI CreateMenu(void)
|
---|
3597 | {
|
---|
3598 | HMENU hMenu;
|
---|
3599 | LPPOPUPMENU menu;
|
---|
3600 |
|
---|
3601 | dprintf(("USER32: CreateMenu"));
|
---|
3602 |
|
---|
3603 | if (!(hMenu = (HMENU)HeapAlloc(GetProcessHeap(),0,sizeof(POPUPMENU)))) return 0;
|
---|
3604 | menu = (LPPOPUPMENU)hMenu;
|
---|
3605 |
|
---|
3606 | ZeroMemory(menu, sizeof(POPUPMENU));
|
---|
3607 | menu->wMagic = MENU_MAGIC;
|
---|
3608 | menu->FocusedItem = NO_SELECTED_ITEM;
|
---|
3609 | menu->bTimeToHide = FALSE;
|
---|
3610 |
|
---|
3611 | //TRACE("return %04x\n", hMenu );
|
---|
3612 |
|
---|
3613 | return hMenu;
|
---|
3614 | }
|
---|
3615 |
|
---|
3616 |
|
---|
3617 | /**********************************************************************
|
---|
3618 | * DestroyMenu32 (USER32.134)
|
---|
3619 | */
|
---|
3620 | BOOL WINAPI DestroyMenu( HMENU hMenu )
|
---|
3621 | {
|
---|
3622 | //TRACE("(%04x)\n", hMenu);
|
---|
3623 |
|
---|
3624 | dprintf(("USER32: DestroyMenu %x", hMenu));
|
---|
3625 |
|
---|
3626 | /* Silently ignore attempts to destroy default system popup */
|
---|
3627 |
|
---|
3628 | if (hMenu && hMenu != MENU_DefSysPopup)
|
---|
3629 | {
|
---|
3630 | LPPOPUPMENU lppop = MENU_GetMenu(hMenu);
|
---|
3631 | HWND pTPWnd = MENU_GetTopPopupWnd();
|
---|
3632 |
|
---|
3633 | if( pTPWnd && (hMenu == GetWindowLongA(pTPWnd,0)) )
|
---|
3634 | SetWindowLongA(pTPWnd,0,0);
|
---|
3635 |
|
---|
3636 | if (!IS_A_MENU(lppop)) lppop = NULL;
|
---|
3637 | if (lppop)
|
---|
3638 | {
|
---|
3639 | lppop->wMagic = 0; /* Mark it as destroyed */
|
---|
3640 |
|
---|
3641 | if ((lppop->wFlags & MF_POPUP) && lppop->hWnd &&
|
---|
3642 | (!pTPWnd || (lppop->hWnd != pTPWnd)))
|
---|
3643 | DestroyWindow( lppop->hWnd );
|
---|
3644 |
|
---|
3645 | if (lppop->items) /* recursively destroy submenus */
|
---|
3646 | {
|
---|
3647 | int i;
|
---|
3648 | MENUITEM *item = lppop->items;
|
---|
3649 | for (i = lppop->nItems; i > 0; i--, item++)
|
---|
3650 | {
|
---|
3651 | if (item->fType & MF_POPUP) DestroyMenu(item->hSubMenu);
|
---|
3652 | MENU_FreeItemData( item );
|
---|
3653 | }
|
---|
3654 | HeapFree(GetProcessHeap(), 0, lppop->items );
|
---|
3655 | }
|
---|
3656 | HeapFree(GetProcessHeap(),0,(LPVOID)hMenu);
|
---|
3657 | MENU_ReleaseTopPopupWnd();
|
---|
3658 | }
|
---|
3659 | else
|
---|
3660 | {
|
---|
3661 | MENU_ReleaseTopPopupWnd();
|
---|
3662 | return FALSE;
|
---|
3663 | }
|
---|
3664 | }
|
---|
3665 | return (hMenu != MENU_DefSysPopup);
|
---|
3666 | }
|
---|
3667 |
|
---|
3668 | /**********************************************************************
|
---|
3669 | * GetSystemMenu32 (USER32.291)
|
---|
3670 | */
|
---|
3671 | HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
|
---|
3672 | {
|
---|
3673 | HMENU retvalue = 0;
|
---|
3674 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hWnd);
|
---|
3675 |
|
---|
3676 | dprintf(("USER32: GetSystemMenu"));
|
---|
3677 |
|
---|
3678 | if (win32wnd)
|
---|
3679 | {
|
---|
3680 | HMENU hSysMenu = getSysMenu(hWnd);
|
---|
3681 | if(hSysMenu)
|
---|
3682 | {
|
---|
3683 | if( bRevert )
|
---|
3684 | {
|
---|
3685 | DestroyMenu(hSysMenu);
|
---|
3686 | hSysMenu = 0;
|
---|
3687 | setSysMenu(hWnd,hSysMenu);
|
---|
3688 | }
|
---|
3689 | else
|
---|
3690 | {
|
---|
3691 | POPUPMENU *menu = MENU_GetMenu(hSysMenu);
|
---|
3692 | if(menu)
|
---|
3693 | {
|
---|
3694 | if( menu->nItems > 0 && menu->items[0].hSubMenu == MENU_DefSysPopup )
|
---|
3695 | menu->items[0].hSubMenu = MENU_CopySysPopup();
|
---|
3696 | }
|
---|
3697 | else
|
---|
3698 | {
|
---|
3699 | //WARN("Current sys-menu (%04x) of wnd %04x is broken\n",
|
---|
3700 | // wndPtr->hSysMenu, hWnd);
|
---|
3701 | hSysMenu = 0;
|
---|
3702 | setSysMenu(hWnd,hSysMenu);
|
---|
3703 | }
|
---|
3704 | }
|
---|
3705 | }
|
---|
3706 |
|
---|
3707 | if(!hSysMenu && (GetWindowLongA(hWnd,GWL_STYLE) & WS_SYSMENU) )
|
---|
3708 | {
|
---|
3709 | hSysMenu = MENU_GetSysMenu( hWnd, (HMENU)(-1) );
|
---|
3710 | setSysMenu(hWnd,hSysMenu);
|
---|
3711 | }
|
---|
3712 |
|
---|
3713 | if( hSysMenu )
|
---|
3714 | {
|
---|
3715 | POPUPMENU *menu;
|
---|
3716 | retvalue = GetSubMenu(hSysMenu, 0);
|
---|
3717 |
|
---|
3718 | /* Store the dummy sysmenu handle to facilitate the refresh */
|
---|
3719 | /* of the close button if the SC_CLOSE item change */
|
---|
3720 | menu = MENU_GetMenu(retvalue);
|
---|
3721 | if (menu)
|
---|
3722 | menu->hSysMenuOwner = hSysMenu;
|
---|
3723 | }
|
---|
3724 | }
|
---|
3725 | return retvalue;
|
---|
3726 | }
|
---|
3727 |
|
---|
3728 |
|
---|
3729 | /*******************************************************************
|
---|
3730 | * SetSystemMenu32 (USER32.508)
|
---|
3731 | */
|
---|
3732 | BOOL WINAPI SetSystemMenu( HWND hwnd, HMENU hMenu )
|
---|
3733 | {
|
---|
3734 | Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
3735 |
|
---|
3736 | dprintf(("USER32: SetSystemMenu"));
|
---|
3737 |
|
---|
3738 | if (win32wnd)
|
---|
3739 | {
|
---|
3740 | if (win32wnd->GetSysMenu()) DestroyMenu(win32wnd->GetSysMenu());
|
---|
3741 | win32wnd->SetSysMenu(MENU_GetSysMenu( hwnd, hMenu ));
|
---|
3742 | return TRUE;
|
---|
3743 | }
|
---|
3744 | return FALSE;
|
---|
3745 | }
|
---|
3746 |
|
---|
3747 | /**********************************************************************
|
---|
3748 | * GetMenu32 (USER32.257)
|
---|
3749 | */
|
---|
3750 | HMENU WINAPI GetMenu( HWND hWnd )
|
---|
3751 | {
|
---|
3752 | HMENU retvalue;
|
---|
3753 |
|
---|
3754 | dprintf(("USER32: GetMenu %x", hWnd));
|
---|
3755 |
|
---|
3756 | if (GetWindowLongA(hWnd,GWL_STYLE) & WS_CHILD) return 0;
|
---|
3757 | else return getMenu(hWnd);
|
---|
3758 | }
|
---|
3759 |
|
---|
3760 | /**********************************************************************
|
---|
3761 | * SetMenu32 (USER32.487)
|
---|
3762 | */
|
---|
3763 | BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu )
|
---|
3764 | {
|
---|
3765 | //TRACE("(%04x, %04x);\n", hWnd, hMenu);
|
---|
3766 |
|
---|
3767 | dprintf(("USER32: SetMenu %x %x", hWnd, hMenu));
|
---|
3768 |
|
---|
3769 | if (hMenu && !IsMenu(hMenu))
|
---|
3770 | {
|
---|
3771 | //WARN("hMenu is not a menu handle\n");
|
---|
3772 | return FALSE;
|
---|
3773 | }
|
---|
3774 |
|
---|
3775 |
|
---|
3776 | if (!(GetWindowLongA(hWnd,GWL_STYLE) & WS_CHILD))
|
---|
3777 | {
|
---|
3778 | if (GetCapture() == hWnd) ReleaseCapture();
|
---|
3779 |
|
---|
3780 | setMenu(hWnd,hMenu);
|
---|
3781 | if (hMenu != 0)
|
---|
3782 | {
|
---|
3783 | LPPOPUPMENU lpmenu;
|
---|
3784 |
|
---|
3785 | if (!(lpmenu = MENU_GetMenu(hMenu)))
|
---|
3786 | {
|
---|
3787 | return FALSE;
|
---|
3788 | }
|
---|
3789 | lpmenu->hWnd = hWnd;
|
---|
3790 | lpmenu->wFlags &= ~MF_POPUP; /* Can't be a popup */
|
---|
3791 | lpmenu->Height = 0; /* Make sure we recalculate the size */
|
---|
3792 | }
|
---|
3793 | //SvL: This fixes the menu in standard mine sweeper (window isn't visible
|
---|
3794 | // when SetMenu is called)
|
---|
3795 | // if (IsWindowVisible(hWnd))
|
---|
3796 | SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
|
---|
3797 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
|
---|
3798 | return TRUE;
|
---|
3799 | }
|
---|
3800 | return FALSE;
|
---|
3801 | }
|
---|
3802 |
|
---|
3803 |
|
---|
3804 | /**********************************************************************
|
---|
3805 | * GetSubMenu32 (USER32.288)
|
---|
3806 | */
|
---|
3807 | HMENU WINAPI GetSubMenu( HMENU hMenu, INT nPos )
|
---|
3808 | {
|
---|
3809 | MENUITEM * lpmi;
|
---|
3810 |
|
---|
3811 | dprintf(("USER32: GetSubMenu %x %d", nPos));
|
---|
3812 |
|
---|
3813 | if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return 0;
|
---|
3814 | if (!(lpmi->fType & MF_POPUP)) return 0;
|
---|
3815 | return lpmi->hSubMenu;
|
---|
3816 | }
|
---|
3817 |
|
---|
3818 |
|
---|
3819 | /**********************************************************************
|
---|
3820 | * DrawMenuBar (USER32.161)
|
---|
3821 | */
|
---|
3822 | BOOL WINAPI DrawMenuBar( HWND hWnd )
|
---|
3823 | {
|
---|
3824 | LPPOPUPMENU lppop;
|
---|
3825 |
|
---|
3826 | dprintf(("USER32: DrawMenuBar %x", hWnd));
|
---|
3827 |
|
---|
3828 | if (!(GetWindowLongA(hWnd,GWL_STYLE) & WS_CHILD) && getMenu(hWnd))
|
---|
3829 | {
|
---|
3830 | lppop = MENU_GetMenu(getMenu(hWnd));
|
---|
3831 | if (lppop == NULL)
|
---|
3832 | {
|
---|
3833 | return FALSE;
|
---|
3834 | }
|
---|
3835 |
|
---|
3836 | lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */
|
---|
3837 | lppop->hwndOwner = hWnd;
|
---|
3838 | SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
|
---|
3839 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
|
---|
3840 | return TRUE;
|
---|
3841 | }
|
---|
3842 | return FALSE;
|
---|
3843 | }
|
---|
3844 |
|
---|
3845 |
|
---|
3846 | /***********************************************************************
|
---|
3847 | * EndMenu (USER.187) (USER32.175)
|
---|
3848 | */
|
---|
3849 | void WINAPI EndMenu(void)
|
---|
3850 | {
|
---|
3851 | dprintf(("USER32: EndMenu not implemented!"));
|
---|
3852 | /*
|
---|
3853 | * FIXME: NOT ENOUGH! This has to cancel menu tracking right away.
|
---|
3854 | */
|
---|
3855 |
|
---|
3856 | fEndMenu = TRUE;
|
---|
3857 | }
|
---|
3858 |
|
---|
3859 |
|
---|
3860 | /*****************************************************************
|
---|
3861 | * LoadMenu32A (USER32.370)
|
---|
3862 | */
|
---|
3863 | HMENU WINAPI LoadMenuA( HINSTANCE instance, LPCSTR name )
|
---|
3864 | {
|
---|
3865 | HRSRC hrsrc = FindResourceA( instance, name, RT_MENUA );
|
---|
3866 |
|
---|
3867 | dprintf(("USER32: LoadMenuA %x %x", instance, name));
|
---|
3868 |
|
---|
3869 | if (!hrsrc) return 0;
|
---|
3870 | return LoadMenuIndirectA( (MENUITEMTEMPLATEHEADER*)LoadResource( instance, hrsrc ));
|
---|
3871 | }
|
---|
3872 |
|
---|
3873 |
|
---|
3874 | /*****************************************************************
|
---|
3875 | * LoadMenu32W (USER32.373)
|
---|
3876 | */
|
---|
3877 | HMENU WINAPI LoadMenuW( HINSTANCE instance, LPCWSTR name )
|
---|
3878 | {
|
---|
3879 | HRSRC hrsrc = FindResourceW( instance, name, RT_MENUW );
|
---|
3880 |
|
---|
3881 | dprintf(("USER32: LoadMenuW %x %x", instance, name));
|
---|
3882 |
|
---|
3883 | if (!hrsrc) return 0;
|
---|
3884 | return LoadMenuIndirectW( (MENUITEMTEMPLATEHEADER*)LoadResource( instance, hrsrc ));
|
---|
3885 | }
|
---|
3886 |
|
---|
3887 |
|
---|
3888 | /**********************************************************************
|
---|
3889 | * LoadMenuIndirect32A (USER32.371)
|
---|
3890 | */
|
---|
3891 | HMENU WINAPI LoadMenuIndirectA(CONST MENUITEMTEMPLATEHEADER *lpMenuTemplate)
|
---|
3892 | {
|
---|
3893 | HMENU hMenu;
|
---|
3894 | WORD version, offset;
|
---|
3895 | LPCSTR p = (LPCSTR)lpMenuTemplate;
|
---|
3896 |
|
---|
3897 | dprintf(("USER32: LoadMenuIndirectA"));
|
---|
3898 |
|
---|
3899 | //TRACE("%p\n", template );
|
---|
3900 | version = GET_WORD(p);
|
---|
3901 | p += sizeof(WORD);
|
---|
3902 | switch (version)
|
---|
3903 | {
|
---|
3904 | case 0:
|
---|
3905 | offset = GET_WORD(p);
|
---|
3906 | p += sizeof(WORD) + offset;
|
---|
3907 | if (!(hMenu = CreateMenu())) return 0;
|
---|
3908 | if (!MENU_ParseResource( p, hMenu, TRUE ))
|
---|
3909 | {
|
---|
3910 | DestroyMenu( hMenu );
|
---|
3911 | return 0;
|
---|
3912 | }
|
---|
3913 | return hMenu;
|
---|
3914 | case 1:
|
---|
3915 | offset = GET_WORD(p);
|
---|
3916 | p += sizeof(WORD) + offset;
|
---|
3917 | if (!(hMenu = CreateMenu())) return 0;
|
---|
3918 | if (!MENUEX_ParseResource( p, hMenu))
|
---|
3919 | {
|
---|
3920 | DestroyMenu( hMenu );
|
---|
3921 | return 0;
|
---|
3922 | }
|
---|
3923 | return hMenu;
|
---|
3924 | default:
|
---|
3925 | //ERR("version %d not supported.\n", version);
|
---|
3926 | return 0;
|
---|
3927 | }
|
---|
3928 | }
|
---|
3929 |
|
---|
3930 |
|
---|
3931 | /**********************************************************************
|
---|
3932 | * LoadMenuIndirect32W (USER32.372)
|
---|
3933 | */
|
---|
3934 | HMENU WINAPI LoadMenuIndirectW(CONST MENUITEMTEMPLATEHEADER *lpMenuTemplate )
|
---|
3935 | {
|
---|
3936 | dprintf(("USER32: LoadMenuIndirectW"));
|
---|
3937 |
|
---|
3938 | /* FIXME: is there anything different between A and W? */
|
---|
3939 | return LoadMenuIndirectA(lpMenuTemplate);
|
---|
3940 | }
|
---|
3941 |
|
---|
3942 |
|
---|
3943 | /**********************************************************************
|
---|
3944 | * IsMenu32 (USER32.346)
|
---|
3945 | */
|
---|
3946 | BOOL WINAPI IsMenu(HMENU hmenu)
|
---|
3947 | {
|
---|
3948 | LPPOPUPMENU menu = (LPPOPUPMENU)hmenu;
|
---|
3949 |
|
---|
3950 | dprintf(("USER32: IsMenu"));
|
---|
3951 |
|
---|
3952 | return IS_A_MENU(menu);
|
---|
3953 | }
|
---|
3954 |
|
---|
3955 | /**********************************************************************
|
---|
3956 | * GetMenuItemInfo32_common
|
---|
3957 | */
|
---|
3958 |
|
---|
3959 | static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos,
|
---|
3960 | LPMENUITEMINFOA lpmii, BOOL unicode)
|
---|
3961 | {
|
---|
3962 | MENUITEM *menu = MENU_FindItem (&hmenu, &item, bypos? MF_BYPOSITION : 0);
|
---|
3963 |
|
---|
3964 | //debug_print_menuitem("GetMenuItemInfo32_common: ", menu, "");
|
---|
3965 |
|
---|
3966 | if (!menu)
|
---|
3967 | return FALSE;
|
---|
3968 |
|
---|
3969 | if (lpmii->fMask & MIIM_TYPE) {
|
---|
3970 | lpmii->fType = menu->fType;
|
---|
3971 | switch (MENU_ITEM_TYPE(menu->fType)) {
|
---|
3972 | case MF_STRING:
|
---|
3973 | if (menu->text && lpmii->dwTypeData && lpmii->cch) {
|
---|
3974 | if (unicode) {
|
---|
3975 | lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text, lpmii->cch);
|
---|
3976 | lpmii->cch = lstrlenW((LPWSTR)menu->text);
|
---|
3977 | } else {
|
---|
3978 | lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch);
|
---|
3979 | lpmii->cch = lstrlenA(menu->text);
|
---|
3980 | }
|
---|
3981 | }
|
---|
3982 | break;
|
---|
3983 | case MF_OWNERDRAW:
|
---|
3984 | case MF_BITMAP:
|
---|
3985 | lpmii->dwTypeData = menu->text;
|
---|
3986 | /* fall through */
|
---|
3987 | default:
|
---|
3988 | lpmii->cch = 0;
|
---|
3989 | }
|
---|
3990 | }
|
---|
3991 |
|
---|
3992 | if (lpmii->fMask & MIIM_STRING) {
|
---|
3993 | if (unicode) {
|
---|
3994 | lstrcpynAtoW((LPWSTR) lpmii->dwTypeData, menu->text, lpmii->cch);
|
---|
3995 | lpmii->cch = lstrlenW((LPWSTR)menu->text);
|
---|
3996 | } else {
|
---|
3997 | lstrcpynA(lpmii->dwTypeData, menu->text, lpmii->cch);
|
---|
3998 | lpmii->cch = lstrlenA(menu->text);
|
---|
3999 | }
|
---|
4000 | }
|
---|
4001 |
|
---|
4002 | if (lpmii->fMask & MIIM_FTYPE)
|
---|
4003 | lpmii->fType = menu->fType;
|
---|
4004 |
|
---|
4005 | if (lpmii->fMask & MIIM_BITMAP)
|
---|
4006 | lpmii->hbmpItem = menu->hbmpItem;
|
---|
4007 |
|
---|
4008 | if (lpmii->fMask & MIIM_STATE)
|
---|
4009 | lpmii->fState = menu->fState;
|
---|
4010 |
|
---|
4011 | if (lpmii->fMask & MIIM_ID)
|
---|
4012 | lpmii->wID = menu->wID;
|
---|
4013 |
|
---|
4014 | if (lpmii->fMask & MIIM_SUBMENU)
|
---|
4015 | lpmii->hSubMenu = menu->hSubMenu;
|
---|
4016 |
|
---|
4017 | if (lpmii->fMask & MIIM_CHECKMARKS) {
|
---|
4018 | lpmii->hbmpChecked = menu->hCheckBit;
|
---|
4019 | lpmii->hbmpUnchecked = menu->hUnCheckBit;
|
---|
4020 | }
|
---|
4021 | if (lpmii->fMask & MIIM_DATA)
|
---|
4022 | lpmii->dwItemData = menu->dwItemData;
|
---|
4023 |
|
---|
4024 | return TRUE;
|
---|
4025 | }
|
---|
4026 |
|
---|
4027 | /**********************************************************************
|
---|
4028 | * GetMenuItemInfoA (USER32.264)
|
---|
4029 | */
|
---|
4030 | BOOL WINAPI GetMenuItemInfoA( HMENU hmenu, UINT item, BOOL bypos,
|
---|
4031 | LPMENUITEMINFOA lpmii)
|
---|
4032 | {
|
---|
4033 | dprintf(("USER32: GetMenuItemInfoA"));
|
---|
4034 |
|
---|
4035 | return GetMenuItemInfo_common (hmenu, item, bypos, lpmii, FALSE);
|
---|
4036 | }
|
---|
4037 |
|
---|
4038 | /**********************************************************************
|
---|
4039 | * GetMenuItemInfoW (USER32.265)
|
---|
4040 | */
|
---|
4041 | BOOL WINAPI GetMenuItemInfoW( HMENU hmenu, UINT item, BOOL bypos,
|
---|
4042 | LPMENUITEMINFOW lpmii)
|
---|
4043 | {
|
---|
4044 | dprintf(("USER32: GetMenuItemInfoW"));
|
---|
4045 |
|
---|
4046 | return GetMenuItemInfo_common (hmenu, item, bypos,
|
---|
4047 | (LPMENUITEMINFOA)lpmii, TRUE);
|
---|
4048 | }
|
---|
4049 |
|
---|
4050 | /**********************************************************************
|
---|
4051 | * SetMenuItemInfo32_common
|
---|
4052 | */
|
---|
4053 |
|
---|
4054 | static BOOL SetMenuItemInfo_common(MENUITEM * menu,
|
---|
4055 | const MENUITEMINFOA *lpmii,
|
---|
4056 | BOOL unicode)
|
---|
4057 | {
|
---|
4058 | if (!menu) return FALSE;
|
---|
4059 |
|
---|
4060 | if (lpmii->fMask & MIIM_TYPE ) {
|
---|
4061 | /* Get rid of old string. */
|
---|
4062 | if ( IS_STRING_ITEM(menu->fType) && menu->text) {
|
---|
4063 | HeapFree(GetProcessHeap(), 0, menu->text);
|
---|
4064 | menu->text = NULL;
|
---|
4065 | }
|
---|
4066 |
|
---|
4067 | /* make only MENU_ITEM_TYPE bits in menu->fType equal lpmii->fType */
|
---|
4068 | menu->fType &= ~MENU_ITEM_TYPE(menu->fType);
|
---|
4069 | menu->fType |= MENU_ITEM_TYPE(lpmii->fType);
|
---|
4070 |
|
---|
4071 | menu->text = lpmii->dwTypeData;
|
---|
4072 |
|
---|
4073 | if (IS_STRING_ITEM(menu->fType) && menu->text) {
|
---|
4074 | if (unicode)
|
---|
4075 | menu->text = HEAP_strdupWtoA(GetProcessHeap(), 0, (LPWSTR) lpmii->dwTypeData);
|
---|
4076 | else
|
---|
4077 | menu->text = HEAP_strdupA(GetProcessHeap(), 0, lpmii->dwTypeData);
|
---|
4078 | }
|
---|
4079 | }
|
---|
4080 |
|
---|
4081 | if (lpmii->fMask & MIIM_FTYPE ) {
|
---|
4082 | /* free the string when the type is changing */
|
---|
4083 | if ( (!IS_STRING_ITEM(lpmii->fType)) && IS_STRING_ITEM(menu->fType) && menu->text) {
|
---|
4084 | HeapFree(GetProcessHeap(), 0, menu->text);
|
---|
4085 | menu->text = NULL;
|
---|
4086 | }
|
---|
4087 | menu->fType &= ~MENU_ITEM_TYPE(menu->fType);
|
---|
4088 | menu->fType |= MENU_ITEM_TYPE(lpmii->fType);
|
---|
4089 | }
|
---|
4090 |
|
---|
4091 | if (lpmii->fMask & MIIM_STRING ) {
|
---|
4092 | /* free the string when used */
|
---|
4093 | if ( IS_STRING_ITEM(menu->fType) && menu->text) {
|
---|
4094 | HeapFree(GetProcessHeap(), 0, menu->text);
|
---|
4095 | if (unicode)
|
---|
4096 | menu->text = HEAP_strdupWtoA(GetProcessHeap(), 0, (LPWSTR) lpmii->dwTypeData);
|
---|
4097 | else
|
---|
4098 | menu->text = HEAP_strdupA(GetProcessHeap(), 0, lpmii->dwTypeData);
|
---|
4099 | }
|
---|
4100 | }
|
---|
4101 |
|
---|
4102 | if (lpmii->fMask & MIIM_STATE)
|
---|
4103 | {
|
---|
4104 | /* fixme: MFS_DEFAULT do we have to reset the other menu items? */
|
---|
4105 | menu->fState = lpmii->fState;
|
---|
4106 | }
|
---|
4107 |
|
---|
4108 | if (lpmii->fMask & MIIM_ID)
|
---|
4109 | menu->wID = lpmii->wID;
|
---|
4110 |
|
---|
4111 | if (lpmii->fMask & MIIM_SUBMENU) {
|
---|
4112 | menu->hSubMenu = lpmii->hSubMenu;
|
---|
4113 | if (menu->hSubMenu) {
|
---|
4114 | POPUPMENU *subMenu = MENU_GetMenu((UINT)menu->hSubMenu);
|
---|
4115 | if (subMenu) {
|
---|
4116 | subMenu->wFlags |= MF_POPUP;
|
---|
4117 | menu->fType |= MF_POPUP;
|
---|
4118 | }
|
---|
4119 | else
|
---|
4120 | /* FIXME: Return an error ? */
|
---|
4121 | menu->fType &= ~MF_POPUP;
|
---|
4122 | }
|
---|
4123 | else
|
---|
4124 | menu->fType &= ~MF_POPUP;
|
---|
4125 | }
|
---|
4126 |
|
---|
4127 | if (lpmii->fMask & MIIM_CHECKMARKS)
|
---|
4128 | {
|
---|
4129 | menu->hCheckBit = lpmii->hbmpChecked;
|
---|
4130 | menu->hUnCheckBit = lpmii->hbmpUnchecked;
|
---|
4131 | }
|
---|
4132 | if (lpmii->fMask & MIIM_DATA)
|
---|
4133 | menu->dwItemData = lpmii->dwItemData;
|
---|
4134 |
|
---|
4135 | //debug_print_menuitem("SetMenuItemInfo32_common: ", menu, "");
|
---|
4136 | return TRUE;
|
---|
4137 | }
|
---|
4138 |
|
---|
4139 | /**********************************************************************
|
---|
4140 | * SetMenuItemInfo32A (USER32.491)
|
---|
4141 | */
|
---|
4142 | BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos,
|
---|
4143 | const MENUITEMINFOA *lpmii)
|
---|
4144 | {
|
---|
4145 | dprintf(("USER32: SetMenuItemInfoA %x %d %d %x", hmenu, item, bypos, lpmii));
|
---|
4146 |
|
---|
4147 | return SetMenuItemInfo_common(MENU_FindItem(&hmenu, &item, bypos? MF_BYPOSITION : 0),
|
---|
4148 | lpmii, FALSE);
|
---|
4149 | }
|
---|
4150 |
|
---|
4151 | /**********************************************************************
|
---|
4152 | * SetMenuItemInfo32W (USER32.492)
|
---|
4153 | */
|
---|
4154 | BOOL WINAPI SetMenuItemInfoW(HMENU hmenu, UINT item, BOOL bypos,
|
---|
4155 | const MENUITEMINFOW *lpmii)
|
---|
4156 | {
|
---|
4157 | dprintf(("USER32: SetMenuItemInfoW"));
|
---|
4158 |
|
---|
4159 | return SetMenuItemInfo_common(MENU_FindItem(&hmenu, &item, bypos? MF_BYPOSITION : 0),
|
---|
4160 | (const MENUITEMINFOA*)lpmii, TRUE);
|
---|
4161 | }
|
---|
4162 |
|
---|
4163 | /**********************************************************************
|
---|
4164 | * SetMenuDefaultItem (USER32.489)
|
---|
4165 | *
|
---|
4166 | */
|
---|
4167 | BOOL WINAPI SetMenuDefaultItem(HMENU hmenu, UINT uItem, UINT bypos)
|
---|
4168 | {
|
---|
4169 | UINT i;
|
---|
4170 | POPUPMENU *menu;
|
---|
4171 | MENUITEM *item;
|
---|
4172 |
|
---|
4173 |
|
---|
4174 | dprintf(("USER32: SetMenuDefaultItem"));
|
---|
4175 | //TRACE("(0x%x,%d,%d)\n", hmenu, uItem, bypos);
|
---|
4176 |
|
---|
4177 | if (!(menu = MENU_GetMenu(hmenu))) return FALSE;
|
---|
4178 |
|
---|
4179 | /* reset all default-item flags */
|
---|
4180 | item = menu->items;
|
---|
4181 | for (i = 0; i < menu->nItems; i++, item++)
|
---|
4182 | {
|
---|
4183 | item->fState &= ~MFS_DEFAULT;
|
---|
4184 | }
|
---|
4185 |
|
---|
4186 | /* no default item */
|
---|
4187 | if ( -1 == uItem)
|
---|
4188 | {
|
---|
4189 | return TRUE;
|
---|
4190 | }
|
---|
4191 |
|
---|
4192 | item = menu->items;
|
---|
4193 | if ( bypos )
|
---|
4194 | {
|
---|
4195 | if ( uItem >= menu->nItems ) return FALSE;
|
---|
4196 | item[uItem].fState |= MFS_DEFAULT;
|
---|
4197 | return TRUE;
|
---|
4198 | }
|
---|
4199 | else
|
---|
4200 | {
|
---|
4201 | for (i = 0; i < menu->nItems; i++, item++)
|
---|
4202 | {
|
---|
4203 | if (item->wID == uItem)
|
---|
4204 | {
|
---|
4205 | item->fState |= MFS_DEFAULT;
|
---|
4206 | return TRUE;
|
---|
4207 | }
|
---|
4208 | }
|
---|
4209 |
|
---|
4210 | }
|
---|
4211 | return FALSE;
|
---|
4212 | }
|
---|
4213 |
|
---|
4214 | /**********************************************************************
|
---|
4215 | * GetMenuDefaultItem (USER32.260)
|
---|
4216 | */
|
---|
4217 | UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags)
|
---|
4218 | {
|
---|
4219 | POPUPMENU *menu;
|
---|
4220 | MENUITEM * item;
|
---|
4221 | UINT i = 0;
|
---|
4222 |
|
---|
4223 | dprintf(("USER32: GetMenuDefaultItem"));
|
---|
4224 | //TRACE("(0x%x,%d,%d)\n", hmenu, bypos, flags);
|
---|
4225 |
|
---|
4226 | if (!(menu = MENU_GetMenu(hmenu))) return -1;
|
---|
4227 |
|
---|
4228 | /* find default item */
|
---|
4229 | item = menu->items;
|
---|
4230 |
|
---|
4231 | /* empty menu */
|
---|
4232 | if (! item) return -1;
|
---|
4233 |
|
---|
4234 | while ( !( item->fState & MFS_DEFAULT ) )
|
---|
4235 | {
|
---|
4236 | i++; item++;
|
---|
4237 | if (i >= menu->nItems ) return -1;
|
---|
4238 | }
|
---|
4239 |
|
---|
4240 | /* default: don't return disabled items */
|
---|
4241 | if ( (!(GMDI_USEDISABLED & flags)) && (item->fState & MFS_DISABLED )) return -1;
|
---|
4242 |
|
---|
4243 | /* search rekursiv when needed */
|
---|
4244 | if ( (item->fType & MF_POPUP) && (flags & GMDI_GOINTOPOPUPS) )
|
---|
4245 | {
|
---|
4246 | UINT ret;
|
---|
4247 | ret = GetMenuDefaultItem( item->hSubMenu, bypos, flags );
|
---|
4248 | if ( -1 != ret ) return ret;
|
---|
4249 |
|
---|
4250 | /* when item not found in submenu, return the popup item */
|
---|
4251 | }
|
---|
4252 | return ( bypos ) ? i : item->wID;
|
---|
4253 |
|
---|
4254 | }
|
---|
4255 |
|
---|
4256 | /**********************************************************************
|
---|
4257 | * InsertMenuItem32A (USER32.323)
|
---|
4258 | */
|
---|
4259 | BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
|
---|
4260 | const MENUITEMINFOA *lpmii)
|
---|
4261 | {
|
---|
4262 | MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
|
---|
4263 |
|
---|
4264 | dprintf(("USER32: InsertMenuItemA %x %d %d %x", hMenu, uItem, bypos, lpmii->wID));
|
---|
4265 |
|
---|
4266 | return SetMenuItemInfo_common(item, lpmii, FALSE);
|
---|
4267 | }
|
---|
4268 |
|
---|
4269 |
|
---|
4270 | /**********************************************************************
|
---|
4271 | * InsertMenuItem32W (USER32.324)
|
---|
4272 | */
|
---|
4273 | BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
|
---|
4274 | const MENUITEMINFOW *lpmii)
|
---|
4275 | {
|
---|
4276 | MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
|
---|
4277 |
|
---|
4278 | dprintf(("USER32: InsertMenuItemW"));
|
---|
4279 |
|
---|
4280 | return SetMenuItemInfo_common(item, (const MENUITEMINFOA*)lpmii, TRUE);
|
---|
4281 | }
|
---|
4282 |
|
---|
4283 | /**********************************************************************
|
---|
4284 | * CheckMenuRadioItem32 (USER32.47)
|
---|
4285 | */
|
---|
4286 |
|
---|
4287 | BOOL WINAPI CheckMenuRadioItem(HMENU hMenu,
|
---|
4288 | UINT first, UINT last, UINT check,
|
---|
4289 | UINT bypos)
|
---|
4290 | {
|
---|
4291 | MENUITEM *mifirst, *milast, *micheck;
|
---|
4292 | HMENU mfirst = hMenu, mlast = hMenu, mcheck = hMenu;
|
---|
4293 |
|
---|
4294 | dprintf(("USER32: CheckMenuRadioItem"));
|
---|
4295 | //TRACE("ox%x: %d-%d, check %d, bypos=%d\n",
|
---|
4296 | // hMenu, first, last, check, bypos);
|
---|
4297 |
|
---|
4298 | mifirst = MENU_FindItem (&mfirst, &first, bypos);
|
---|
4299 | milast = MENU_FindItem (&mlast, &last, bypos);
|
---|
4300 | micheck = MENU_FindItem (&mcheck, &check, bypos);
|
---|
4301 |
|
---|
4302 | if (mifirst == NULL || milast == NULL || micheck == NULL ||
|
---|
4303 | mifirst > milast || mfirst != mlast || mfirst != mcheck ||
|
---|
4304 | micheck > milast || micheck < mifirst)
|
---|
4305 | return FALSE;
|
---|
4306 |
|
---|
4307 | while (mifirst <= milast)
|
---|
4308 | {
|
---|
4309 | if (mifirst == micheck)
|
---|
4310 | {
|
---|
4311 | mifirst->fType |= MFT_RADIOCHECK;
|
---|
4312 | mifirst->fState |= MFS_CHECKED;
|
---|
4313 | } else {
|
---|
4314 | mifirst->fType &= ~MFT_RADIOCHECK;
|
---|
4315 | mifirst->fState &= ~MFS_CHECKED;
|
---|
4316 | }
|
---|
4317 | mifirst++;
|
---|
4318 | }
|
---|
4319 |
|
---|
4320 | return TRUE;
|
---|
4321 | }
|
---|
4322 |
|
---|
4323 | /**********************************************************************
|
---|
4324 | * GetMenuItemRect32 (USER32.266)
|
---|
4325 | *
|
---|
4326 | * ATTENTION: Here, the returned values in rect are the screen
|
---|
4327 | * coordinates of the item just like if the menu was
|
---|
4328 | * always on the upper left side of the application.
|
---|
4329 | *
|
---|
4330 | */
|
---|
4331 | BOOL WINAPI GetMenuItemRect (HWND hwnd, HMENU hMenu, UINT uItem,
|
---|
4332 | LPRECT rect)
|
---|
4333 | {
|
---|
4334 | POPUPMENU *itemMenu;
|
---|
4335 | MENUITEM *item;
|
---|
4336 | HWND referenceHwnd;
|
---|
4337 |
|
---|
4338 | //TRACE("(0x%x,0x%x,%d,%p)\n", hwnd, hMenu, uItem, rect);
|
---|
4339 |
|
---|
4340 | item = MENU_FindItem (&hMenu, &uItem, MF_BYPOSITION);
|
---|
4341 | referenceHwnd = hwnd;
|
---|
4342 |
|
---|
4343 | if(!hwnd)
|
---|
4344 | {
|
---|
4345 | itemMenu = MENU_GetMenu(hMenu);
|
---|
4346 | if (itemMenu == NULL) {
|
---|
4347 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
4348 | return FALSE;
|
---|
4349 | }
|
---|
4350 |
|
---|
4351 | if(itemMenu->hWnd == 0)
|
---|
4352 | return FALSE;
|
---|
4353 | referenceHwnd = itemMenu->hWnd;
|
---|
4354 | }
|
---|
4355 |
|
---|
4356 | if ((rect == NULL) || (item == NULL)) {
|
---|
4357 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
4358 | return FALSE;
|
---|
4359 | }
|
---|
4360 | *rect = item->rect;
|
---|
4361 |
|
---|
4362 | MapWindowPoints(referenceHwnd, 0, (LPPOINT)rect, 2);
|
---|
4363 | dprintf(("USER32: GetMenuItemRect %x %x %d (%d,%d)(%d,%d)", hwnd, hMenu, uItem, rect->left, rect->top, rect->right, rect->bottom));
|
---|
4364 |
|
---|
4365 | return TRUE;
|
---|
4366 | }
|
---|
4367 |
|
---|
4368 | /**********************************************************************
|
---|
4369 | * SetMenuInfo
|
---|
4370 | *
|
---|
4371 | * FIXME
|
---|
4372 | * MIM_APPLYTOSUBMENUS
|
---|
4373 | * actually use the items to draw the menu
|
---|
4374 | */
|
---|
4375 | BOOL WINAPI SetMenuInfo (HMENU hMenu, LPCMENUINFO lpmi)
|
---|
4376 | {
|
---|
4377 | POPUPMENU *menu;
|
---|
4378 |
|
---|
4379 | dprintf(("USER32: SetMenuInfo"));
|
---|
4380 | //TRACE("(0x%04x %p)\n", hMenu, lpmi);
|
---|
4381 |
|
---|
4382 | if (lpmi && (lpmi->cbSize==sizeof(MENUINFO)) && (menu=MENU_GetMenu(hMenu)))
|
---|
4383 | {
|
---|
4384 |
|
---|
4385 | if (lpmi->fMask & MIM_BACKGROUND)
|
---|
4386 | menu->hbrBack = lpmi->hbrBack;
|
---|
4387 |
|
---|
4388 | if (lpmi->fMask & MIM_HELPID)
|
---|
4389 | menu->dwContextHelpID = lpmi->dwContextHelpID;
|
---|
4390 |
|
---|
4391 | if (lpmi->fMask & MIM_MAXHEIGHT)
|
---|
4392 | menu->cyMax = lpmi->cyMax;
|
---|
4393 |
|
---|
4394 | if (lpmi->fMask & MIM_MENUDATA)
|
---|
4395 | menu->dwMenuData = lpmi->dwMenuData;
|
---|
4396 |
|
---|
4397 | if (lpmi->fMask & MIM_STYLE)
|
---|
4398 | menu->dwStyle = lpmi->dwStyle;
|
---|
4399 |
|
---|
4400 | return TRUE;
|
---|
4401 | }
|
---|
4402 | return FALSE;
|
---|
4403 | }
|
---|
4404 |
|
---|
4405 | /**********************************************************************
|
---|
4406 | * GetMenuInfo
|
---|
4407 | *
|
---|
4408 | * NOTES
|
---|
4409 | * win98/NT5.0
|
---|
4410 | *
|
---|
4411 | */
|
---|
4412 | BOOL WINAPI GetMenuInfo (HMENU hMenu, LPMENUINFO lpmi)
|
---|
4413 | { POPUPMENU *menu;
|
---|
4414 |
|
---|
4415 | dprintf(("USER32: GetMenuInfo"));
|
---|
4416 | //TRACE("(0x%04x %p)\n", hMenu, lpmi);
|
---|
4417 |
|
---|
4418 | if (lpmi && (menu = MENU_GetMenu(hMenu)))
|
---|
4419 | {
|
---|
4420 |
|
---|
4421 | if (lpmi->fMask & MIM_BACKGROUND)
|
---|
4422 | lpmi->hbrBack = menu->hbrBack;
|
---|
4423 |
|
---|
4424 | if (lpmi->fMask & MIM_HELPID)
|
---|
4425 | lpmi->dwContextHelpID = menu->dwContextHelpID;
|
---|
4426 |
|
---|
4427 | if (lpmi->fMask & MIM_MAXHEIGHT)
|
---|
4428 | lpmi->cyMax = menu->cyMax;
|
---|
4429 |
|
---|
4430 | if (lpmi->fMask & MIM_MENUDATA)
|
---|
4431 | lpmi->dwMenuData = menu->dwMenuData;
|
---|
4432 |
|
---|
4433 | if (lpmi->fMask & MIM_STYLE)
|
---|
4434 | lpmi->dwStyle = menu->dwStyle;
|
---|
4435 |
|
---|
4436 | return TRUE;
|
---|
4437 | }
|
---|
4438 | return FALSE;
|
---|
4439 | }
|
---|
4440 |
|
---|
4441 | /**********************************************************************
|
---|
4442 | * SetMenuContextHelpId (USER32.488)
|
---|
4443 | */
|
---|
4444 | BOOL WINAPI SetMenuContextHelpId( HMENU hMenu, DWORD dwContextHelpID)
|
---|
4445 | {
|
---|
4446 | LPPOPUPMENU menu;
|
---|
4447 |
|
---|
4448 | dprintf(("USER32: SetMenuContextHelpId"));
|
---|
4449 | //TRACE("(0x%04x 0x%08lx)\n", hMenu, dwContextHelpID);
|
---|
4450 |
|
---|
4451 | menu = MENU_GetMenu(hMenu);
|
---|
4452 | if (menu)
|
---|
4453 | {
|
---|
4454 | menu->dwContextHelpID = dwContextHelpID;
|
---|
4455 | return TRUE;
|
---|
4456 | }
|
---|
4457 | return FALSE;
|
---|
4458 | }
|
---|
4459 |
|
---|
4460 | /**********************************************************************
|
---|
4461 | * GetMenuContextHelpId (USER32.488)
|
---|
4462 | */
|
---|
4463 | DWORD WINAPI GetMenuContextHelpId( HMENU hMenu )
|
---|
4464 | {
|
---|
4465 | LPPOPUPMENU menu;
|
---|
4466 |
|
---|
4467 | dprintf(("USER32: GetMenuContextHelpId"));
|
---|
4468 | //TRACE("(0x%04x)\n", hMenu);
|
---|
4469 |
|
---|
4470 | menu = MENU_GetMenu(hMenu);
|
---|
4471 | if (menu)
|
---|
4472 | {
|
---|
4473 | return menu->dwContextHelpID;
|
---|
4474 | }
|
---|
4475 | return 0;
|
---|
4476 | }
|
---|
4477 |
|
---|
4478 | /**********************************************************************
|
---|
4479 | * MenuItemFromPoint (USER32.387)
|
---|
4480 | */
|
---|
4481 | UINT WINAPI MenuItemFromPoint(HWND hWnd, HMENU hMenu, POINT ptScreen)
|
---|
4482 | {
|
---|
4483 | dprintf(("USER32: MenuItemFromPoint not implemented!"));
|
---|
4484 | //FIXME("(0x%04x,0x%04x,(%ld,%ld)):stub\n",
|
---|
4485 | // hWnd, hMenu, ptScreen.x, ptScreen.y);
|
---|
4486 | return 0;
|
---|
4487 | }
|
---|
4488 |
|
---|
4489 | BOOL POPUPMENU_Register()
|
---|
4490 | {
|
---|
4491 | WNDCLASSA wndClass;
|
---|
4492 | BOOL rc;
|
---|
4493 |
|
---|
4494 | //SvL: Don't check this now
|
---|
4495 | // if (GlobalFindAtomA(POPUPMENUCLASSNAME)) return FALSE;
|
---|
4496 |
|
---|
4497 | ZeroMemory(&wndClass,sizeof(WNDCLASSA));
|
---|
4498 | wndClass.style = CS_GLOBALCLASS | CS_SAVEBITS;
|
---|
4499 | wndClass.lpfnWndProc = (WNDPROC)PopupMenuWndProc;
|
---|
4500 | wndClass.cbClsExtra = 0;
|
---|
4501 | wndClass.cbWndExtra = sizeof(HMENU);
|
---|
4502 | wndClass.hCursor = LoadCursorA(0,IDC_ARROWA);
|
---|
4503 | wndClass.hbrBackground = NULL_BRUSH;
|
---|
4504 | wndClass.lpszClassName = POPUPMENUCLASSNAME;
|
---|
4505 |
|
---|
4506 | rc = RegisterClassA(&wndClass);
|
---|
4507 | MENU_Init();
|
---|
4508 |
|
---|
4509 | return rc;
|
---|
4510 | }
|
---|
4511 | //******************************************************************************
|
---|
4512 | //******************************************************************************
|
---|
4513 | BOOL POPUPMENU_Unregister()
|
---|
4514 | {
|
---|
4515 | if (GlobalFindAtomA(POPUPMENUCLASSNAME))
|
---|
4516 | return UnregisterClassA(POPUPMENUCLASSNAME,(HINSTANCE)NULL);
|
---|
4517 | else return FALSE;
|
---|
4518 | }
|
---|
4519 | //******************************************************************************
|
---|
4520 | //******************************************************************************
|
---|
4521 |
|
---|