| 1740 | |
| 1741 | |
| 1742 | POINT CenterWindow(int aWidth, int aHeight) |
| 1743 | // Given a the window's width and height, calculates where to position its upper-left corner |
| 1744 | // so that it is centered EVEN IF the task bar is on the left side or top side of the window. |
| 1745 | // This does not currently handle multi-monitor systems explicitly, since those calculations |
| 1746 | // require API functions that don't exist in Win95/NT (and thus would have to be loaded |
| 1747 | // dynamically to allow the program to launch). Therefore, windows will likely wind up |
| 1748 | // being centered across the total dimensions of all monitors, which usually results in |
| 1749 | // half being on one monitor and half in the other. This doesn't seem too terrible and |
| 1750 | // might even be what the user wants in some cases (i.e. for really big windows). |
| 1751 | { |
| 1752 | RECT rect; |
| 1753 | SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0); // Get desktop rect excluding task bar. |
| 1754 | // Note that rect.left will NOT be zero if the taskbar is on docked on the left. |
| 1755 | // Similarly, rect.top will NOT be zero if the taskbar is on docked at the top of the screen. |
| 1756 | POINT pt; |
| 1757 | pt.x = rect.left + (((rect.right - rect.left) - aWidth) / 2); |
| 1758 | pt.y = rect.top + (((rect.bottom - rect.top) - aHeight) / 2); |
| 1759 | return pt; |
| 1760 | } |
| 1761 | |
| 1762 | |
| 1763 | |