00047 {
00048
DWORD ch;
00049 ULONG_PTR cmdHitArea;
00050
UINT cmdItem;
00051 LPARAM lParam;
00052
BOOL fThreadLock =
FALSE;
00053
TL tlpwndHitArea;
00054
TL tlpwndT;
00055 POINT pt;
00056
PWND pwnd;
00057 RECT rc;
00058
00059
00060
00061
00062
00063
00064
if (ppopupmenu->
spmenu ==
NULL) {
00065 RIPMSG2(RIP_ERROR,
"xxxHandleMenuMessages NULL spmenu. pMenuSate:%p ppopupmenu:%p",
00066 pMenuState, ppopupmenu);
00067
return FALSE;
00068 }
00069
00070
00071
00072 ch = (
DWORD)lpmsg->wParam;
00073 lParam = lpmsg->lParam;
00074
00075
00076
00077
00078
00079
00080
switch (lpmsg->message) {
00081
case WM_RBUTTONDOWN:
00082
case WM_NCRBUTTONDOWN:
00083
00084
if (ppopupmenu->
fRightButton) {
00085
goto HandleButtonDown;
00086 }
00087
00088
00089
00090
case WM_RBUTTONDBLCLK:
00091
case WM_NCRBUTTONDBLCLK:
00092
00093
00094
00095
00096 pMenuState->
mnFocus =
MOUSEHOLD;
00097 cmdHitArea =
xxxMNFindWindowFromPoint(ppopupmenu, &cmdItem, MAKEPOINTS(lParam));
00098
if (cmdHitArea ==
MFMWFP_OFFMENU) {
00099
xxxMNDismiss(pMenuState);
00100
return TRUE;
00101 }
00102
00103
00104
00105
if (!pMenuState->
fModelessMenu) {
00106
xxxMNRemoveMessage(lpmsg->message, 0);
00107 }
00108
return TRUE;
00109
00110
case WM_LBUTTONDOWN:
00111
case WM_NCLBUTTONDOWN:
00112
00113
00114
00115
00116 HandleButtonDown:
00117
00118
00119
00120
00121 pMenuState->
mnFocus =
MOUSEHOLD;
00122 pMenuState->
ptMouseLast.x =
GET_X_LPARAM(lParam);
00123 pMenuState->
ptMouseLast.y =
GET_Y_LPARAM(lParam);
00124 cmdHitArea =
xxxMNFindWindowFromPoint(ppopupmenu, &cmdItem, MAKEPOINTS(lParam));
00125
00126
00127
00128
00129
00130
00131 fThreadLock =
IsMFMWFPWindow(cmdHitArea);
00132
if (fThreadLock) {
00133
ThreadLock((
PWND)cmdHitArea, &tlpwndHitArea);
00134 }
00135
00136
00137
00138
00139
00140
if (pMenuState->
fDragAndDrop) {
00141 pMenuState->
ptButtonDown = pMenuState->
ptMouseLast;
00142 pMenuState->
uButtonDownIndex = cmdItem;
00143
LockMFMWFPWindow(&pMenuState->
uButtonDownHitArea, cmdHitArea);
00144 }
00145
00146
00147
00148
00149
00150
00151
00152
if (pMenuState->
fDragAndDrop || pMenuState->
fModelessMenu) {
00153
if (ch & MK_RBUTTON) {
00154 pMenuState->
vkButtonDown = VK_RBUTTON;
00155 }
else {
00156 pMenuState->
vkButtonDown = VK_LBUTTON;
00157 }
00158 }
00159
00160
00161
if ((cmdHitArea ==
MFMWFP_OFFMENU) && (cmdItem == 0)) {
00162
00163
00164
00165 CancelOut:
00166
xxxMNDismiss(pMenuState);
00167
goto Unlock;
00168 }
else if (ppopupmenu->
fHasMenuBar && (cmdHitArea ==
MFMWFP_ALTMENU)) {
00169
00170
00171
00172
xxxMNSwitchToAlternateMenu(ppopupmenu);
00173 cmdHitArea =
MFMWFP_NOITEM;
00174 }
00175
00176
if (cmdHitArea ==
MFMWFP_NOITEM) {
00177
00178
00179
00180
xxxMNButtonDown(ppopupmenu, pMenuState, cmdItem, TRUE);
00181 }
else {
00182
00183 UserAssert(cmdHitArea);
00184
xxxSendMessage((
PWND)cmdHitArea, MN_BUTTONDOWN, cmdItem, 0L);
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
if (!pMenuState->
fModelessMenu) {
00203
xxxMNRemoveMessage(lpmsg->message, WM_RBUTTONDOWN);
00204 }
00205
goto Unlock;
00206
00207
case WM_MOUSEMOVE:
00208
case WM_NCMOUSEMOVE:
00209
00210
00211
00212
00213
if (pMenuState->
fDragAndDrop
00214 && pMenuState->
fButtonDown
00215 && !pMenuState->
fDragging
00216 && !pMenuState->
fButtonAlwaysDown
00217 && (pMenuState->
uButtonDownHitArea !=
MFMWFP_OFFMENU)) {
00218
00219
00220
00221
00222 UserAssert(!ppopupmenu->
fFirstClick);
00223
00224
00225
00226
00227
00228 *(LPPOINT)&rc.left = pMenuState->
ptButtonDown;
00229 *(LPPOINT)&rc.right = pMenuState->
ptButtonDown;
00230
InflateRect(&rc,
SYSMET(CXDRAG),
SYSMET(CYDRAG));
00231
00232 pt.x =
GET_X_LPARAM(lParam);
00233 pt.y =
GET_Y_LPARAM(lParam);
00234
00235
00236
00237
00238
if (!
PtInRect(&rc, pt)) {
00239
00240
00241
00242
00243
00244 pwnd =
GetMenuStateWindow(pMenuState);
00245
if (pwnd !=
NULL) {
00246 pMenuState->
fDragging =
TRUE;
00247
_PostMessage(pwnd, MN_DODRAGDROP, 0, 0);
00248 }
else {
00249 RIPMSG0(RIP_ERROR,
"xxxMNMouseMove. Unble to post MN_DODGRAGDROP");
00250 }
00251 }
00252 }
00253
00254
xxxMNMouseMove(ppopupmenu, pMenuState, MAKEPOINTS(lParam));
00255
return TRUE;
00256
00257
case WM_RBUTTONUP:
00258
case WM_NCRBUTTONUP:
00259
if (ppopupmenu->
fRightButton) {
00260
goto HandleButtonUp;
00261 }
00262
00263
00264
00265
if (pMenuState->
fButtonDown) {
00266
if (!pMenuState->
fModelessMenu) {
00267
xxxMNRemoveMessage(lpmsg->message, 0);
00268 }
00269
return TRUE;
00270 }
00271
00272
00273
00274
00275
00276
00277
if ((lpmsg->message == WM_RBUTTONUP) && !ppopupmenu->
fNoNotify) {
00278
PPOPUPMENU ppopupActive;
00279
00280
if ((ppopupmenu->
spwndActivePopup !=
NULL)
00281 && (ppopupActive = ((
PMENUWND)(ppopupmenu->
spwndActivePopup))->ppopupmenu)
00282 &&
MNIsItemSelected(ppopupActive))
00283 {
00284
TL tlpwndNotify;
00285
ThreadLock( ppopupActive->
spwndNotify, &tlpwndNotify );
00286
xxxSendMessage(ppopupActive->
spwndNotify, WM_MENURBUTTONUP,
00287 ppopupActive->
posSelectedItem, (LPARAM)
PtoH(ppopupActive->
spmenu));
00288
ThreadUnlock( &tlpwndNotify );
00289 }
00290 }
00291
break;
00292
00293
case WM_LBUTTONUP:
00294
case WM_NCLBUTTONUP:
00295
00296
00297
00298
00299 HandleButtonUp:
00300
if (!pMenuState->
fButtonDown) {
00301
00302
00303
00304
00305
00306
return TRUE;
00307 }
00308
00309
00310
00311
00312
if (pMenuState->
fDragAndDrop) {
00313
00314
UnlockMFMWFPWindow(&pMenuState->
uButtonDownHitArea);
00315 pMenuState->
fDragging =
FALSE;
00316
00317
if (pMenuState->
fIgnoreButtonUp) {
00318 pMenuState->
fButtonDown =
00319 pMenuState->
fIgnoreButtonUp =
FALSE;
00320
return TRUE;
00321 }
00322 }
00323
00324
00325
00326
00327 pMenuState->
ptMouseLast.x =
GET_X_LPARAM(lParam);
00328 pMenuState->
ptMouseLast.y =
GET_Y_LPARAM(lParam);
00329 cmdHitArea =
xxxMNFindWindowFromPoint(ppopupmenu, &cmdItem, MAKEPOINTS(lParam));
00330
00331
00332
00333
00334
00335 UserAssert((cmdHitArea != MFMWFP_OFFMENU) || (cmdItem == 0));
00336 UserAssert(cmdHitArea != 0x0000FFFF);
00337
00338
00339
00340
00341
00342 fThreadLock =
IsMFMWFPWindow(cmdHitArea);
00343
if (fThreadLock) {
00344
ThreadLock((
PWND)cmdHitArea, &tlpwndHitArea);
00345 }
00346
00347
00348
if (ppopupmenu->
fHasMenuBar) {
00349
if (((cmdHitArea ==
MFMWFP_OFFMENU) && (cmdItem == 0)) ||
00350 ((cmdHitArea ==
MFMWFP_NOITEM) && ppopupmenu->
fIsSysMenu && ppopupmenu->
fToggle))
00351
00352
00353
goto CancelOut;
00354 }
else {
00355
if ((cmdHitArea ==
MFMWFP_OFFMENU) && (cmdItem == 0)) {
00356
if (!ppopupmenu->
fFirstClick) {
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
ThreadLock(ppopupmenu->
spwndPopupMenu, &tlpwndT);
00368
xxxSendMessage(ppopupmenu->
spwndPopupMenu, MN_CANCELMENUS, 0, 0);
00369
ThreadUnlock(&tlpwndT);
00370
goto Unlock;
00371 }
00372 }
00373
00374 ppopupmenu->
fFirstClick =
FALSE;
00375 }
00376
00377
if (cmdHitArea ==
MFMWFP_NOITEM) {
00378
00379
00380
00381
00382
xxxMNButtonUp(ppopupmenu, pMenuState, cmdItem, 0);
00383 }
else if ((cmdHitArea !=
MFMWFP_OFFMENU) && (cmdHitArea !=
MFMWFP_ALTMENU)) {
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
xxxSendMessage((
PWND)cmdHitArea, MN_BUTTONUP, (DWORD)cmdItem, lParam);
00397 }
else {
00398 pMenuState->
fButtonDown =
00399 pMenuState->
fButtonAlwaysDown =
FALSE;
00400 }
00401
Unlock:
00402
if (fThreadLock)
00403
ThreadUnlock(&tlpwndHitArea);
00404
return TRUE;
00405
00406
00407
case WM_LBUTTONDBLCLK:
00408
case WM_NCLBUTTONDBLCLK:
00409
00410
00411
00412
00413 pMenuState->
mnFocus =
MOUSEHOLD;
00414 cmdHitArea =
xxxMNFindWindowFromPoint(ppopupmenu, &cmdItem, MAKEPOINTS(lParam));
00415
if ((cmdHitArea ==
MFMWFP_OFFMENU) && (cmdItem == 0)) {
00416
00417
00418
xxxMNDismiss(pMenuState);
00419
return TRUE;
00420 }
else if (ppopupmenu->
fHasMenuBar && (cmdHitArea ==
MFMWFP_ALTMENU)) {
00421
00422
00423
00424
00425
xxxMNSwitchToAlternateMenu(ppopupmenu);
00426 cmdHitArea =
MFMWFP_NOITEM;
00427 }
00428
00429
if (cmdHitArea ==
MFMWFP_NOITEM)
00430
xxxMNDoubleClick(pMenuState, ppopupmenu, cmdItem);
00431
else {
00432 UserAssert(cmdHitArea);
00433
00434
ThreadLock((
PWND)cmdHitArea, &tlpwndHitArea);
00435
xxxSendMessage((
PWND)cmdHitArea, MN_DBLCLK,
00436 (DWORD)cmdItem, 0L);
00437
ThreadUnlock(&tlpwndHitArea);
00438 }
00439
return TRUE;
00440
00441
case WM_KEYDOWN:
00442
case WM_SYSKEYDOWN:
00443
00444
00445
00446
00447
if (pMenuState->
fButtonDown && (ch != VK_F1)) {
00448
00449
00450
00451
00452
if (pMenuState->
fDragging && (ch == VK_ESCAPE)) {
00453 RIPMSG0(RIP_WARNING,
"xxxHandleMenuMessages: ESC while dragging");
00454 pMenuState->
fIgnoreButtonUp =
TRUE;
00455 }
00456
00457
return TRUE;
00458 }
00459 pMenuState->
mnFocus =
KEYBDHOLD;
00460
switch (ch) {
00461
case VK_UP:
00462
case VK_DOWN:
00463
case VK_LEFT:
00464
case VK_RIGHT:
00465
case VK_RETURN:
00466
case VK_CANCEL:
00467
case VK_ESCAPE:
00468
case VK_MENU:
00469
case VK_F10:
00470
case VK_F1:
00471
if (ppopupmenu->
spwndActivePopup) {
00472
ThreadLockAlways(ppopupmenu->
spwndActivePopup, &tlpwndT);
00473
xxxSendMessage(ppopupmenu->
spwndActivePopup, lpmsg->message,
00474 ch, 0L);
00475
ThreadUnlock(&tlpwndT);
00476 }
else {
00477
xxxMNKeyDown(ppopupmenu, pMenuState, (UINT)ch);
00478 }
00479
break;
00480
00481
case VK_TAB:
00482
00483
00484
00485
00486
00487
00488
if (ppopupmenu->
fIsMenuBar && (ppopupmenu->
spwndActivePopup ==
NULL)) {
00489
xxxMNDismiss(pMenuState);
00490
return TRUE;
00491 }
00492
00493
00494
00495
00496
default:
00497 TranslateKey:
00498
if (!pMenuState->
fModelessMenu) {
00499
xxxTranslateMessage(lpmsg, 0);
00500 }
00501
break;
00502 }
00503
return TRUE;
00504
00505
case WM_CHAR:
00506
case WM_SYSCHAR:
00507
if (ppopupmenu->
spwndActivePopup) {
00508
ThreadLockAlways(ppopupmenu->
spwndActivePopup, &tlpwndT);
00509
xxxSendMessage(ppopupmenu->
spwndActivePopup, lpmsg->message,
00510 ch, 0L);
00511
ThreadUnlock(&tlpwndT);
00512 }
else {
00513
xxxMNChar(ppopupmenu, pMenuState, (UINT)ch);
00514 }
00515
return TRUE;
00516
00517
case WM_SYSKEYUP:
00518
00519
00520
00521
00522
00523
if (ch == VK_MENU || ch == VK_F10) {
00524
if (
gwinOldAppHackoMaticFlags &
WOAHACK_CHECKALTKEYSTATE) {
00525
if (
gwinOldAppHackoMaticFlags &
WOAHACK_IGNOREALTKEYDOWN) {
00526
gwinOldAppHackoMaticFlags &= ~
WOAHACK_IGNOREALTKEYDOWN;
00527
gwinOldAppHackoMaticFlags &= ~
WOAHACK_CHECKALTKEYSTATE;
00528 }
else
00529
gwinOldAppHackoMaticFlags |=
WOAHACK_IGNOREALTKEYDOWN;
00530 }
00531
00532
return TRUE;
00533 }
00534
00535
00536
00537
00538
00539
case WM_KEYUP:
00540
00541
00542
00543
00544
goto TranslateKey;
00545
00546
case WM_SYSTIMER:
00547
00548
00549
00550
00551
return TRUE;
00552
00553
default:
00554
break;
00555 }
00556
00557
#if DBG
00558
00559
00560
00561
if (!pMenuState->
fModelessMenu
00562 && !pMenuState->
fInDoDragDrop
00563 && !
ExitMenuLoop (pMenuState, ppopupmenu) ) {
00564
00565 UserAssert(
PtiCurrent()->pq->QF_flags & QF_CAPTURELOCKED);
00566 UserAssert(
PtiCurrent()->pq->spwndCapture == ppopupmenu->
spwndNotify);
00567 }
00568
#endif
00569
00570
00571
00572
00573
return FALSE;
00574 }