Jump to content
  • Advertisement
Sign in to follow this  
Decrius

Resize child window

This topic is 4410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I made a window, in the window I created 4 child windows:
HWND Create_Window_Child1(HWND hParent, char *Classname, int win_width, int win_height)
{
    return CreateWindowEx(
                 WS_EX_CLIENTEDGE, // give it a standard border
                 Classname,
                 NULL,
                 WS_VISIBLE | WS_CHILD,
                 1, 28, (((win_width-10)/2)-2), (((win_height-100)/2)-1),
                 hParent,
                 NULL, GetModuleHandle(0), NULL
               );
}
HWND Create_Window_Child2(HWND hParent, char *Classname, int win_width, int win_height)
{
    return CreateWindowEx(
                 WS_EX_CLIENTEDGE, // give it a standard border
                 Classname,
                 NULL,
                 WS_VISIBLE | WS_CHILD,
                 1, 28+(((win_height-100)/2)-1)+4, (((win_width-10)/2)-2), (((win_height-100)/2)-2),
                 hParent,
                 NULL, GetModuleHandle(0), NULL
               );
}
HWND Create_Window_Child3(HWND hParent, char *Classname, int win_width, int win_height)
{
    return CreateWindowEx(
                 WS_EX_CLIENTEDGE, // give it a standard border
                 Classname,
                 NULL,
                 WS_VISIBLE | WS_CHILD,
                 1+(((win_width-10)/2)-2)+4, 28, (((win_width-10)/2)-2), (((win_height-100)/2)-2),
                 hParent,
                 NULL, GetModuleHandle(0), NULL
               );
}
HWND Create_Window_Child4(HWND hParent, char *Classname, int win_width, int win_height)
{
    return CreateWindowEx(
                 WS_EX_CLIENTEDGE, // give it a standard border
                 Classname,
                 NULL,
                 WS_VISIBLE | WS_CHILD,
                 1+(((win_width-10)/2)-2)+4, 28+(((win_height-100)/2)-1)+4, (((win_width-10)/2)-2), (((win_height-100)/2)-2),
                 hParent,
                 NULL, GetModuleHandle(0), NULL
               );
}

win_width and win_height are the sizes of the window (512x512). When I resize the window, I want that the 4 child windows will resize too, and not stay the same, but contract or expand. So I need to do something with the
case WM_SIZE:
{
return 0;
}

function. Should I use SendMessage( or MoveWindow( ? And how to use them, noone of them worked yet. I tried them all... Any suggestion is very appreciated :) Decrius

Share this post


Link to post
Share on other sites
Advertisement
Thank you for the reply.

So it should be:

SetWindowPos(hChild1, hWnd, 1, 28, (((LOWORD(lParam)-10)/2)-2), (((HIWORD(lParam)-100)/2)-1), 0);

But thats not working, the child isn't sizing at all. What's wrong?

Decrius

Share this post


Link to post
Share on other sites
Does it work if you call that outside your WM_SIZE handler? It works fine for me... Does SetWindowPos() return any error?

Share this post


Link to post
Share on other sites
Well, when the program starts, the first Child (which I try to resize) has a different size on start up, but when I resize the window, nothing happens. How can I check if the function gives an error?

Thank you anyways, :)

Decrius

PS: or do I have to redraw the window?

Share this post


Link to post
Share on other sites
Quote:
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
The only reason I can think that the function would fail is if your window handles are invalid, however.

EDIT: You shouldn't have to redraw the window, Windows will do that for you.

Share this post


Link to post
Share on other sites
I got some progress, the second parameter shouldn't be 'hWnd', but something like 'HWND_BOTTOM', 'HWND_NOTTOPMOST', 'HWND_TOP' or 'HWND_TOPMOST'. For nottopmost and topmost I see no difference. But for the bottom and top things, I see nothing until I resize the window, I see them flickering, flashing (whatever :p). The flashing border of the child grows if the window expands. But when I stop resizing the flashing is gone. Its like the child window is under the surface, but I don't see how to fix it...

Thanks so far anyways :)

Decrius

Share this post


Link to post
Share on other sites
First try to resize the window to a fixed size, perhaps you have a negative width or something.. I don't know what happens if you do.

Here's how you can check for errors:
You might need to #include <stdio.h> for sprintf

BOOL bRet;

bRet = SetWindowPos(
hChildWnd,
NULL,
0,
0,
500,
500,
SWP_NOZORDER
);
if(bRet == 0) {
DWORD dwErr = GetLastError();
char str[255];

sprintf(str, "Error %d", dwErr);
MessageBox(NULL, str, "Message", MB_OK);
}


Share this post


Link to post
Share on other sites
Quote:
Original post by Decrius
I got some progress, the second parameter shouldn't be 'hWnd', but something like 'HWND_BOTTOM', 'HWND_NOTTOPMOST', 'HWND_TOP' or 'HWND_TOPMOST'. For nottopmost and topmost I see no difference. But for the bottom and top things, I see nothing until I resize the window, I see them flickering, flashing (whatever :p). The flashing border of the child grows if the window expands. But when I stop resizing the flashing is gone. Its like the child window is under the surface, but I don't see how to fix it...

No necessarily [wink]
Quote:
hWndInsertAfter
[in] Handle to the window to precede the positioned window in the z-order. This parameter must be a window handle or one of the following values.
(Emphasis mine). Try what Erik Rufelt suggested, and see if that helps.

Share this post


Link to post
Share on other sites
Thank you :)

I put it in the program, when I start up the program, I get one message box with:

Error: 1400

But when I resize the window I get nothing.

How to find out what error 1400 means?

Decrius

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!