From cf4aa335c60bc259dc7861489f63865d9a9549ec Mon Sep 17 00:00:00 2001 From: Quantum Date: Tue, 12 Aug 2014 16:13:43 -0400 Subject: [PATCH] Hid piano during resizing to avoid slowness, and flickering on Aero. --- include/PianoControl.hpp | 5 ++++- src/MainWindow.cpp | 4 +++- src/PianoControl.cpp | 9 +++++++++ src/Window.cpp | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/PianoControl.hpp b/include/PianoControl.hpp index 5b6b09c..07f4632 100644 --- a/include/PianoControl.hpp +++ b/include/PianoControl.hpp @@ -35,7 +35,10 @@ public: virtual void SetKeyText(int key, LPCWSTR text); virtual LPCWSTR GetKeyText(int key); - + + virtual void DisableDraw(); + virtual void EnableDraw(); + virtual void SetBackground(HBRUSH background) { hBackground = background; } virtual HBRUSH GetBackground() { return hBackground; } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 130cccc..578e0d3 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -103,7 +103,7 @@ static LPWSTR keychars = L"\"-\0" // D5 L"]\0" // D#5 L"=\x21b5\0" // E5 - L"\x2190\0" // F5 + L"\x2190\\\0" // F5 ; static WORD frequency[] = { @@ -740,9 +740,11 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; case WM_ENTERSIZEMOVE: SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_COMPOSITED); + piano->DisableDraw(); return 0; case WM_EXITSIZEMOVE: SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) & ~WS_EX_COMPOSITED); + piano->EnableDraw(); return 0; case MMWM_NOTEID: { int note = wParam + 54; diff --git a/src/PianoControl.cpp b/src/PianoControl.cpp index bdcb5e3..e895306 100644 --- a/src/PianoControl.cpp +++ b/src/PianoControl.cpp @@ -495,6 +495,15 @@ void PianoControl::OnPaint() EndPaint(m_hwnd, &ps); } +void PianoControl::DisableDraw() { + SendMessage(m_hwnd, WM_SETREDRAW, FALSE, 0); +} + +void PianoControl::EnableDraw() { + SendMessage(m_hwnd, WM_SETREDRAW, TRUE, 0); + RedrawWindow(m_hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); +} + LRESULT PianoControl::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { diff --git a/src/Window.cpp b/src/Window.cpp index 343817c..81a9663 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -25,7 +25,7 @@ void Window::Register() wc.hInstance = GetInstance(); wc.hIcon = GetIcon(); wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = CreateSolidBrush(RGB(0xF0, 0xF0, 0xF0)); + wc.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1); wc.lpszMenuName = NULL; wc.lpszClassName = ClassName();