Hi
I got a standard window to display with a button inside but I don't know how to lock the button to the corner.
I put the code for the button in WM_CREATE:
Code:
case WM_CREATE:
{
HWND hwndButton = CreateWindow(
L"BUTTON", // Predefined class; Unicode assumed
L"OK", // Button text
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles
10, // x position
10, // y position
100, // Button width
100, // Button height
hWnd, // Parent window
NULL, // No menu.
(HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
NULL); // Pointer not needed.
}
break;
Now I am trying to put the button in the lower right corner with GetWindowRect and SetWindowPos but I don't know how to can anybody help?
Code:
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
BOOL GetWindowRect(
HWND hWnd,
LPRECT lpRect
);
//Trying to set the Variables for SetWindowPos so the button is always in the lower right corner
X = lpRect.right - ButtonHSize - ButtonRightPadding
Y = lpRect.bottom - ButtonVSize - ButtonBottomPadding
cx = lpRect.right - ButtonRightPadding
cy = lpRect.bottom - ButtonBottomPadding
BOOL SetWindowPos(
[in] HWND hwndButton,
NULL,
[in] int X,
[in] int Y,
[in] int cx,
[in] int cy,
[in] UINT uFlags
);
EndPaint(hWnd, &ps);
}
break;
Is that the right spot for that code and how do I make it work?