I'm creating a notepad, and I've created a child window in the size of the parent window (so the child fit the entire parent window) of text...
I want to resize the child window, if the user resize (with the mouse) the parent window, but nothing works for me :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
void AddEditHandle(HWND hwnd) // Creating the text window
{
HWND Edit_Handle = NULL;
void AddEditHandle(HWND hwnd) // Creating the text window
{
Edit_Handle = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", NULL, WS_CHILD | WS_VSCROLL | WS_HSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_LEFT | ES_MULTILINE |
ES_WANTRETURN , 0, 0, 780, 560, hwnd, NULL, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
if (Edit_Handle == NULL)
MessageBox(NULL, "Could not create edit control!", "Error", MB_OK | MB_ICONERROR);
ShowWindow(Edit_Handle, SW_SHOW);
SetFocus(Edit_Handle);
}
|
This function creates the child window (parent window is 600X800)....
It fits perfect, and looks like it should be.. but when I want to resize it, the child window doesnt move.. only the parent...
so I've added this code to WndProc :
1 2 3 4 5
|
case WM_SIZE:
{
MoveWindow(Edit_Handle, 0, 0, LOWORD(lParam), HIWORD(lParam), false);
}
break;
|
Though there is no change, the child window still doesnt move...
How can I fix this?
Thanks!
EDIT :
I had an error of 1400 using GetLastError, meaning of invalid handler...
Insted of delcaring the variable as static (I've initialized Edit_Handler inside WndProc) I've used it as a global variable, and now it works using this code :
1 2 3 4 5 6
|
case WM_SIZE:
{
if(0 == MoveWindow(Edit_Handle, 0, 0, LOWORD(lParam), HIWORD(lParam), false))
dwLastError = GetLastError(); // Getting errors
}
break;
|
Thanks for you'r help guys!