Click here to Skip to main content
15,076,130 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am quite desperate to resolve this very annoying issue :( . I am trying to display a child window on parent window.
The instantiation is fine and the window shows what it should.
At some point the window need to be resized. But for some reason, when I using MoveWindow function it leaves blank space on the top of the parent window. Here is the screenshot:<ahref>[^]

Here is the code example:
HWND hwnd  // Comes from external function. Was defined as WS_CHILD previously
HWND hwndParent     = ::GetParent(hwnd);  
RECT parentRect     = {0,0,0,0};  
RECT childRect      = {0,0,0,0};  
::GetClientRect(hwndParent, &parentRect);  // Suppose it returns {0,0,600,300}  

BOOL ok = ::MoveWindow(hwnd, 0, 0, 600, 300, true);  
::GetClientRect(hwnd, &childRect);  // Will return {0,0,584,297}

Since the rect is smaller than asked not entire window rect will be used.
WHY ?????

What am I doing wrong? Did I forgot some flags with window initialization?!

GetClientRect[^] returns how big the DRAWABLE (client area) part of the window is.
This is the parent windows excluding title bar, borders and what appears to be a tool bar in your situation.
If you want the full area of the windows you can use GetWindowRect[^], but remember this includes the title bar and borders.
Iron-Eagle 17-Oct-11 11:03am
That is exactly what I want. I receive drawable area of the size (600, 300). So why when I try to move child window inside it I only get (584,297)?
It seem like In child window somehow ClientRect != WindowRect after MoveWindow and I do not understand why? They were completely equal before.
In addition, if you will look at the picture, you will see that is starts to draw not at 0,0 but at another point, like it leaving some space no idea for what.
Take a look at this section[^] in MSDN, which may help.
Iron-Eagle 17-Oct-11 11:23am
Sorry, it does not help.
As you can see, I am doing exactly what they are - taking clientRect and placing child window inside. I am giving coordinates of start - (0,0), yet it starts from much below it.
Richard MacCutchan 17-Oct-11 11:59am
The only thing I can think is that somehow the system believes that your child window is bigger than what is being displayed. Perhaps you could post a bit more code round about when you create the child window to see if something stands out.
Iron-Eagle 17-Oct-11 15:03pm
Well... you can see this Spy++ information, before and after the MoveWindow call.
I can extract the same information from the parent window if you like.[^]
The problem was WS_POPUP flag to the parent window.
Very strange. As far as I know it was not suppose to have such an effect.

Thanks for everyone!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900