| 502 | } |
| 503 | |
| 504 | LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 505 | { |
| 506 | WinBFApp* app = (WinBFApp*) gBFApp; |
| 507 | |
| 508 | if (app == NULL) |
| 509 | { |
| 510 | PrintStuff(); |
| 511 | } |
| 512 | |
| 513 | switch (uMsg) |
| 514 | { |
| 515 | case WM_KEYDOWN: |
| 516 | case WM_KEYUP: |
| 517 | case WM_SYSKEYDOWN: |
| 518 | case WM_CHAR: |
| 519 | for (auto child : mChildren) |
| 520 | { |
| 521 | auto childWindow = (WinBFWindow*)child; |
| 522 | if ((childWindow->mSoftHasFocus) && (childWindow->mFlags & BFWINDOW_FAKEFOCUS)) |
| 523 | { |
| 524 | return childWindow->WindowProc(hWnd, uMsg, wParam, lParam); |
| 525 | } |
| 526 | } |
| 527 | break; |
| 528 | } |
| 529 | |
| 530 | switch (uMsg) |
| 531 | { |
| 532 | case WM_CLOSE: |
| 533 | { |
| 534 | //OutputDebugStrF("WM_CLOSE %08X NewFocus:%08X\n", hWnd, GetFocus()); |
| 535 | |
| 536 | if (mCloseQueryFunc(this) != 0) |
| 537 | gBFApp->RemoveWindow(this); |
| 538 | HWND newFocus = GetFocus(); |
| 539 | for (auto window : gBFApp->mWindowList) |
| 540 | { |
| 541 | WinBFWindow* winWindow = (WinBFWindow*)window; |
| 542 | if (winWindow->mHWnd == newFocus) |
| 543 | { |
| 544 | while (true) |
| 545 | { |
| 546 | WinBFWindow* altFocusWindow = NULL; |
| 547 | for (auto checkChild : winWindow->mChildren) |
| 548 | { |
| 549 | auto checkWinChild = (WinBFWindow*)checkChild; |
| 550 | if (checkWinChild->mFlags & BFWINDOW_FAKEFOCUS) |
| 551 | altFocusWindow = checkWinChild; |
| 552 | } |
| 553 | if (altFocusWindow == NULL) |
| 554 | break; |
| 555 | winWindow = altFocusWindow; |
| 556 | } |
| 557 | |
| 558 | winWindow->mHasFocus = true; |
| 559 | winWindow->mSoftHasFocus = true; |
| 560 | winWindow->mGotFocusFunc(winWindow); |
| 561 | } |
no test coverage detected