[MSPAINT] Avoid flickering when resizing (#5144)

- Add CPaletteWindow::OnEraseBkgnd to avoid flickering.
- Add getColorBoxRect and drawColorBox helper functions to draw a color box.
- Add CPaletteWindow::DoHitTest helper function to do a hit test.
- Improve CPaletteWindow::OnPaint by using a memory bitmap.
- Improve readability of CMainWindow::alignChildrenToMainWindow.
CORE-18867
This commit is contained in:
Katayama Hirofumi MZ 2023-03-15 07:29:25 +09:00 committed by GitHub
parent f5840df9e9
commit 44b2a46d03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 173 additions and 93 deletions

View file

@ -18,15 +18,13 @@ LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
HIMAGELIST hImageList;
HBITMAP tempBm;
int i;
TCHAR tooltips[16][30];
TCHAR tooltips[NUM_TOOLS][30];
/*
* FIXME: Unintentionally there is a line above the tool bar (hidden by y-offset).
* To prevent cropping of the buttons height has been increased from 200 to 205
*/
RECT toolbarPos = {1, -2, 1 + 50, -2 + 205};
toolbar.Create(TOOLBARCLASSNAME, m_hWnd, toolbarPos, NULL,
WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS);
/* NOTE: The horizontal line above the toolbar is hidden by CCS_NODIVIDER style. */
RECT toolbarPos = {0, 0, CX_TOOLBAR, CY_TOOLBAR};
DWORD style = WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE |
TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_NODIVIDER;
toolbar.Create(TOOLBARCLASSNAME, m_hWnd, toolbarPos, NULL, style);
hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
toolbar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM) hImageList);
tempBm = (HBITMAP) LoadImage(hProgInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0);
@ -34,7 +32,7 @@ LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
DeleteObject(tempBm);
toolbar.SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
for(i = 0; i < 16; i++)
for (i = 0; i < NUM_TOOLS; i++)
{
TBBUTTON tbbutton;
int wrapnow = 0;
@ -54,7 +52,7 @@ LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
toolbar.SendMessage(TB_CHECKBUTTON, ID_PEN, MAKELPARAM(TRUE, 0));
toolbar.SendMessage(TB_SETMAXTEXTROWS, 0, 0);
toolbar.SendMessage(TB_SETBUTTONSIZE, 0, MAKELPARAM(25, 25));
toolbar.SendMessage(TB_SETBUTTONSIZE, 0, MAKELPARAM(CXY_TB_BUTTON, CXY_TB_BUTTON));
return 0;
}