Skip to content

Commit 07809c4

Browse files
committed
updated StaticDialog.cpp
1 parent 5fff55f commit 07809c4

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

src/StaticDialog/StaticDialog.cpp

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
// This file is part of the MultiReplace plugin for Notepad++.
2-
// Copyright (C) 2023 Thomas Knoefel
3-
//
1+
// This file is part of Notepad++ project
2+
// Copyright (C)2022 Don HO <don.h@free.fr>
3+
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
7-
// (at your option) any later version.
7+
// at your option any later version.
88
//
99
// This program is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU General Public License for more details.
1313
//
1414
// You should have received a copy of the GNU General Public License
15-
// along with this program. If not, see <https://www.gnu.org/licenses/>.
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
#include <stdio.h>
1818
#include <string>
@@ -56,12 +56,12 @@ void StaticDialog::goToCenter()
5656
RECT rc;
5757
::GetClientRect(_hParent, &rc);
5858
POINT center;
59-
center.x = rc.left + (rc.right - rc.left)/2;
60-
center.y = rc.top + (rc.bottom - rc.top)/2;
59+
center.x = rc.left + (rc.right - rc.left) / 2;
60+
center.y = rc.top + (rc.bottom - rc.top) / 2;
6161
::ClientToScreen(_hParent, &center);
6262

63-
int x = center.x - (_rc.right - _rc.left)/2;
64-
int y = center.y - (_rc.bottom - _rc.top)/2;
63+
int x = center.x - (_rc.right - _rc.left) / 2;
64+
int y = center.y - (_rc.bottom - _rc.top) / 2;
6565

6666
::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
6767
}
@@ -80,7 +80,7 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing
8080

8181
if ((testPositionRc.left != candidateRc.left) || (testPositionRc.top != candidateRc.top))
8282
{
83-
::MoveWindow(_hSelf, candidateRc.left, candidateRc.top,
83+
::MoveWindow(_hSelf, candidateRc.left, candidateRc.top,
8484
candidateRc.right - candidateRc.left, candidateRc.bottom - candidateRc.top, TRUE);
8585
}
8686
}
@@ -128,7 +128,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const
128128
// rect would be at least partially visible on a monitor
129129

130130
::GetMonitorInfo(hMon, &mi);
131-
131+
132132
int margin = ::GetSystemMetrics(SM_CYBORDER) + ::GetSystemMetrics(SM_CYSIZEFRAME) + ::GetSystemMetrics(SM_CYCAPTION);
133133

134134
// require that the title bar of the window be in a viewable place so the user can see it to grab it with the mouse
@@ -153,7 +153,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const
153153
if (!rectPosViewableWithoutChange)
154154
{
155155
// reposition rect so that it would be viewable on current/nearest monitor, centering if reasonable
156-
156+
157157
LONG testRectWidth = testPositionRc.right - testPositionRc.left;
158158
LONG testRectHeight = testPositionRc.bottom - testPositionRc.top;
159159
LONG monWidth = mi.rcWork.right - mi.rcWork.left;
@@ -171,7 +171,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const
171171
return returnRc;
172172
}
173173

174-
HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate)
174+
HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE** ppMyDlgTemplate)
175175
{
176176
// Get Dlg Template resource
177177
HRSRC hDialogRC = ::FindResource(_hInst, MAKEINTRESOURCE(dialogID), RT_DIALOG);
@@ -182,18 +182,18 @@ HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplat
182182
if (!hDlgTemplate)
183183
return NULL;
184184

185-
DLGTEMPLATE *pDlgTemplate = static_cast<DLGTEMPLATE *>(::LockResource(hDlgTemplate));
185+
DLGTEMPLATE* pDlgTemplate = static_cast<DLGTEMPLATE*>(::LockResource(hDlgTemplate));
186186
if (!pDlgTemplate)
187187
return NULL;
188188

189189
// Duplicate Dlg Template resource
190190
unsigned long sizeDlg = ::SizeofResource(_hInst, hDialogRC);
191191
HGLOBAL hMyDlgTemplate = ::GlobalAlloc(GPTR, sizeDlg);
192-
*ppMyDlgTemplate = static_cast<DLGTEMPLATE *>(::GlobalLock(hMyDlgTemplate));
192+
*ppMyDlgTemplate = static_cast<DLGTEMPLATE*>(::GlobalLock(hMyDlgTemplate));
193193

194194
::memcpy(*ppMyDlgTemplate, pDlgTemplate, sizeDlg);
195195

196-
DLGTEMPLATEEX *pMyDlgTemplateEx = reinterpret_cast<DLGTEMPLATEEX *>(*ppMyDlgTemplate);
196+
DLGTEMPLATEEX* pMyDlgTemplateEx = reinterpret_cast<DLGTEMPLATEEX*>(*ppMyDlgTemplate);
197197
if (pMyDlgTemplateEx->signature == 0xFFFF)
198198
pMyDlgTemplateEx->exStyle |= WS_EX_LAYOUTRTL;
199199
else
@@ -228,7 +228,7 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
228228
{
229229
if (isRTL)
230230
{
231-
DLGTEMPLATE *pMyDlgTemplate = NULL;
231+
DLGTEMPLATE* pMyDlgTemplate = NULL;
232232
HGLOBAL hMyDlgTemplate = makeRTLResource(dialogID, &pMyDlgTemplate);
233233
_hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
234234
::GlobalFree(hMyDlgTemplate);
@@ -252,28 +252,28 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L
252252
{
253253
switch (message)
254254
{
255-
case WM_INITDIALOG:
256-
{
257-
StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(lParam);
258-
pStaticDlg->_hSelf = hwnd;
259-
::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast<LONG_PTR>(lParam));
260-
::GetWindowRect(hwnd, &(pStaticDlg->_rc));
261-
pStaticDlg->run_dlgProc(message, wParam, lParam);
255+
case WM_INITDIALOG:
256+
{
257+
StaticDialog* pStaticDlg = reinterpret_cast<StaticDialog*>(lParam);
258+
pStaticDlg->_hSelf = hwnd;
259+
::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast<LONG_PTR>(lParam));
260+
::GetWindowRect(hwnd, &(pStaticDlg->_rc));
261+
pStaticDlg->run_dlgProc(message, wParam, lParam);
262262

263-
return TRUE;
264-
}
263+
return TRUE;
264+
}
265265

266-
default:
267-
{
268-
StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
269-
if (!pStaticDlg)
270-
return FALSE;
271-
return pStaticDlg->run_dlgProc(message, wParam, lParam);
272-
}
266+
default:
267+
{
268+
StaticDialog* pStaticDlg = reinterpret_cast<StaticDialog*>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
269+
if (!pStaticDlg)
270+
return FALSE;
271+
return pStaticDlg->run_dlgProc(message, wParam, lParam);
272+
}
273273
}
274274
}
275275

276-
void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point)
276+
void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT& point)
277277
{
278278
RECT rc, rc2;
279279
::GetWindowRect(handle, &rc);
@@ -283,31 +283,31 @@ void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT
283283

284284
switch (pos)
285285
{
286-
case PosAlign::left:
287-
{
288-
::GetWindowRect(handle2Align, &rc2);
289-
point.x -= rc2.right - rc2.left;
290-
break;
291-
}
292-
case PosAlign::right:
293-
{
294-
::GetWindowRect(handle, &rc2);
295-
point.x += rc2.right - rc2.left;
296-
break;
297-
}
298-
case PosAlign::top:
299-
{
300-
::GetWindowRect(handle2Align, &rc2);
301-
point.y -= rc2.bottom - rc2.top;
302-
break;
303-
}
304-
case PosAlign::bottom:
305-
{
306-
::GetWindowRect(handle, &rc2);
307-
point.y += rc2.bottom - rc2.top;
308-
break;
309-
}
286+
case PosAlign::left:
287+
{
288+
::GetWindowRect(handle2Align, &rc2);
289+
point.x -= rc2.right - rc2.left;
290+
break;
291+
}
292+
case PosAlign::right:
293+
{
294+
::GetWindowRect(handle, &rc2);
295+
point.x += rc2.right - rc2.left;
296+
break;
297+
}
298+
case PosAlign::top:
299+
{
300+
::GetWindowRect(handle2Align, &rc2);
301+
point.y -= rc2.bottom - rc2.top;
302+
break;
303+
}
304+
case PosAlign::bottom:
305+
{
306+
::GetWindowRect(handle, &rc2);
307+
point.y += rc2.bottom - rc2.top;
308+
break;
309+
}
310310
}
311311

312312
::ScreenToClient(_hSelf, &point);
313-
}
313+
}

0 commit comments

Comments
 (0)