============================================================================= SnapToDefaultPos() Aligns Notepad2 to the default window position on the current screen
| 6145 | // |
| 6146 | // |
| 6147 | void 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() |
no test coverage detected