ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2023
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
139 discussions
Start a n
N
ew thread
[reactos] 01/01: [COMCTL32][USER32] EDIT: Default processing on WM_IME_SELECT/WM_IME_CONTROL (#5173)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=be518f9f5a5d1c3cc0ef7…
commit be518f9f5a5d1c3cc0ef765ca16e4f3dfd1ffbc6 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Mar 22 09:09:38 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Mar 22 09:09:38 2023 +0900 [COMCTL32][USER32] EDIT: Default processing on WM_IME_SELECT/WM_IME_CONTROL (#5173) Do default processing on WM_IME_SELECT and WM_IME_CONTROL messages in EDIT controls. CORE-11700, CORE-15289 --- dll/win32/comctl32/edit.c | 6 ++++++ win32ss/user/user32/controls/edit.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/dll/win32/comctl32/edit.c b/dll/win32/comctl32/edit.c index 15365715bb3..0a0023908a6 100644 --- a/dll/win32/comctl32/edit.c +++ b/dll/win32/comctl32/edit.c @@ -4997,9 +4997,15 @@ static LRESULT CALLBACK EDIT_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break; case WM_IME_SELECT: +#ifdef __REACTOS__ + result = DefWindowProcW(hwnd, msg, wParam, lParam); +#endif break; case WM_IME_CONTROL: +#ifdef __REACTOS__ + result = DefWindowProcW(hwnd, msg, wParam, lParam); +#endif break; case WM_IME_REQUEST: diff --git a/win32ss/user/user32/controls/edit.c b/win32ss/user/user32/controls/edit.c index 46a0ed5b8b7..419f13ff16e 100644 --- a/win32ss/user/user32/controls/edit.c +++ b/win32ss/user/user32/controls/edit.c @@ -5310,9 +5310,15 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP break; case WM_IME_SELECT: +#ifdef __REACTOS__ + result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode); +#endif break; case WM_IME_CONTROL: +#ifdef __REACTOS__ + result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode); +#endif break; case WM_IME_REQUEST:
1 year, 9 months
1
0
0
0
[reactos] 01/01: [MSPAINT] Improve CMiniatureWindow::OnPaint
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=68e6820ddf3ddf5d19c7d…
commit 68e6820ddf3ddf5d19c7d89c14964ad7f5635c95 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Mar 22 08:10:26 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Wed Mar 22 08:10:26 2023 +0900 [MSPAINT] Improve CMiniatureWindow::OnPaint CORE-18867 --- base/applications/mspaint/miniature.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/base/applications/mspaint/miniature.cpp b/base/applications/mspaint/miniature.cpp index 6df83aee49a..b9efd889a81 100644 --- a/base/applications/mspaint/miniature.cpp +++ b/base/applications/mspaint/miniature.cpp @@ -22,12 +22,14 @@ LRESULT CMiniatureWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& LRESULT CMiniatureWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - DefWindowProc(WM_PAINT, wParam, lParam); - RECT mclient; - HDC hdc; - miniature.GetClientRect(&mclient); - hdc = miniature.GetDC(); - StretchBlt(hdc, 0, 0, mclient.right, mclient.bottom, imageModel.GetDC(), 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), SRCCOPY); - miniature.ReleaseDC(hdc); + RECT rc; + GetClientRect(&rc); + + PAINTSTRUCT ps; + HDC hDC = BeginPaint(&ps); + StretchBlt(hDC, 0, 0, rc.right, rc.bottom, + imageModel.GetDC(), 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), + SRCCOPY); + EndPaint(&ps); return 0; }
1 year, 9 months
1
0
0
0
[reactos] 01/01: [UNIATA] Fix Memory leak while claiming PCI IDE controller (#5053)
by Atharva Kulkarni
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=08248e83a0babebef805a…
commit 08248e83a0babebef805a0df3bdd0d59b2e7b82e Author: Atharva Kulkarni <atharvak1910(a)gmail.com> AuthorDate: Wed Mar 22 03:31:18 2023 +0530 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Mar 22 01:01:18 2023 +0300 [UNIATA] Fix Memory leak while claiming PCI IDE controller (#5053) HalAssignSlotResources will allocate a new resource list which the caller must free. --- drivers/storage/ide/uniata/id_probe.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/storage/ide/uniata/id_probe.cpp b/drivers/storage/ide/uniata/id_probe.cpp index 1ca49d248ec..c950e6f9d8f 100644 --- a/drivers/storage/ide/uniata/id_probe.cpp +++ b/drivers/storage/ide/uniata/id_probe.cpp @@ -1941,8 +1941,11 @@ UniataClaimLegacyPCIIDE( ) { NTSTATUS status; - PCM_RESOURCE_LIST resourceList = NULL; UNICODE_STRING devname; + PCM_RESOURCE_LIST resourceList = NULL; +#ifdef __REACTOS__ + PCM_RESOURCE_LIST oldResList = NULL; +#endif KdPrint2((PRINT_PREFIX "UniataClaimLegacyPCIIDE:\n")); @@ -1970,6 +1973,10 @@ UniataClaimLegacyPCIIDE( del_do: IoDeleteDevice(BMList[i].PciIdeDevObj); BMList[i].PciIdeDevObj = NULL; +#ifdef __REACTOS__ + if (oldResList) + ExFreePool(oldResList); +#endif return status; } @@ -1977,6 +1984,10 @@ del_do: resourceList, sizeof(CM_RESOURCE_LIST)); +#ifdef __REACTOS__ + oldResList = resourceList; +#endif + // IoReportDetectedDevice() should be used for WDM OSes // TODO: check if resourceList is actually used inside HalAssignSlotResources() @@ -2006,6 +2017,11 @@ del_do: goto del_do; } +#ifdef __REACTOS__ + ExFreePool(resourceList); + ExFreePool(oldResList); +#endif + KdPrint2((PRINT_PREFIX "ok %#x\n", status)); BMList[i].ChanInitOk |= 0x80;
1 year, 9 months
1
0
0
0
[reactos] 01/01: [MSPAINT] Simplify TextEdit by using SizeBox (#5177)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cb454ef9ed19382d1e644…
commit cb454ef9ed19382d1e6449e4d7fa6cc6b8529dd6 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Mar 21 13:15:08 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Mar 21 13:15:08 2023 +0900 [MSPAINT] Simplify TextEdit by using SizeBox (#5177) Reduce source code. CORE-18867 --- base/applications/mspaint/textedit.cpp | 120 ++++++--------------------------- 1 file changed, 21 insertions(+), 99 deletions(-) diff --git a/base/applications/mspaint/textedit.cpp b/base/applications/mspaint/textedit.cpp index 80f87682e32..881a00bff6f 100644 --- a/base/applications/mspaint/textedit.cpp +++ b/base/applications/mspaint/textedit.cpp @@ -19,94 +19,28 @@ CTextEditWindow::CTextEditWindow() : m_hFont(NULL), m_hFontZoomed(NULL), m_nAppI SetRectEmpty(&m_rc); } -#define X0 rc.left -#define X1 ((rc.left + rc.right - CXY_GRIP) / 2) -#define X2 (rc.right - CXY_GRIP) -#define Y0 rc.top -#define Y1 ((rc.top + rc.bottom - CXY_GRIP) / 2) -#define Y2 (rc.bottom - CXY_GRIP) -#define RECT0 X0, Y0, X0 + CXY_GRIP, Y0 + CXY_GRIP // Upper Left -#define RECT1 X1, Y0, X1 + CXY_GRIP, Y0 + CXY_GRIP // Top -#define RECT2 X2, Y0, X2 + CXY_GRIP, Y0 + CXY_GRIP // Upper Right -#define RECT3 X0, Y1, X0 + CXY_GRIP, Y1 + CXY_GRIP // Left -#define RECT4 X2, Y1, X2 + CXY_GRIP, Y1 + CXY_GRIP // Right -#define RECT5 X0, Y2, X0 + CXY_GRIP, Y2 + CXY_GRIP // Lower Left -#define RECT6 X1, Y2, X1 + CXY_GRIP, Y2 + CXY_GRIP // Bottom -#define RECT7 X2, Y2, X2 + CXY_GRIP, Y2 + CXY_GRIP // Lower Right - INT CTextEditWindow::DoHitTest(RECT& rc, POINT pt) { - RECT rcGrip; - - SetRect(&rcGrip, RECT0); - if (PtInRect(&rcGrip, pt)) - return HTTOPLEFT; - SetRect(&rcGrip, RECT1); - if (PtInRect(&rcGrip, pt)) - return HTTOP; - SetRect(&rcGrip, RECT2); - if (PtInRect(&rcGrip, pt)) - return HTTOPRIGHT; - - SetRect(&rcGrip, RECT3); - if (PtInRect(&rcGrip, pt)) - return HTLEFT; - SetRect(&rcGrip, RECT4); - if (PtInRect(&rcGrip, pt)) - return HTRIGHT; - - SetRect(&rcGrip, RECT5); - if (PtInRect(&rcGrip, pt)) - return HTBOTTOMLEFT; - SetRect(&rcGrip, RECT6); - if (PtInRect(&rcGrip, pt)) - return HTBOTTOM; - SetRect(&rcGrip, RECT7); - if (PtInRect(&rcGrip, pt)) - return HTBOTTOMRIGHT; - - // On border line? - RECT rcInner = rc; - InflateRect(&rcInner, -3, -3); - if (!PtInRect(&rcInner, pt) && PtInRect(&rc, pt)) - return HTCAPTION; - - return HTCLIENT; + switch (getSizeBoxHitTest(pt, &rc)) + { + case HIT_NONE: return HTNOWHERE; + case HIT_UPPER_LEFT: return HTTOPLEFT; + case HIT_UPPER_CENTER: return HTTOP; + case HIT_UPPER_RIGHT: return HTTOPRIGHT; + case HIT_MIDDLE_LEFT: return HTLEFT; + case HIT_MIDDLE_RIGHT: return HTRIGHT; + case HIT_LOWER_LEFT: return HTBOTTOMLEFT; + case HIT_LOWER_CENTER: return HTBOTTOM; + case HIT_LOWER_RIGHT: return HTBOTTOMRIGHT; + case HIT_BORDER: return HTCAPTION; // Enable drag move + case HIT_INNER: return HTCLIENT; + } + return HTNOWHERE; } void CTextEditWindow::DrawGrip(HDC hDC, RECT& rc) { - HGDIOBJ hbrOld = SelectObject(hDC, GetStockObject(NULL_BRUSH)); - HPEN hPen = CreatePen(PS_DOT, 1, GetSysColor(COLOR_HIGHLIGHT)); - HGDIOBJ hPenOld = SelectObject(hDC, hPen); - InflateRect(&rc, -1, -1); - Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); - InflateRect(&rc, 1, 1); - SelectObject(hDC, hPenOld); - SelectObject(hDC, hbrOld); - DeleteObject(hPen); - - RECT rcGrip; - HBRUSH hbrHighlight = GetSysColorBrush(COLOR_HIGHLIGHT); - - SetRect(&rcGrip, RECT0); - FillRect(hDC, &rcGrip, hbrHighlight); - SetRect(&rcGrip, RECT1); - FillRect(hDC, &rcGrip, hbrHighlight); - SetRect(&rcGrip, RECT2); - FillRect(hDC, &rcGrip, hbrHighlight); - - SetRect(&rcGrip, RECT3); - FillRect(hDC, &rcGrip, hbrHighlight); - SetRect(&rcGrip, RECT4); - FillRect(hDC, &rcGrip, hbrHighlight); - - SetRect(&rcGrip, RECT5); - FillRect(hDC, &rcGrip, hbrHighlight); - SetRect(&rcGrip, RECT6); - FillRect(hDC, &rcGrip, hbrHighlight); - SetRect(&rcGrip, RECT7); - FillRect(hDC, &rcGrip, hbrHighlight); + drawSizeBoxes(hDC, &rc, TRUE, NULL); } void CTextEditWindow::FixEditPos(LPCTSTR pszOldText) @@ -257,7 +191,7 @@ LRESULT CTextEditWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BO UINT nHitTest = LOWORD(lParam); if (nHitTest == HTCAPTION) { - SetCursor(LoadCursor(NULL, IDC_SIZEALL)); + ::SetCursor(::LoadCursor(NULL, IDC_SIZEALL)); // Enable drag move return FALSE; } return DefWindowProc(nMsg, wParam, lParam); @@ -477,28 +411,16 @@ void CTextEditWindow::Reposition() imageArea.GetClientRect(&rcImage); if (rc.bottom > rcImage.bottom) - { - rc.top = rcImage.bottom - (rc.bottom - rc.top); - rc.bottom = rcImage.bottom; - } + ::OffsetRect(&rc, 0, rcImage.bottom - rc.bottom); if (rc.right > rcImage.right) - { - rc.left = rcImage.right - (rc.right - rc.left); - rc.right = rcImage.right; - } + ::OffsetRect(&rc, rcImage.right - rc.right, 0); if (rc.left < 0) - { - rc.right += -rc.left; - rc.left = 0; - } + ::OffsetRect(&rc, -rc.left, 0); if (rc.top < 0) - { - rc.bottom += -rc.top; - rc.top = 0; - } + ::OffsetRect(&rc, 0, -rc.top); ++m_nAppIsMovingOrSizing; MoveWindow(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
1 year, 9 months
1
0
0
0
[reactos] 01/01: [MSPAINT] Tool settings: Reduce magic numbers (#5168)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=57891b5f34d5832fccce9…
commit 57891b5f34d5832fccce99155f568c983161b002 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Mar 21 13:13:53 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Mar 21 13:13:53 2023 +0900 [MSPAINT] Tool settings: Reduce magic numbers (#5168) Many coordinates are dynamically calculated. It is adjustable against client area change. - Fix some brush/eraser shapes for pixel perfection. - Reduce magic numbers in toolssettings.cpp. - Refactoring. CORE-18867 --- base/applications/mspaint/drawing.cpp | 30 +- base/applications/mspaint/main.cpp | 9 +- base/applications/mspaint/toolbox.cpp | 9 + base/applications/mspaint/toolbox.h | 7 +- base/applications/mspaint/toolsettings.cpp | 461 +++++++++++++++++++---------- base/applications/mspaint/toolsettings.h | 11 + base/applications/mspaint/winproc.cpp | 2 +- 7 files changed, 356 insertions(+), 173 deletions(-) diff --git a/base/applications/mspaint/drawing.cpp b/base/applications/mspaint/drawing.cpp index 296a6f57a1e..f94da436eca 100644 --- a/base/applications/mspaint/drawing.cpp +++ b/base/applications/mspaint/drawing.cpp @@ -123,9 +123,11 @@ Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius) b = max(1, max(abs(x2 - x1), abs(y2 - y1))); oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); for(a = 0; a <= b; a++) - Rectangle(hdc, (x1 * (b - a) + x2 * a) / b - radius + 1, - (y1 * (b - a) + y2 * a) / b - radius + 1, (x1 * (b - a) + x2 * a) / b + radius + 1, - (y1 * (b - a) + y2 * a) / b + radius + 1); + Rectangle(hdc, + (x1 * (b - a) + x2 * a) / b - radius, + (y1 * (b - a) + y2 * a) / b - radius, + (x1 * (b - a) + x2 * a) / b + radius, + (y1 * (b - a) + y2 * a) / b + radius); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); } @@ -172,8 +174,11 @@ Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style) break; case 1: for(a = 0; a <= b; a++) - Ellipse(hdc, (x1 * (b - a) + x2 * a) / b - 1, (y1 * (b - a) + y2 * a) / b - 1, - (x1 * (b - a) + x2 * a) / b + 3, (y1 * (b - a) + y2 * a) / b + 3); + Ellipse(hdc, + (x1 * (b - a) + x2 * a) / b - 2, + (y1 * (b - a) + y2 * a) / b - 2, + (x1 * (b - a) + x2 * a) / b + 2, + (y1 * (b - a) + y2 * a) / b + 2); break; case 2: MoveToEx(hdc, x1, y1, NULL); @@ -182,8 +187,11 @@ Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style) break; case 3: for(a = 0; a <= b; a++) - Rectangle(hdc, (x1 * (b - a) + x2 * a) / b - 3, (y1 * (b - a) + y2 * a) / b - 3, - (x1 * (b - a) + x2 * a) / b + 5, (y1 * (b - a) + y2 * a) / b + 5); + Rectangle(hdc, + (x1 * (b - a) + x2 * a) / b - 4, + (y1 * (b - a) + y2 * a) / b - 4, + (x1 * (b - a) + x2 * a) / b + 4, + (y1 * (b - a) + y2 * a) / b + 4); break; case 4: for(a = 0; a <= b; a++) @@ -202,10 +210,10 @@ Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style) case 10: case 11: { - POINT offsTop[] = {{4, -3}, {2, -2}, {0, 0}, - {-3, -3}, {-2, -2}, {-1, 0}}; - POINT offsBtm[] = {{-3, 4}, {-2, 2}, {-1, 1}, - {4, 4}, {2, 2}, {0, 1}}; + POINT offsTop[] = {{3, -3}, {2, -2}, {0, 0}, + {-4, -4}, {-2, -2}, {-1, 0}}; + POINT offsBtm[] = {{-3, 3}, {-2, 2}, {-1, 1}, + {3, 3}, {2, 2}, {0, 1}}; LONG idx = style - 6; POINT pts[4]; pts[0].x = x1 + offsTop[idx].x; diff --git a/base/applications/mspaint/main.cpp b/base/applications/mspaint/main.cpp index f24a12b1a1f..1099f6af3f8 100644 --- a/base/applications/mspaint/main.cpp +++ b/base/applications/mspaint/main.cpp @@ -180,13 +180,8 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument SetMenu(hwnd, menu); haccel = LoadAccelerators(hThisInstance, MAKEINTRESOURCE(800)); - RECT toolBoxContainerPos = {2, 2, 2 + 52, 2 + 350}; - toolBoxContainer.Create(hwnd, toolBoxContainerPos, NULL, WS_CHILD); - if (registrySettings.ShowToolBox) - toolBoxContainer.ShowWindow(SW_SHOWNOACTIVATE); - /* creating the tool settings child window */ - RECT toolSettingsWindowPos = {5, 208, 5 + 42, 208 + 140}; - toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos, NULL, WS_CHILD | WS_VISIBLE); + /* Create ToolBox */ + toolBoxContainer.DoCreate(hwnd); /* creating the palette child window */ RECT paletteWindowPos = {56, 9, 56 + 255, 9 + 32}; diff --git a/base/applications/mspaint/toolbox.cpp b/base/applications/mspaint/toolbox.cpp index 4af48b5917a..793c62bbfda 100644 --- a/base/applications/mspaint/toolbox.cpp +++ b/base/applications/mspaint/toolbox.cpp @@ -13,6 +13,13 @@ /* FUNCTIONS ********************************************************/ +BOOL CToolBox::DoCreate(HWND hwndParent) +{ + RECT toolBoxContainerPos = { 0, 0, 0, 0 }; + DWORD style = WS_CHILD | (registrySettings.ShowToolBox ? WS_VISIBLE : 0); + return !!Create(hwndParent, toolBoxContainerPos, NULL, style); +} + LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { HIMAGELIST hImageList; @@ -20,6 +27,8 @@ LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl int i; TCHAR tooltips[NUM_TOOLS][30]; + toolSettingsWindow.DoCreate(m_hWnd); + /* 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 | diff --git a/base/applications/mspaint/toolbox.h b/base/applications/mspaint/toolbox.h index ac40ab19e5a..b6699c67455 100644 --- a/base/applications/mspaint/toolbox.h +++ b/base/applications/mspaint/toolbox.h @@ -12,8 +12,8 @@ #define TOOLBAR_ROWS 8 #define TOOLBAR_COLUMNS 2 #define CXY_TB_BUTTON 25 -#define CX_TOOLBAR ((TOOLBAR_COLUMNS * CXY_TB_BUTTON) + 2) -#define CY_TOOLBAR ((TOOLBAR_ROWS * CXY_TB_BUTTON) + 2) +#define CX_TOOLBAR (TOOLBAR_COLUMNS * CXY_TB_BUTTON) +#define CY_TOOLBAR (TOOLBAR_ROWS * CXY_TB_BUTTON) class CToolBox : public CWindowImpl<CToolBox> { @@ -27,6 +27,9 @@ public: MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged) END_MSG_MAP() + BOOL DoCreate(HWND hwndParent); + +private: CWindow toolbar; LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); diff --git a/base/applications/mspaint/toolsettings.cpp b/base/applications/mspaint/toolsettings.cpp index dc1883bf47e..c8b3978e8b6 100644 --- a/base/applications/mspaint/toolsettings.cpp +++ b/base/applications/mspaint/toolsettings.cpp @@ -5,21 +5,264 @@ * PURPOSE: Window procedure of the tool settings window * PROGRAMMERS: Benedikt Freisen * Stanislav Motylkov + * Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> */ /* INCLUDES *********************************************************/ #include "precomp.h" +#define X_TOOLSETTINGS 0 +#define Y_TOOLSETTINGS (CY_TOOLBAR + 3) +#define CX_TOOLSETTINGS CX_TOOLBAR +#define CY_TOOLSETTINGS 140 + +#define CX_TRANS_ICON 40 +#define CY_TRANS_ICON 30 +#define MARGIN1 3 +#define MARGIN2 2 + +static const BYTE s_AirRadius[4] = { 5, 8, 3, 12 }; + /* FUNCTIONS ********************************************************/ +BOOL CToolSettingsWindow::DoCreate(HWND hwndParent) +{ + /* creating the tool settings child window */ + RECT toolSettingsWindowPos = + { + X_TOOLSETTINGS, Y_TOOLSETTINGS, + X_TOOLSETTINGS + CX_TOOLSETTINGS, Y_TOOLSETTINGS + CY_TOOLSETTINGS + }; + return !!Create(toolBoxContainer, toolSettingsWindowPos, NULL, WS_CHILD | WS_VISIBLE); +} + +static INT +getSplitRects(RECT *rects, INT cColumns, INT cRows, LPCRECT prc, LPPOINT ppt) +{ + INT cx = prc->right - prc->left, cy = prc->bottom - prc->top; + for (INT i = 0, iRow = 0; iRow < cRows; ++iRow) + { + for (INT iColumn = 0; iColumn < cColumns; ++iColumn) + { + RECT& rc = rects[i]; + rc.left = prc->left + (iColumn * cx / cColumns); + rc.top = prc->top + (iRow * cy / cRows); + rc.right = prc->left + ((iColumn + 1) * cx / cColumns); + rc.bottom = prc->top + ((iRow + 1) * cy / cRows); + if (ppt && ::PtInRect(&rc, *ppt)) + return i; + ++i; + } + } + return -1; +} + +static inline INT getTransRects(RECT rects[2], LPCRECT prc, LPPOINT ppt = NULL) +{ + return getSplitRects(rects, 1, 2, prc, ppt); +} + +VOID CToolSettingsWindow::drawTrans(HDC hdc, LPCRECT prc) +{ + RECT rc[2]; + getTransRects(rc, prc); + + HBRUSH hbrHigh = ::GetSysColorBrush(COLOR_HIGHLIGHT); + ::FillRect(hdc, &rc[toolsModel.IsBackgroundTransparent()], hbrHigh); + ::DrawIconEx(hdc, rc[0].left, rc[0].top, m_hNontranspIcon, + CX_TRANS_ICON, CY_TRANS_ICON, 0, NULL, DI_NORMAL); + ::DrawIconEx(hdc, rc[1].left, rc[1].top, m_hTranspIcon, + CX_TRANS_ICON, CY_TRANS_ICON, 0, NULL, DI_NORMAL); +} + +static inline INT getRubberRects(RECT rects[4], LPCRECT prc, LPPOINT ppt = NULL) +{ + return getSplitRects(rects, 1, 4, prc, ppt); +} + +VOID CToolSettingsWindow::drawRubber(HDC hdc, LPCRECT prc) +{ + RECT rects[4], rcRubber; + getRubberRects(rects, prc); + INT xCenter = (prc->left + prc->right) / 2; + for (INT i = 0; i < 4; i++) + { + INT iColor, radius = i + 2; + if (toolsModel.GetRubberRadius() == radius) + { + ::FillRect(hdc, &rects[i], ::GetSysColorBrush(COLOR_HIGHLIGHT)); + iColor = COLOR_HIGHLIGHTTEXT; + } + else + { + iColor = COLOR_WINDOWTEXT; + } + + INT yCenter = (rects[i].top + rects[i].bottom) / 2; + rcRubber.left = xCenter - radius; + rcRubber.top = yCenter - radius; + rcRubber.right = rcRubber.left + radius * 2; + rcRubber.bottom = rcRubber.top + radius * 2; + ::FillRect(hdc, &rcRubber, GetSysColorBrush(iColor)); + } +} + +static inline INT getBrushRects(RECT rects[12], LPCRECT prc, LPPOINT ppt = NULL) +{ + return getSplitRects(rects, 3, 4, prc, ppt); +} + +VOID CToolSettingsWindow::drawBrush(HDC hdc, LPCRECT prc) +{ + RECT rects[12]; + getBrushRects(rects, prc); + + HBRUSH hbrHigh = ::GetSysColorBrush(COLOR_HIGHLIGHT); + ::FillRect(hdc, &rects[toolsModel.GetBrushStyle()], hbrHigh); + + for (INT i = 0; i < 12; i++) + { + RECT rcItem = rects[i]; + INT x = (rcItem.left + rcItem.right) / 2, y = (rcItem.top + rcItem.bottom) / 2; + INT iColor; + if (i == toolsModel.GetBrushStyle()) + iColor = COLOR_HIGHLIGHTTEXT; + else + iColor = COLOR_WINDOWTEXT; + Brush(hdc, x, y, x, y, ::GetSysColor(iColor), i); + } +} + +static inline INT getLineRects(RECT rects[5], LPCRECT prc, LPPOINT ppt = NULL) +{ + return getSplitRects(rects, 1, 5, prc, ppt); +} + +VOID CToolSettingsWindow::drawLine(HDC hdc, LPCRECT prc) +{ + RECT rects[5]; + getLineRects(rects, prc); + + for (INT i = 0; i < 5; i++) + { + INT penWidth = i + 1; + RECT rcLine = rects[i]; + ::InflateRect(&rcLine, -2, 0); + rcLine.top = (rcLine.top + rcLine.bottom - penWidth) / 2; + rcLine.bottom = rcLine.top + penWidth; + if (toolsModel.GetLineWidth() == penWidth) + { + ::FillRect(hdc, &rects[i], ::GetSysColorBrush(COLOR_HIGHLIGHT)); + ::FillRect(hdc, &rcLine, ::GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); + } + else + { + ::FillRect(hdc, &rcLine, ::GetSysColorBrush(COLOR_WINDOWTEXT)); + } + } +} + +static INT getAirBrushRects(RECT rects[4], LPCRECT prc, LPPOINT ppt = NULL) +{ + INT cx = (prc->right - prc->left), cy = (prc->bottom - prc->top); + + rects[0] = rects[1] = rects[2] = rects[3] = *prc; + + rects[0].right = rects[1].left = prc->left + cx * 3 / 8; + rects[0].bottom = rects[1].bottom = prc->top + cy / 2; + + rects[2].top = rects[3].top = prc->top + cy / 2; + rects[2].right = rects[3].left = prc->left + cx * 2 / 8; + + if (ppt) + { + for (INT i = 0; i < 4; ++i) + { + if (::PtInRect(&rects[i], *ppt)) + return i; + } + } + return -1; +} + +VOID CToolSettingsWindow::drawAirBrush(HDC hdc, LPCRECT prc) +{ + RECT rects[4]; + getAirBrushRects(rects, prc); + + srand(0); + for (size_t i = 0; i < 4; ++i) + { + RECT& rc = rects[i]; + INT x = (rc.left + rc.right) / 2; + INT y = (rc.top + rc.bottom) / 2; + BOOL bHigh = (s_AirRadius[i] == toolsModel.GetAirBrushWidth()); + if (bHigh) + { + ::FillRect(hdc, &rc, ::GetSysColorBrush(COLOR_HIGHLIGHT)); + Airbrush(hdc, x, y, ::GetSysColor(COLOR_HIGHLIGHTTEXT), s_AirRadius[i]); + } + else + { + Airbrush(hdc, x, y, ::GetSysColor(COLOR_WINDOWTEXT), s_AirRadius[i]); + } + } +} + +static inline INT getBoxRects(RECT rects[3], LPCRECT prc, LPPOINT ppt = NULL) +{ + return getSplitRects(rects, 1, 3, prc, ppt); +} + +VOID CToolSettingsWindow::drawBox(HDC hdc, LPCRECT prc) +{ + RECT rects[3]; + getBoxRects(rects, prc); + + for (INT iItem = 0; iItem < 3; ++iItem) + { + RECT& rcItem = rects[iItem]; + + if (toolsModel.GetShapeStyle() == iItem) + ::FillRect(hdc, &rcItem, ::GetSysColorBrush(COLOR_HIGHLIGHT)); + + ::InflateRect(&rcItem, -5, -5); + + if (iItem <= 1) + { + COLORREF rgbPen; + if (toolsModel.GetShapeStyle() == iItem) + rgbPen = ::GetSysColor(COLOR_HIGHLIGHTTEXT); + else + rgbPen = ::GetSysColor(COLOR_WINDOWTEXT); + HGDIOBJ hOldBrush; + if (iItem == 0) + hOldBrush = ::SelectObject(hdc, ::GetStockObject(NULL_BRUSH)); + else + hOldBrush = ::SelectObject(hdc, ::GetSysColorBrush(COLOR_APPWORKSPACE)); + HGDIOBJ hOldPen = ::SelectObject(hdc, ::CreatePen(PS_SOLID, 1, rgbPen)); + ::Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom); + ::DeleteObject(::SelectObject(hdc, hOldPen)); + ::SelectObject(hdc, hOldBrush); + } + else + { + if (toolsModel.GetShapeStyle() == iItem) + ::FillRect(hdc, &rcItem, ::GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); + else + ::FillRect(hdc, &rcItem, ::GetSysColorBrush(COLOR_WINDOWTEXT)); + } + } +} + LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, WINBOOL& bHandled) { /* preloading the draw transparent/nontransparent icons for later use */ m_hNontranspIcon = (HICON)LoadImage(hProgInstance, MAKEINTRESOURCE(IDI_NONTRANSPARENT), - IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR); + IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR); m_hTranspIcon = (HICON)LoadImage(hProgInstance, MAKEINTRESOURCE(IDI_TRANSPARENT), - IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR); + IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR); RECT trackbarZoomPos = {1, 1, 1 + 40, 1 + 64}; trackbarZoom.Create(TRACKBAR_CLASS, m_hWnd, trackbarZoomPos, NULL, WS_CHILD | TBS_VERT | TBS_AUTOTICKS); @@ -44,149 +287,65 @@ LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, return 0; } +VOID CToolSettingsWindow::calculateTwoBoxes(RECT& rect1, RECT& rect2) +{ + RECT rcClient; + GetClientRect(&rcClient); + ::InflateRect(&rcClient, -MARGIN1, -MARGIN1); + + INT yCenter = (rcClient.top + rcClient.bottom) / 2; + ::SetRect(&rect1, rcClient.left, rcClient.top, rcClient.right, yCenter); + ::SetRect(&rect2, rcClient.left, yCenter, rcClient.right, rcClient.bottom); + + ::InflateRect(&rect1, -MARGIN2, -MARGIN2); + ::InflateRect(&rect2, -MARGIN2, -MARGIN2); +} + LRESULT CToolSettingsWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - PAINTSTRUCT ps; - RECT rect1 = { 0, 0, 42, 66 }; - RECT rect2 = { 0, 70, 42, 136 }; + RECT rect1, rect2; + calculateTwoBoxes(rect1, rect2); + PAINTSTRUCT ps; HDC hdc = BeginPaint(&ps); - DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (toolsModel.GetActiveTool() == TOOL_ZOOM) ? BF_RECT : BF_RECT | BF_MIDDLE); - DrawEdge(hdc, &rect2, (toolsModel.GetActiveTool() >= TOOL_RECT) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE); + + if (toolsModel.GetActiveTool() == TOOL_ZOOM) + ::DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, BF_RECT); + else + ::DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE); + + if (toolsModel.GetActiveTool() >= TOOL_RECT) + ::DrawEdge(hdc, &rect2, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE); + + ::InflateRect(&rect1, -MARGIN2, -MARGIN2); + ::InflateRect(&rect2, -MARGIN2, -MARGIN2); switch (toolsModel.GetActiveTool()) { case TOOL_FREESEL: case TOOL_RECTSEL: case TOOL_TEXT: - { - HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, toolsModel.IsBackgroundTransparent() * 31 + 2, 41, toolsModel.IsBackgroundTransparent() * 31 + 33); - DeleteObject(SelectObject(hdc, oldPen)); - DrawIconEx(hdc, 1, 2, m_hNontranspIcon, 40, 30, 0, NULL, DI_NORMAL); - DrawIconEx(hdc, 1, 33, m_hTranspIcon, 40, 30, 0, NULL, DI_NORMAL); + drawTrans(hdc, &rect1); break; - } case TOOL_RUBBER: - { - int i; - HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - for(i = 0; i < 4; i++) - { - if (toolsModel.GetRubberRadius() == i + 2) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 14, i * 15 + 2, 29, i * 15 + 17); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); - } - else - SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); - Rectangle(hdc, 19 - i, i * 14 + 7, 24 + i, i * 16 + 12); - } - DeleteObject(SelectObject(hdc, oldPen)); + drawRubber(hdc, &rect1); break; - } case TOOL_BRUSH: - { - int i; - HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, toolsModel.GetBrushStyle() % 3 * 13 + 2, toolsModel.GetBrushStyle() / 3 * 15 + 2, toolsModel.GetBrushStyle() % 3 * 13 + 15, - toolsModel.GetBrushStyle() / 3 * 15 + 17); - DeleteObject(SelectObject(hdc, oldPen)); - for(i = 0; i < 12; i++) - Brush(hdc, i % 3 * 13 + 7, i / 3 * 15 + 8, i % 3 * 13 + 7, i / 3 * 15 + 8, - GetSysColor((i == toolsModel.GetBrushStyle()) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), i); + drawBrush(hdc, &rect1); break; - } case TOOL_AIRBRUSH: - { - HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - switch (toolsModel.GetAirBrushWidth()) - { - case 5: - Rectangle(hdc, 2, 2, 21, 31); - break; - case 8: - Rectangle(hdc, 20, 2, 41, 31); - break; - case 3: - Rectangle(hdc, 2, 30, 16, 61); - break; - case 12: - Rectangle(hdc, 15, 30, 41, 61); - break; - } - Airbrush(hdc, 10, 15, - GetSysColor((toolsModel.GetAirBrushWidth() == 5) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 5); - Airbrush(hdc, 30, 15, - GetSysColor((toolsModel.GetAirBrushWidth() == 8) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 8); - Airbrush(hdc, 8, 45, - GetSysColor((toolsModel.GetAirBrushWidth() == 3) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 3); - Airbrush(hdc, 27, 45, - GetSysColor((toolsModel.GetAirBrushWidth() == 12) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 12); - DeleteObject(SelectObject(hdc, oldPen)); + drawAirBrush(hdc, &rect1); break; - } case TOOL_LINE: case TOOL_BEZIER: - { - int i; - HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - for(i = 0; i < 5; i++) - { - if (toolsModel.GetLineWidth() == i + 1) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, i * 12 + 2, 41, i * 12 + 14); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); - } - else - SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); - Rectangle(hdc, 5, i * 12 + 6, 38, i * 12 + 8 + i); - } - DeleteObject(SelectObject(hdc, oldPen)); + drawLine(hdc, &rect1); break; - } case TOOL_RECT: case TOOL_SHAPE: case TOOL_ELLIPSE: case TOOL_RRECT: - { - int i; - HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - for(i = 0; i < 3; i++) - { - if (toolsModel.GetShapeStyle() == i) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, i * 20 + 2, 41, i * 20 + 22); - } - } - Rect(hdc, 5, 6, 37, 16, - GetSysColor((toolsModel.GetShapeStyle() == 0) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), - GetSysColor(COLOR_APPWORKSPACE), 1, 0); - Rect(hdc, 5, 26, 37, 36, - GetSysColor((toolsModel.GetShapeStyle() == 1) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), - GetSysColor(COLOR_APPWORKSPACE), 1, 1); - Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE), - 1, 1); - for(i = 0; i < 5; i++) - { - if (toolsModel.GetLineWidth() == i + 1) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, i * 12 + 72, 41, i * 12 + 84); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); - } - else - SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); - Rectangle(hdc, 5, i * 12 + 76, 38, i * 12 + 78 + i); - } - DeleteObject(SelectObject(hdc, oldPen)); + drawBox(hdc, &rect1); + drawLine(hdc, &rect2); break; - } case TOOL_FILL: case TOOL_COLOR: case TOOL_ZOOM: @@ -199,56 +358,54 @@ LRESULT CToolSettingsWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BO LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + + RECT rect1, rect2; + calculateTwoBoxes(rect1, rect2); + RECT rects[12]; + + INT iItem; switch (toolsModel.GetActiveTool()) { case TOOL_FREESEL: case TOOL_RECTSEL: case TOOL_TEXT: - if ((y > 1) && (y < 64)) - toolsModel.SetBackgroundTransparent((y - 2) / 31); + iItem = getTransRects(rects, &rect1, &pt); + if (iItem != -1) + toolsModel.SetBackgroundTransparent(iItem); break; case TOOL_RUBBER: - if ((y > 1) && (y < 62)) - toolsModel.SetRubberRadius((y - 2) / 15 + 2); + iItem = getRubberRects(rects, &rect1, &pt); + if (iItem != -1) + toolsModel.SetRubberRadius(iItem + 2); break; case TOOL_BRUSH: - if ((x > 1) && (x < 40) && (y > 1) && (y < 62)) - toolsModel.SetBrushStyle((y - 2) / 15 * 3 + (x - 2) / 13); + iItem = getBrushRects(rects, &rect1, &pt); + if (iItem != -1) + toolsModel.SetBrushStyle(iItem); break; case TOOL_AIRBRUSH: - if (y < 62) - { - if (y < 30) - { - if (x < 20) - toolsModel.SetAirBrushWidth(5); - else - toolsModel.SetAirBrushWidth(8); - } - else - { - if (x < 15) - toolsModel.SetAirBrushWidth(3); - else - toolsModel.SetAirBrushWidth(12); - } - } + iItem = getAirBrushRects(rects, &rect1, &pt); + if (iItem != -1) + toolsModel.SetAirBrushWidth(s_AirRadius[iItem]); break; case TOOL_LINE: case TOOL_BEZIER: - if (y <= 62) - toolsModel.SetLineWidth((y - 2) / 12 + 1); + iItem = getLineRects(rects, &rect1, &pt); + if (iItem != -1) + toolsModel.SetLineWidth(iItem + 1); break; case TOOL_RECT: case TOOL_SHAPE: case TOOL_ELLIPSE: case TOOL_RRECT: - if (y <= 60) - toolsModel.SetShapeStyle((y - 2) / 20); - if ((y >= 70) && (y <= 132)) - toolsModel.SetLineWidth((y - 72) / 12 + 1); + iItem = getBoxRects(rects, &rect1, &pt); + if (iItem != -1) + toolsModel.SetShapeStyle(iItem); + + iItem = getLineRects(rects, &rect2, &pt); + if (iItem != -1) + toolsModel.SetLineWidth(iItem + 1); break; case TOOL_FILL: case TOOL_COLOR: diff --git a/base/applications/mspaint/toolsettings.h b/base/applications/mspaint/toolsettings.h index bd92d61a6ac..6ad02e22e09 100644 --- a/base/applications/mspaint/toolsettings.h +++ b/base/applications/mspaint/toolsettings.h @@ -24,10 +24,21 @@ public: MESSAGE_HANDLER(WM_DESTROY, OnDestroy) END_MSG_MAP() + BOOL DoCreate(HWND hwndParent); + +private: CWindow trackbarZoom; HICON m_hNontranspIcon; HICON m_hTranspIcon; + VOID drawTrans(HDC hdc, LPCRECT prc); + VOID drawRubber(HDC hdc, LPCRECT prc); + VOID drawBrush(HDC hdc, LPCRECT prc); + VOID drawLine(HDC hdc, LPCRECT prc); + VOID drawBox(HDC hdc, LPCRECT prc); + VOID drawAirBrush(HDC hdc, LPCRECT prc); + VOID calculateTwoBoxes(RECT& rect1, RECT& rect2); + LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); diff --git a/base/applications/mspaint/winproc.cpp b/base/applications/mspaint/winproc.cpp index ee4e9daa87a..5208e37d610 100644 --- a/base/applications/mspaint/winproc.cpp +++ b/base/applications/mspaint/winproc.cpp @@ -426,7 +426,7 @@ LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BO { MINMAXINFO *mm = (LPMINMAXINFO) lParam; mm->ptMinTrackSize.x = 330; - mm->ptMinTrackSize.y = 430; + mm->ptMinTrackSize.y = 360; return 0; }
1 year, 9 months
1
0
0
0
[reactos] 01/01: [NOTEPAD] Use _countof macro from <stdlib.h> (#5170)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d28e39e4096be4dd24ad9…
commit d28e39e4096be4dd24ad9bed795e011e71b460d7 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Mar 21 08:59:40 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Mar 21 08:59:40 2023 +0900 [NOTEPAD] Use _countof macro from <stdlib.h> (#5170) - Remove the definition of ARRAY_SIZE macro. - Replace ARRAY_SIZE and ARRAYSIZE with _countof. CORE-18837 --- base/applications/notepad/dialog.c | 60 ++++++++++++++++++------------------ base/applications/notepad/main.c | 18 +++++------ base/applications/notepad/notepad.h | 2 -- base/applications/notepad/printing.c | 34 ++++++++++---------- base/applications/notepad/settings.c | 16 +++++----- 5 files changed, 64 insertions(+), 66 deletions(-) diff --git a/base/applications/notepad/dialog.c b/base/applications/notepad/dialog.c index b972dbb08bc..78dbd467f37 100644 --- a/base/applications/notepad/dialog.c +++ b/base/applications/notepad/dialog.c @@ -50,7 +50,7 @@ VOID ShowLastError(VOID) LPTSTR lpMsgBuf = NULL; TCHAR szTitle[MAX_STRING_LEN]; - LoadString(Globals.hInstance, STRING_ERROR, szTitle, ARRAY_SIZE(szTitle)); + LoadString(Globals.hInstance, STRING_ERROR, szTitle, _countof(szTitle)); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -96,13 +96,13 @@ void UpdateWindowCaption(BOOL clearModifyAlert) Globals.bWasModified = isModified; /* Load the name of the application */ - LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad)); + LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad)); /* Determine if the file has been saved or if this is a new file */ if (Globals.szFileTitle[0] != 0) - StringCchCopy(szFilename, ARRAY_SIZE(szFilename), Globals.szFileTitle); + StringCchCopy(szFilename, _countof(szFilename), Globals.szFileTitle); else - LoadString(Globals.hInstance, STRING_UNTITLED, szFilename, ARRAY_SIZE(szFilename)); + LoadString(Globals.hInstance, STRING_UNTITLED, szFilename, _countof(szFilename)); /* Update the window caption based upon whether the user has modified the file or not */ StringCbPrintf(szCaption, sizeof(szCaption), _T("%s%s - %s"), @@ -126,14 +126,14 @@ VOID DIALOG_StatusBarAlignParts(VOID) parts[0] = max(parts[0], defaultWidths[0]); parts[1] = max(parts[1], defaultWidths[0] + defaultWidths[1]); - SendMessageW(Globals.hStatusBar, SB_SETPARTS, ARRAY_SIZE(parts), (LPARAM)parts); + SendMessageW(Globals.hStatusBar, SB_SETPARTS, _countof(parts), (LPARAM)parts); } static VOID DIALOG_StatusBarUpdateLineEndings(VOID) { WCHAR szText[128]; - LoadStringW(Globals.hInstance, EolnToStrId[Globals.iEoln], szText, ARRAY_SIZE(szText)); + LoadStringW(Globals.hInstance, EolnToStrId[Globals.iEoln], szText, _countof(szText)); SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_EOLN, (LPARAM)szText); } @@ -144,7 +144,7 @@ static VOID DIALOG_StatusBarUpdateEncoding(VOID) if (Globals.encFile != ENCODING_AUTO) { - LoadStringW(Globals.hInstance, EncToStrId[Globals.encFile], szText, ARRAY_SIZE(szText)); + LoadStringW(Globals.hInstance, EncToStrId[Globals.encFile], szText, _countof(szText)); } SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_ENCODING, (LPARAM)szText); @@ -163,14 +163,14 @@ int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFl TCHAR szResource[MAX_STRING_LEN]; /* Load and format szMessage */ - LoadString(Globals.hInstance, formatId, szResource, ARRAY_SIZE(szResource)); - _sntprintf(szMessage, ARRAY_SIZE(szMessage), szResource, szString); + LoadString(Globals.hInstance, formatId, szResource, _countof(szResource)); + _sntprintf(szMessage, _countof(szMessage), szResource, szString); /* Load szCaption */ if ((dwFlags & MB_ICONMASK) == MB_ICONEXCLAMATION) - LoadString(Globals.hInstance, STRING_ERROR, szResource, ARRAY_SIZE(szResource)); + LoadString(Globals.hInstance, STRING_ERROR, szResource, _countof(szResource)); else - LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource)); + LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, _countof(szResource)); /* Display Modal Dialog */ // if (hParent == NULL) @@ -187,7 +187,7 @@ static int AlertFileNotSaved(LPCTSTR szFileName) { TCHAR szUntitled[MAX_STRING_LEN]; - LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, ARRAY_SIZE(szUntitled)); + LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, _countof(szUntitled)); return DIALOG_StringMsgBox(Globals.hMainWnd, STRING_NOTSAVED, szFileName[0] ? szFileName : szUntitled, @@ -330,7 +330,7 @@ VOID DoOpenFile(LPCTSTR szFileName) /* If the file starts with .LOG, add a time/date at the end and set cursor after * See
http://web.archive.org/web/20090627165105/http://support.microsoft.com/kb/2…
*/ - if (GetWindowText(Globals.hEdit, log, ARRAY_SIZE(log)) && !_tcscmp(log, _T(".LOG"))) + if (GetWindowText(Globals.hEdit, log, _countof(log)) && !_tcscmp(log, _T(".LOG"))) { static const TCHAR lf[] = _T("\r\n"); SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1); @@ -367,7 +367,7 @@ VOID DIALOG_FileNew(VOID) VOID DIALOG_FileNewWindow(VOID) { TCHAR pszNotepadExe[MAX_PATH]; - GetModuleFileName(NULL, pszNotepadExe, ARRAYSIZE(pszNotepadExe)); + GetModuleFileName(NULL, pszNotepadExe, _countof(pszNotepadExe)); ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL); } @@ -388,7 +388,7 @@ VOID DIALOG_FileOpen(VOID) openfilename.hInstance = Globals.hInstance; openfilename.lpstrFilter = Globals.szFilter; openfilename.lpstrFile = szPath; - openfilename.nMaxFile = ARRAY_SIZE(szPath); + openfilename.nMaxFile = _countof(szPath); openfilename.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; openfilename.lpstrDefExt = szDefaultExt; @@ -428,32 +428,32 @@ DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: hCombo = GetDlgItem(hDlg, ID_ENCODING); - LoadString(Globals.hInstance, STRING_ANSI, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_ANSI, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); - LoadString(Globals.hInstance, STRING_UNICODE, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_UNICODE, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); - LoadString(Globals.hInstance, STRING_UNICODE_BE, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_UNICODE_BE, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); - LoadString(Globals.hInstance, STRING_UTF8, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_UTF8, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); - LoadString(Globals.hInstance, STRING_UTF8_BOM, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_UTF8_BOM, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); SendMessage(hCombo, CB_SETCURSEL, Globals.encFile, 0); hCombo = GetDlgItem(hDlg, ID_EOLN); - LoadString(Globals.hInstance, STRING_CRLF, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_CRLF, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); - LoadString(Globals.hInstance, STRING_LF, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_LF, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); - LoadString(Globals.hInstance, STRING_CR, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, STRING_CR, szText, _countof(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); SendMessage(hCombo, CB_SETCURSEL, Globals.iEoln, 0); @@ -492,7 +492,7 @@ BOOL DIALOG_FileSaveAs(VOID) saveas.hInstance = Globals.hInstance; saveas.lpstrFilter = Globals.szFilter; saveas.lpstrFile = szPath; - saveas.nMaxFile = ARRAY_SIZE(szPath); + saveas.nMaxFile = _countof(szPath); saveas.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK; saveas.lpstrDefExt = szDefaultExt; @@ -748,9 +748,9 @@ static VOID DIALOG_SearchDialog(FINDPROC pfnProc) Globals.find.lStructSize = sizeof(Globals.find); Globals.find.hwndOwner = Globals.hMainWnd; Globals.find.lpstrFindWhat = Globals.szFindText; - Globals.find.wFindWhatLen = ARRAY_SIZE(Globals.szFindText); + Globals.find.wFindWhatLen = _countof(Globals.szFindText); Globals.find.lpstrReplaceWith = Globals.szReplaceText; - Globals.find.wReplaceWithLen = ARRAY_SIZE(Globals.szReplaceText); + Globals.find.wReplaceWithLen = _countof(Globals.szReplaceText); Globals.find.Flags = FR_DOWN; } @@ -812,8 +812,8 @@ DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam) { /* Show error message */ WCHAR title[128], text[256]; - LoadStringW(Globals.hInstance, STRING_NOTEPAD, title, ARRAY_SIZE(title)); - LoadStringW(Globals.hInstance, STRING_LINE_NUMBER_OUT_OF_RANGE, text, ARRAY_SIZE(text)); + LoadStringW(Globals.hInstance, STRING_NOTEPAD, title, _countof(title)); + LoadStringW(Globals.hInstance, STRING_LINE_NUMBER_OUT_OF_RANGE, text, _countof(text)); MessageBoxW(hwndDialog, text, title, MB_OK); SendDlgItemMessageW(hwndDialog, ID_LINENUMBER, EM_SETSEL, 0, -1); @@ -900,8 +900,8 @@ VOID DIALOG_HelpAboutNotepad(VOID) TCHAR szNotepad[MAX_STRING_LEN]; TCHAR szNotepadAuthors[MAX_STRING_LEN]; - LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad)); - LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, ARRAY_SIZE(szNotepadAuthors)); + LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad)); + LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, _countof(szNotepadAuthors)); ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors, LoadIcon(Globals.hInstance, MAKEINTRESOURCE(IDI_NPICON))); diff --git a/base/applications/notepad/main.c b/base/applications/notepad/main.c index baea8b40ada..c232bfbf3e7 100644 --- a/base/applications/notepad/main.c +++ b/base/applications/notepad/main.c @@ -33,9 +33,9 @@ VOID NOTEPAD_EnableSearchMenu() */ VOID SetFileName(LPCTSTR szFileName) { - StringCchCopy(Globals.szFileName, ARRAY_SIZE(Globals.szFileName), szFileName); + StringCchCopy(Globals.szFileName, _countof(Globals.szFileName), szFileName); Globals.szFileTitle[0] = 0; - GetFileTitle(szFileName, Globals.szFileTitle, ARRAY_SIZE(Globals.szFileTitle)); + GetFileTitle(szFileName, Globals.szFileTitle, _countof(Globals.szFileTitle)); if (szFileName && szFileName[0]) SHAddToRecentDocs(SHARD_PATHW, szFileName); @@ -201,9 +201,9 @@ BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert) /* Can't find target */ if (bShowAlert) { - LoadString(Globals.hInstance, STRING_CANNOTFIND, szResource, ARRAY_SIZE(szResource)); - _sntprintf(szText, ARRAY_SIZE(szText), szResource, pFindReplace->lpstrFindWhat); - LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource)); + LoadString(Globals.hInstance, STRING_CANNOTFIND, szResource, _countof(szResource)); + _sntprintf(szText, _countof(szText), szResource, pFindReplace->lpstrFindWhat); + LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, _countof(szResource)); MessageBox(Globals.hFindReplaceDlg, szText, szResource, MB_OK); } bSuccess = FALSE; @@ -253,11 +253,11 @@ static VOID NOTEPAD_InitData(HINSTANCE hInstance) p = Globals.szFilter; p += LoadString(Globals.hInstance, STRING_TEXT_FILES_TXT, p, MAX_STRING_LEN) + 1; _tcscpy(p, txt_files); - p += ARRAY_SIZE(txt_files); + p += _countof(txt_files); p += LoadString(Globals.hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN) + 1; _tcscpy(p, all_files); - p += ARRAY_SIZE(all_files); + p += _countof(all_files); *p = '\0'; Globals.find.lpstrFindWhat = NULL; @@ -416,7 +416,7 @@ NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) TCHAR szFileName[MAX_PATH]; HDROP hDrop = (HDROP) wParam; - DragQueryFile(hDrop, 0, szFileName, ARRAY_SIZE(szFileName)); + DragQueryFile(hDrop, 0, szFileName, _countof(szFileName)); DragFinish(hDrop); DoOpenFile(szFileName); break; @@ -515,7 +515,7 @@ static BOOL HandleCommandLine(LPTSTR cmdline) } } - GetFullPathName(file_name, ARRAY_SIZE(szPath), szPath, NULL); + GetFullPathName(file_name, _countof(szPath), szPath, NULL); if (file_exists) { diff --git a/base/applications/notepad/notepad.h b/base/applications/notepad/notepad.h index 2b9338a3b85..b369101da5f 100644 --- a/base/applications/notepad/notepad.h +++ b/base/applications/notepad/notepad.h @@ -33,8 +33,6 @@ #include "dialog.h" #include "notepad_res.h" -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - #define EDIT_STYLE_WRAP (WS_CHILD | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL) #define EDIT_STYLE (EDIT_STYLE_WRAP | WS_HSCROLL | ES_AUTOHSCROLL) #define EDIT_CLASS _T("EDIT") diff --git a/base/applications/notepad/printing.c b/base/applications/notepad/printing.c index be15b2ecb0a..65f4e7322b3 100644 --- a/base/applications/notepad/printing.c +++ b/base/applications/notepad/printing.c @@ -17,7 +17,7 @@ static VOID AlertPrintError(VOID) { TCHAR szUntitled[MAX_STRING_LEN]; - LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, ARRAY_SIZE(szUntitled)); + LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, _countof(szUntitled)); DIALOG_StringMsgBox(Globals.hMainWnd, STRING_PRINTERROR, Globals.szFileName[0] ? Globals.szFileName : szUntitled, @@ -143,7 +143,7 @@ DrawHeaderOrFooter(HDC hDC, LPRECT pRect, LPCTSTR pszFormat, INT nPageNo, const { if (*pchFormat != _T('&')) { - StringCchCatN(szText, ARRAY_SIZE(szText), pchFormat, 1); + StringCchCatN(szText, _countof(szText), pchFormat, 1); continue; } @@ -154,7 +154,7 @@ DrawHeaderOrFooter(HDC hDC, LPRECT pRect, LPCTSTR pszFormat, INT nPageNo, const switch (_totupper(*pchFormat)) /* Make it uppercase */ { case _T('&'): /* Found double ampersand */ - StringCchCat(szText, ARRAY_SIZE(szText), TEXT("&")); + StringCchCat(szText, _countof(szText), TEXT("&")); break; case _T('L'): /* Left */ @@ -177,30 +177,30 @@ DrawHeaderOrFooter(HDC hDC, LPRECT pRect, LPCTSTR pszFormat, INT nPageNo, const case _T('D'): /* Date */ GetDateFormat(LOCALE_USER_DEFAULT, 0, pstNow, NULL, - szField, (INT)ARRAY_SIZE(szField)); - StringCchCat(szText, ARRAY_SIZE(szText), szField); + szField, (INT)_countof(szField)); + StringCchCat(szText, _countof(szText), szField); break; case _T('T'): /* Time */ GetTimeFormat(LOCALE_USER_DEFAULT, 0, pstNow, NULL, - szField, (INT)ARRAY_SIZE(szField)); - StringCchCat(szText, ARRAY_SIZE(szText), szField); + szField, (INT)_countof(szField)); + StringCchCat(szText, _countof(szText), szField); break; case _T('F'): /* Filename */ - StringCchCat(szText, ARRAY_SIZE(szText), Globals.szFileTitle); + StringCchCat(szText, _countof(szText), Globals.szFileTitle); break; case _T('P'): /* Page number */ - StringCchPrintf(szField, ARRAY_SIZE(szField), TEXT("%u"), nPageNo); - StringCchCat(szText, ARRAY_SIZE(szText), szField); + StringCchPrintf(szField, _countof(szField), TEXT("%u"), nPageNo); + StringCchCat(szText, _countof(szText), szField); break; default: /* Otherwise */ szField[0] = _T('&'); szField[1] = *pchFormat; szField[2] = 0; - StringCchCat(szText, ARRAY_SIZE(szText), szField); + StringCchCat(szText, _countof(szText), szField); break; } } @@ -503,7 +503,7 @@ DIALOG_Printing_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) s_pData = (PPRINT_DATA)lParam; s_pData->hwndDlg = hwnd; SetDlgItemText(hwnd, IDC_PRINTING_FILENAME, Globals.szFileTitle); - GetDlgItemText(hwnd, IDC_PRINTING_PAGE, s_szPage, ARRAY_SIZE(s_szPage)); + GetDlgItemText(hwnd, IDC_PRINTING_PAGE, s_szPage, _countof(s_szPage)); SetDlgItemText(hwnd, IDC_PRINTING_PAGE, NULL); s_hThread = CreateThread(NULL, 0, PrintThreadFunc, s_pData, 0, NULL); @@ -519,17 +519,17 @@ DIALOG_Printing_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { case STRING_NOWPRINTING: case STRING_PRINTCANCELING: - StringCchPrintf(szText, ARRAY_SIZE(szText), s_szPage, s_pData->currentPage); + StringCchPrintf(szText, _countof(szText), s_szPage, s_pData->currentPage); SetDlgItemText(hwnd, IDC_PRINTING_PAGE, szText); - LoadString(Globals.hInstance, s_pData->status, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, s_pData->status, szText, _countof(szText)); SetDlgItemText(hwnd, IDC_PRINTING_STATUS, szText); break; case STRING_PRINTCOMPLETE: case STRING_PRINTCANCELED: case STRING_PRINTFAILED: - LoadString(Globals.hInstance, s_pData->status, szText, ARRAY_SIZE(szText)); + LoadString(Globals.hInstance, s_pData->status, szText, _countof(szText)); SetDlgItemText(hwnd, IDC_PRINTING_STATUS, szText); if (s_pData->status == STRING_PRINTCOMPLETE) @@ -636,8 +636,8 @@ static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook(HWND hDlg, UINT uMsg, WPARAM wPar { case IDOK: /* save user input and close dialog */ - GetDlgItemText(hDlg, 0x141, Globals.szHeader, ARRAY_SIZE(Globals.szHeader)); - GetDlgItemText(hDlg, 0x143, Globals.szFooter, ARRAY_SIZE(Globals.szFooter)); + GetDlgItemText(hDlg, 0x141, Globals.szHeader, _countof(Globals.szHeader)); + GetDlgItemText(hDlg, 0x143, Globals.szFooter, _countof(Globals.szFooter)); return FALSE; case IDCANCEL: diff --git a/base/applications/notepad/settings.c b/base/applications/notepad/settings.c index 5295a06f025..6c0c1672144 100644 --- a/base/applications/notepad/settings.c +++ b/base/applications/notepad/settings.c @@ -159,8 +159,8 @@ void NOTEPAD_LoadSettingsFromRegistry(void) QueryDword(hKey, _T("iWindowPosDX"), &cx); QueryDword(hKey, _T("iWindowPosDY"), &cy); - QueryString(hKey, _T("searchString"), Globals.szFindText, ARRAY_SIZE(Globals.szFindText)); - QueryString(hKey, _T("replaceString"), Globals.szReplaceText, ARRAY_SIZE(Globals.szReplaceText)); + QueryString(hKey, _T("searchString"), Globals.szFindText, _countof(Globals.szFindText)); + QueryString(hKey, _T("replaceString"), Globals.szReplaceText, _countof(Globals.szReplaceText)); } Globals.lfFont.lfHeight = HeightFromPointSize(dwPointSize); @@ -168,22 +168,22 @@ void NOTEPAD_LoadSettingsFromRegistry(void) Globals.main_rect.bottom = Globals.main_rect.top + cy; if (!hKey || !QueryString(hKey, _T("lfFaceName"), - Globals.lfFont.lfFaceName, ARRAY_SIZE(Globals.lfFont.lfFaceName))) + Globals.lfFont.lfFaceName, _countof(Globals.lfFont.lfFaceName))) { LoadString(Globals.hInstance, STRING_DEFAULTFONT, Globals.lfFont.lfFaceName, - ARRAY_SIZE(Globals.lfFont.lfFaceName)); + _countof(Globals.lfFont.lfFaceName)); } - if (!hKey || !QueryString(hKey, _T("szHeader"), Globals.szHeader, ARRAY_SIZE(Globals.szHeader))) + if (!hKey || !QueryString(hKey, _T("szHeader"), Globals.szHeader, _countof(Globals.szHeader))) { LoadString(Globals.hInstance, STRING_PAGESETUP_HEADERVALUE, Globals.szHeader, - ARRAY_SIZE(Globals.szHeader)); + _countof(Globals.szHeader)); } - if (!hKey || !QueryString(hKey, _T("szTrailer"), Globals.szFooter, ARRAY_SIZE(Globals.szFooter))) + if (!hKey || !QueryString(hKey, _T("szTrailer"), Globals.szFooter, _countof(Globals.szFooter))) { LoadString(Globals.hInstance, STRING_PAGESETUP_FOOTERVALUE, Globals.szFooter, - ARRAY_SIZE(Globals.szFooter)); + _countof(Globals.szFooter)); } if (hKey)
1 year, 9 months
1
0
0
0
[reactos] 01/01: [REGEDIT] Move '#include <crtdbg.h>' and add _CRTDBG_MAP_ALLOC
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=49d8c1af21c06f6e38b3d…
commit 49d8c1af21c06f6e38b3d9034f52820656362ff1 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Mar 21 07:26:04 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Mar 21 07:26:04 2023 +0900 [REGEDIT] Move '#include <crtdbg.h>' and add _CRTDBG_MAP_ALLOC - Add #include <stdlib.h>. - Move #include <crtdbg.h> to "regedit.h". - Add #define _CRTDBG_MAP_ALLOC before #include <crtdbg.h>. CORE-18876 --- base/applications/regedit/main.c | 4 ---- base/applications/regedit/regedit.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/base/applications/regedit/main.c b/base/applications/regedit/main.c index 5ec8ddca2cc..3f58f0162e9 100644 --- a/base/applications/regedit/main.c +++ b/base/applications/regedit/main.c @@ -20,10 +20,6 @@ #include "regedit.h" -#ifdef _DEBUG -#include <crtdbg.h> -#endif - BOOL ProcessCmdLine(WCHAR *cmdline); const WCHAR *reg_class_namesW[] = {L"HKEY_LOCAL_MACHINE", L"HKEY_USERS", diff --git a/base/applications/regedit/regedit.h b/base/applications/regedit/regedit.h index d1decef5893..102f3480524 100644 --- a/base/applications/regedit/regedit.h +++ b/base/applications/regedit/regedit.h @@ -10,6 +10,11 @@ #include <aclapi.h> #include <shellapi.h> #include <strsafe.h> +#include <stdlib.h> +#ifdef _DEBUG + #define _CRTDBG_MAP_ALLOC + #include <crtdbg.h> +#endif #include "main.h" #include "hexedit.h"
1 year, 9 months
1
0
0
0
[reactos] 01/01: [NTUSER] ime.c: Add parameter to ERR(...)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1ef98fff3bf48ea6a9244…
commit 1ef98fff3bf48ea6a92446a199fc46bce0c826d4 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Mar 21 07:21:31 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Mar 21 07:21:31 2023 +0900 [NTUSER] ime.c: Add parameter to ERR(...) Follow-up of 94f22bd. CORE-11700 --- win32ss/user/ntuser/ime.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c index d483fa2530a..5a1eeb86580 100644 --- a/win32ss/user/ntuser/ime.c +++ b/win32ss/user/ntuser/ime.c @@ -78,7 +78,7 @@ UINT FASTCALL IntGetImeHotKeyLanguageScore(HKL hKL, LANGID HotKeyLangId) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", NtCurrentTeb()); lcid = MAKELCID(LANGID_NEUTRAL, SORT_DEFAULT); } _SEH2_END; @@ -433,7 +433,7 @@ NtUserGetImeHotKey(DWORD dwHotKeyId, LPUINT lpuModifiers, LPUINT lpuVirtualKey, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p, %p, %p\n", lpuModifiers, lpuVirtualKey, lphKL); _SEH2_YIELD(goto Quit); } _SEH2_END; @@ -451,7 +451,7 @@ NtUserGetImeHotKey(DWORD dwHotKeyId, LPUINT lpuModifiers, LPUINT lpuVirtualKey, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p, %p, %p, %p\n", pNode, lpuModifiers, lpuVirtualKey, lphKL); pNode = NULL; } _SEH2_END; @@ -740,7 +740,7 @@ NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCo } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p, %p\n", phList, pdwCount); _SEH2_YIELD(goto Quit); } _SEH2_END; @@ -1038,12 +1038,12 @@ NtUserGetImeInfoEx( _SEH2_TRY { - ProbeForWrite(pImeInfoEx, sizeof(*pImeInfoEx), 1); + ProbeForRead(pImeInfoEx, sizeof(*pImeInfoEx), 1); ImeInfoEx = *pImeInfoEx; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pImeInfoEx); _SEH2_YIELD(goto Quit); } _SEH2_END; @@ -1055,11 +1055,12 @@ NtUserGetImeInfoEx( _SEH2_TRY { + ProbeForWrite(pImeInfoEx, sizeof(*pImeInfoEx), 1); *pImeInfoEx = ImeInfoEx; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pImeInfoEx); ret = FALSE; } _SEH2_END; @@ -1158,7 +1159,7 @@ NtUserSetImeInfoEx(PIMEINFOEX pImeInfoEx) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pImeInfoEx); _SEH2_YIELD(goto Quit); } _SEH2_END; @@ -2020,7 +2021,7 @@ PWND FASTCALL co_IntCreateDefaultImeWindow(PWND pwndTarget, HINSTANCE hInst) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pimeui); } _SEH2_END; } @@ -2051,7 +2052,7 @@ BOOL FASTCALL IntImeCanDestroyDefIMEforChild(PWND pImeWnd, PWND pwndTarget) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pimeui); } _SEH2_END; @@ -2096,7 +2097,7 @@ BOOL FASTCALL IntImeCanDestroyDefIME(PWND pImeWnd, PWND pwndTarget) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pimeui); } _SEH2_END; @@ -2205,7 +2206,7 @@ BOOL FASTCALL IntCheckImeShowStatus(PWND pwndIme, PTHREADINFO pti) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pimeui); pwndIMC = NULL; } _SEH2_END; @@ -2260,7 +2261,7 @@ IntSendMessageToUI(PTHREADINFO ptiIME, PIMEUI pimeui, UINT uMsg, WPARAM wParam, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pimeui); pwndUI = NULL; } _SEH2_END; @@ -2277,7 +2278,7 @@ IntSendMessageToUI(PTHREADINFO ptiIME, PIMEUI pimeui, UINT uMsg, WPARAM wParam, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pimeui); _SEH2_YIELD(goto Quit); } _SEH2_END; @@ -2302,7 +2303,7 @@ IntSendMessageToUI(PTHREADINFO ptiIME, PIMEUI pimeui, UINT uMsg, WPARAM wParam, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p\n", pimeui); _SEH2_YIELD(goto Quit); } _SEH2_END; @@ -2376,7 +2377,7 @@ VOID FASTCALL IntNotifyImeShowStatus(PWND pImeWnd) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - ERR("!!!\n"); + ERR("%p, %p\n", pImeWnd, pimeui); if (pti != ptiIME) KeDetachProcess();
1 year, 9 months
1
0
0
0
[reactos] 01/01: [NOTEPAD] LoadIcon() needs no DestroyIcon() (#5142)
by Serge Gautherie
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3615e7c122004cb703790…
commit 3615e7c122004cb703790eadd32a8acdc0eb35be Author: Serge Gautherie <32623169+SergeGautherie(a)users.noreply.github.com> AuthorDate: Mon Mar 20 22:19:30 2023 +0100 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Mar 21 06:19:30 2023 +0900 [NOTEPAD] LoadIcon() needs no DestroyIcon() (#5142) CORE-18369 --- base/applications/notepad/dialog.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/base/applications/notepad/dialog.c b/base/applications/notepad/dialog.c index cc5efe0743f..b972dbb08bc 100644 --- a/base/applications/notepad/dialog.c +++ b/base/applications/notepad/dialog.c @@ -900,11 +900,9 @@ VOID DIALOG_HelpAboutNotepad(VOID) TCHAR szNotepad[MAX_STRING_LEN]; TCHAR szNotepadAuthors[MAX_STRING_LEN]; - HICON notepadIcon = LoadIcon(Globals.hInstance, MAKEINTRESOURCE(IDI_NPICON)); - LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad)); LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, ARRAY_SIZE(szNotepadAuthors)); - ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors, notepadIcon); - DestroyIcon(notepadIcon); + ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors, + LoadIcon(Globals.hInstance, MAKEINTRESOURCE(IDI_NPICON))); }
1 year, 9 months
1
0
0
0
[reactos] 01/01: [MSPAINT] Move '#include <crtdbg.h>' and add _CRTDBG_MAP_ALLOC
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ed03768b1b8e288f8782d…
commit ed03768b1b8e288f8782db35a4ba4547dd7ae38c Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Mon Mar 20 22:59:05 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Mon Mar 20 22:59:05 2023 +0900 [MSPAINT] Move '#include <crtdbg.h>' and add _CRTDBG_MAP_ALLOC CORE-18867 --- base/applications/mspaint/main.cpp | 4 ---- base/applications/mspaint/precomp.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/base/applications/mspaint/main.cpp b/base/applications/mspaint/main.cpp index 82b70d9dba5..f24a12b1a1f 100644 --- a/base/applications/mspaint/main.cpp +++ b/base/applications/mspaint/main.cpp @@ -8,10 +8,6 @@ #include "precomp.h" -#ifdef _DEBUG -#include <crtdbg.h> -#endif - /* FUNCTIONS ********************************************************/ POINT start; diff --git a/base/applications/mspaint/precomp.h b/base/applications/mspaint/precomp.h index cd24f7f8379..c73cd809a75 100644 --- a/base/applications/mspaint/precomp.h +++ b/base/applications/mspaint/precomp.h @@ -26,6 +26,10 @@ #include <stdlib.h> #include <shellapi.h> #include <htmlhelp.h> +#ifdef _DEBUG + #define _CRTDBG_MAP_ALLOC + #include <crtdbg.h> +#endif #define NDEBUG #include <debug.h>
1 year, 9 months
1
0
0
0
← Newer
1
2
3
4
5
6
...
14
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Results per page:
10
25
50
100
200