G
Platform SDK schrieb:
The AdjustWindowRectEx function calculates the required size of the window rectangle, based on the desired size of the client rectangle. The window rectangle can then be passed to the CreateWindowEx function to create a window whose client area is the desired size.
Ich machs allerdings so:
int AdjustWindowSize(HWND hWnd, int cx, int cy)
{
RECT iRt, oRt;
int xd, yd;
int mx, my;
GetWindowRect(hWnd,&oRt);
GetClientRect(hWnd,&iRt);
oRt.right=oRt.right-oRt.left;
oRt.bottom=oRt.bottom-oRt.top;
xd=oRt.right-iRt.right; // Differenz von Fenster-Breite und Client-Breite
yd=oRt.bottom-iRt.bottom; // Differenz von Fenster-Höhe und Client-Höhe
// Das hier habe ich nur um das Fenster zu zentrieren
// cx+xd ergibt die gesuchte Fensterbreite
// cy+yd die gewünschte Fensterhöhe
mx=(GetSystemMetrics(SM_CXSCREEN)/2)-((cx+xd)/2);
my=(GetSystemMetrics(SM_CYSCREEN)/2)-((cy+yd)/2);
MoveWindow(hWnd,mx,my,(cx+xd),(yd+cy),true);
return 1;
}