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
+
4
4
// This program is free software: you can redistribute it and/or modify
5
5
// it under the terms of the GNU General Public License as published by
6
6
// 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.
8
8
//
9
9
// This program is distributed in the hope that it will be useful,
10
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
12
// GNU General Public License for more details.
13
13
//
14
14
// 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/>.
16
16
17
17
#include < stdio.h>
18
18
#include < string>
@@ -56,12 +56,12 @@ void StaticDialog::goToCenter()
56
56
RECT rc;
57
57
::GetClientRect (_hParent, &rc);
58
58
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 ;
61
61
::ClientToScreen (_hParent, ¢er);
62
62
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 ;
65
65
66
66
::SetWindowPos (_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
67
67
}
@@ -80,7 +80,7 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing
80
80
81
81
if ((testPositionRc.left != candidateRc.left ) || (testPositionRc.top != candidateRc.top ))
82
82
{
83
- ::MoveWindow (_hSelf, candidateRc.left, candidateRc.top,
83
+ ::MoveWindow (_hSelf, candidateRc.left, candidateRc.top,
84
84
candidateRc.right - candidateRc.left, candidateRc.bottom - candidateRc.top, TRUE );
85
85
}
86
86
}
@@ -128,7 +128,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const
128
128
// rect would be at least partially visible on a monitor
129
129
130
130
::GetMonitorInfo (hMon, &mi);
131
-
131
+
132
132
int margin = ::GetSystemMetrics (SM_CYBORDER) + ::GetSystemMetrics (SM_CYSIZEFRAME) + ::GetSystemMetrics (SM_CYCAPTION);
133
133
134
134
// 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
153
153
if (!rectPosViewableWithoutChange)
154
154
{
155
155
// reposition rect so that it would be viewable on current/nearest monitor, centering if reasonable
156
-
156
+
157
157
LONG testRectWidth = testPositionRc.right - testPositionRc.left ;
158
158
LONG testRectHeight = testPositionRc.bottom - testPositionRc.top ;
159
159
LONG monWidth = mi.rcWork .right - mi.rcWork .left ;
@@ -171,7 +171,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const
171
171
return returnRc;
172
172
}
173
173
174
- HGLOBAL StaticDialog::makeRTLResource (int dialogID, DLGTEMPLATE ** ppMyDlgTemplate)
174
+ HGLOBAL StaticDialog::makeRTLResource (int dialogID, DLGTEMPLATE** ppMyDlgTemplate)
175
175
{
176
176
// Get Dlg Template resource
177
177
HRSRC hDialogRC = ::FindResource (_hInst, MAKEINTRESOURCE (dialogID), RT_DIALOG);
@@ -182,18 +182,18 @@ HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplat
182
182
if (!hDlgTemplate)
183
183
return NULL ;
184
184
185
- DLGTEMPLATE * pDlgTemplate = static_cast <DLGTEMPLATE *>(::LockResource (hDlgTemplate));
185
+ DLGTEMPLATE* pDlgTemplate = static_cast <DLGTEMPLATE*>(::LockResource (hDlgTemplate));
186
186
if (!pDlgTemplate)
187
187
return NULL ;
188
188
189
189
// Duplicate Dlg Template resource
190
190
unsigned long sizeDlg = ::SizeofResource (_hInst, hDialogRC);
191
191
HGLOBAL hMyDlgTemplate = ::GlobalAlloc (GPTR, sizeDlg);
192
- *ppMyDlgTemplate = static_cast <DLGTEMPLATE *>(::GlobalLock (hMyDlgTemplate));
192
+ *ppMyDlgTemplate = static_cast <DLGTEMPLATE*>(::GlobalLock (hMyDlgTemplate));
193
193
194
194
::memcpy (*ppMyDlgTemplate, pDlgTemplate, sizeDlg);
195
195
196
- DLGTEMPLATEEX * pMyDlgTemplateEx = reinterpret_cast <DLGTEMPLATEEX *>(*ppMyDlgTemplate);
196
+ DLGTEMPLATEEX* pMyDlgTemplateEx = reinterpret_cast <DLGTEMPLATEEX*>(*ppMyDlgTemplate);
197
197
if (pMyDlgTemplateEx->signature == 0xFFFF )
198
198
pMyDlgTemplateEx->exStyle |= WS_EX_LAYOUTRTL;
199
199
else
@@ -228,7 +228,7 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
228
228
{
229
229
if (isRTL)
230
230
{
231
- DLGTEMPLATE * pMyDlgTemplate = NULL ;
231
+ DLGTEMPLATE* pMyDlgTemplate = NULL ;
232
232
HGLOBAL hMyDlgTemplate = makeRTLResource (dialogID, &pMyDlgTemplate);
233
233
_hSelf = ::CreateDialogIndirectParam (_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast <LPARAM>(this ));
234
234
::GlobalFree (hMyDlgTemplate);
@@ -252,28 +252,28 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L
252
252
{
253
253
switch (message)
254
254
{
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);
262
262
263
- return TRUE ;
264
- }
263
+ return TRUE ;
264
+ }
265
265
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
+ }
273
273
}
274
274
}
275
275
276
- void StaticDialog::alignWith (HWND handle, HWND handle2Align, PosAlign pos, POINT & point)
276
+ void StaticDialog::alignWith (HWND handle, HWND handle2Align, PosAlign pos, POINT& point)
277
277
{
278
278
RECT rc, rc2;
279
279
::GetWindowRect (handle, &rc);
@@ -283,31 +283,31 @@ void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT
283
283
284
284
switch (pos)
285
285
{
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
+ }
310
310
}
311
311
312
312
::ScreenToClient (_hSelf, &point);
313
- }
313
+ }
0 commit comments