MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / SnapToDefaultPos

Function SnapToDefaultPos

src/Notepad2.c:6147–6179  ·  view source on GitHub ↗

============================================================================= SnapToDefaultPos() Aligns Notepad2 to the default window position on the current screen

Source from the content-addressed store, hash-verified

6145//
6146//
6147void SnapToDefaultPos ( HWND hwnd )
6148{
6149 WINDOWPLACEMENT wndpl;
6150 HMONITOR hMonitor;
6151 MONITORINFO mi;
6152 int x, y, cx, cy;
6153 RECT rcOld;
6154 GetWindowRect ( hwnd, &rcOld );
6155 hMonitor = MonitorFromRect ( &rcOld, MONITOR_DEFAULTTONEAREST );
6156 mi.cbSize = sizeof ( mi );
6157 GetMonitorInfo ( hMonitor, &mi );
6158 y = mi.rcWork.top + 16;
6159 cy = mi.rcWork.bottom - mi.rcWork.top - 32;
6160 cx = min ( mi.rcWork.right - mi.rcWork.left - 32, cy );
6161 x = mi.rcWork.right - cx - 16;
6162 wndpl.length = sizeof ( WINDOWPLACEMENT );
6163 wndpl.flags = WPF_ASYNCWINDOWPLACEMENT;
6164 wndpl.showCmd = SW_RESTORE;
6165 wndpl.rcNormalPosition.left = x;
6166 wndpl.rcNormalPosition.top = y;
6167 wndpl.rcNormalPosition.right = x + cx;
6168 wndpl.rcNormalPosition.bottom = y + cy;
6169 if ( EqualRect ( &rcOld, &wndpl.rcNormalPosition ) ) {
6170 x = mi.rcWork.left + 16;
6171 wndpl.rcNormalPosition.left = x;
6172 wndpl.rcNormalPosition.right = x + cx;
6173 }
6174 if ( GetDoAnimateMinimize() ) {
6175 DrawAnimatedRects ( hwnd, IDANI_CAPTION, &rcOld, &wndpl.rcNormalPosition );
6176 OffsetRect ( &wndpl.rcNormalPosition, mi.rcMonitor.left - mi.rcWork.left, mi.rcMonitor.top - mi.rcWork.top );
6177 }
6178 SetWindowPlacement ( hwnd, &wndpl );
6179}
6180//=============================================================================
6181//
6182// ShowNotifyIcon()

Callers 1

MsgCommandFunction · 0.85

Calls 1

GetDoAnimateMinimizeFunction · 0.85

Tested by

no test coverage detected