INF: Algorithm Creates Window Same Size As Full-Screen Window

ID Number: Q36319

2.03 2.10 3.00 3.10

WINDOWS

Summary:

The following algorithm creates a window the size of the "standard"

full-screen window:

int winBorder, cxBorder, cyBorder,

cxMargin, cxBAMargin, cyBAMargin,

x, y, cx, cy;

/* Get the user-defined border width */

winBorder = GetProfileInt("windows", "BorderWidth", 5);

/* It must be in the range of 0 < winBorder < 51 */

if (winBorder < 1) {

winBorder = 1;

} else if (winBorder > 50) {

winBorder = 50;

}

/* Get some internal system metrics to determine extra scaling */

cxBorder = GetSystemMetrics (SM_CXBORDER);

cyBorder = GetSystemMetrics (SM_CYBORDER);

cxMargin = (cxBorder * winBorder) + cxBorder;

/* Byte align the border */

cxBAMargin = (((cxMargin + 7) & 0xFFF8) - cxMargin);

cyBAMargin = cxBAMargin * cyBorder / cxBorder;

x = cxBAMargin;

y = cyBAMargin;

cx = CW_USEDEFAULT;

cy = 0;

hWnd = CreateWindow(szAppName, szTitle, WS_OVERLAPPEDWINDOW,

x, y, cx, cy,

NULL, NULL, hInstance, NULL);

Additional reference words: 2.03 2.10 2.x 3.00 3.10 3.x