From 2ca1d5a9d3db64cf7beecf6d3a5c101e042586c2 Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 14 Apr 2014 20:21:32 -0400 Subject: [PATCH] That bitmap caching never worked... --- src/PianoControl.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/PianoControl.cpp b/src/PianoControl.cpp index 08f631d..89f774b 100644 --- a/src/PianoControl.cpp +++ b/src/PianoControl.cpp @@ -471,12 +471,12 @@ void PianoControl::OnPaint() if (!hMemDC) hMemDC = CreateCompatibleDC(hdc); - if (!hMemBitmap) - hMemBitmap = CreateCompatibleBitmap(hdc, cx + 50, cy + 50); - if (cx > bmx || cy > bmy) { + if (!hMemBitmap || cx > bmx || cy > bmy) { if (hMemBitmap) DeleteObject(hMemBitmap); - hMemBitmap = CreateCompatibleBitmap(hdc, cx + 50, cy + 50); + bmx = cx + 50; + bmy = cy + 50; + hMemBitmap = CreateCompatibleBitmap(hdc, bmx, bmy); } if (hMemDC && hMemBitmap) { ps.hdc = hMemDC; @@ -510,8 +510,6 @@ LRESULT PianoControl::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) InvalidateRect(m_hwnd, NULL, TRUE); return 0; case WM_LBUTTONDOWN: { - /*if (mouseDown) - return 0;*/ bool black; int internal = hitTest(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), black); int key = internalToKeyID(internal, black); @@ -521,6 +519,7 @@ LRESULT PianoControl::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) lastNote = external; lastKey = key; mouseDown = true; + SetFocus(m_hwnd); return 0; } case WM_LBUTTONUP: {