Rev 299 | Rev 301 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 299 | Rev 300 | ||
---|---|---|---|
Line 132... | Line 132... | ||
132 | #define _MONITOR_DEFAULTTOPRIMARY 0x00000001 |
132 | #define _MONITOR_DEFAULTTOPRIMARY 0x00000001 |
133 | #define _MONITOR_DEFAULTTONEAREST 0x00000002 |
133 | #define _MONITOR_DEFAULTTONEAREST 0x00000002 |
134 | 134 | ||
135 | void _doMonitorAdjustments(LPRECT rcPlugin) { |
135 | void _doMonitorAdjustments(LPRECT rcPlugin) { |
136 | RECT rcMonitorWork; |
136 | RECT rcMonitorWork; |
137 | _MONITORINFO grMonitorInfo; |
- | |
138 | _HMONITOR hMonitor; |
137 | _HMONITOR hMonitor; |
- | 138 | _MONITORINFO grMonitorInfo = { sizeof(grMonitorInfo) }; |
|
- | 139 | int nXAdjust = 0, nYAdjust = 0, nPluginWidth, nPluginHeight, nMonitorWorkWidth, nMonitorWorkHeight; |
|
139 | 140 | ||
140 | hMonitor = _MonitorFromRect(rcPlugin, _MONITOR_DEFAULTTONEAREST); |
141 | hMonitor = _MonitorFromRect(rcPlugin, _MONITOR_DEFAULTTONEAREST); |
141 | if (hMonitor == NULL) return; |
142 | if (hMonitor == NULL) return; |
142 | 143 | ||
143 | memset(&grMonitorInfo, 0, sizeof(grMonitorInfo)); |
- | |
144 | grMonitorInfo.cbSize = sizeof(grMonitorInfo); |
- | |
145 | if (!_GetMonitorInfoA(hMonitor, &grMonitorInfo)) return; |
144 | if (!_GetMonitorInfoA(hMonitor, &grMonitorInfo)) return; |
146 | rcMonitorWork = grMonitorInfo.rcWork; |
145 | rcMonitorWork = grMonitorInfo.rcWork; |
147 | 146 | ||
148 | // Don't let the window exit the left/right borders of the monitor |
147 | // Don't let the window exit the left/right borders of the monitor |
- | 148 | nPluginWidth = rcPlugin->right - rcPlugin->left; |
|
149 | if ((rcPlugin->left < rcMonitorWork.left) && (rcPlugin->right > rcMonitorWork.right)) { |
149 | nMonitorWorkWidth = rcMonitorWork.right - rcMonitorWork.left; |
- | 150 | if (nPluginWidth > nMonitorWorkWidth) { |
|
- | 151 | // Window larger than screen width. Decrease the width! |
|
150 | rcPlugin->left = rcMonitorWork.left;; |
152 | rcPlugin->left = rcMonitorWork.left; |
151 | rcPlugin->right = rcMonitorWork.right; |
153 | rcPlugin->right = rcMonitorWork.right; |
152 | } |
154 | } |
153 | else if (rcPlugin->left < rcMonitorWork.left) { |
155 | else if (rcPlugin->left < rcMonitorWork.left) { |
154 | int nLeftAdjust = (rcMonitorWork.left - rcPlugin->left); |
156 | nXAdjust = rcMonitorWork.left - rcPlugin->left; |
155 | rcPlugin->left += nLeftAdjust; |
- | |
156 | rcPlugin->right += nLeftAdjust; |
- | |
157 | } |
157 | } |
158 | else if (rcPlugin->right > rcMonitorWork.right) { |
158 | else if (rcPlugin->right > rcMonitorWork.right) { |
159 | int nRightAdjust = (rcPlugin->right - rcMonitorWork.right); |
159 | nXAdjust = rcMonitorWork.right - rcPlugin->right; |
160 | rcPlugin->left -= nRightAdjust; |
- | |
161 | rcPlugin->right -= nRightAdjust; |
- | |
162 | } |
160 | } |
163 | 161 | ||
164 | // Don't let the window exit the top/bottom borders of the monitor |
162 | // Don't let the window exit the top/bottom borders of the monitor |
- | 163 | nPluginHeight = rcPlugin->bottom - rcPlugin->top; |
|
165 | if ((rcPlugin->top < rcMonitorWork.top) && (rcPlugin->bottom > rcMonitorWork.bottom)) { |
164 | nMonitorWorkHeight = rcMonitorWork.bottom - rcMonitorWork.top; |
- | 165 | if (nPluginHeight > nMonitorWorkHeight) { |
|
- | 166 | // Window larger than screen height. Decrease the height! |
|
166 | rcPlugin->top = rcMonitorWork.top; |
167 | rcPlugin->top = rcMonitorWork.top; |
167 | rcPlugin->bottom = rcMonitorWork.bottom; |
168 | rcPlugin->bottom = rcMonitorWork.bottom; |
168 | } |
169 | } |
169 | else if (rcPlugin->top < rcMonitorWork.top) { |
170 | else if (rcPlugin->top < rcMonitorWork.top) { |
170 | int nTopAdjust = (rcMonitorWork.top - rcPlugin->top); |
171 | nYAdjust = rcMonitorWork.top - rcPlugin->top; |
171 | rcPlugin->top += nTopAdjust; |
- | |
172 | rcPlugin->bottom += nTopAdjust; |
- | |
173 | } |
172 | } |
174 | else if (rcPlugin->bottom > rcMonitorWork.bottom) { |
173 | else if (rcPlugin->bottom > rcMonitorWork.bottom) { |
175 | int nBottomAdjust = (rcPlugin->bottom - rcMonitorWork.bottom); |
174 | nYAdjust = rcMonitorWork.bottom - rcPlugin->bottom; |
176 | rcPlugin->top -= nBottomAdjust; |
- | |
177 | rcPlugin->bottom -= nBottomAdjust; |
- | |
178 | } |
175 | } |
- | 176 | ||
- | 177 | OffsetRect(rcPlugin, nXAdjust, nYAdjust); |
|
179 | } |
178 | } |
180 | 179 | ||
181 | /* |
180 | /* |
182 | * Centers a window to the center of its parent form but avoids |
181 | * Centers a window to the center of its parent form but avoids |
183 | * being spread across two screens. |
182 | * being spread across two screens. |