:: MoveWindow保留空白区域 [英] ::MoveWindow leaves blank area

查看:82
本文介绍了:: MoveWindow保留空白区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常想解决这个非常烦人的问题:(.我正试图在父窗口上显示子窗口.
实例化很好,并且窗口显示了应该的内容.
在某些时候,需要调整窗口的大小.但是由于某些原因,当我使用MoveWindow函数时,它将在父窗口的顶部留下空白.这是屏幕截图:< ahref> http://i32.fastpic.ru/big/2011/1016/39/9e4460be87c03499e8b183a130902d39.png [

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>http://i32.fastpic.ru/big/2011/1016/39/9e4460be87c03499e8b183a130902d39.png[^]

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}



由于rect小于要求的矩形,因此不会使用整个窗口rect.
为什么?????

我究竟做错了什么?我是否在窗口初始化时忘记了一些标志?!



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?!

推荐答案

^ ]返回窗口的DRAWABLE(客户区域)部分的大小.
这是父窗口,不包括标题栏,边框和您所处情况下的工具栏.
如果需要整个窗口,则可以使用 GetWindowRect [
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.


看看此部分 [ ^ ]可能会有所帮助.
Take a look at this section[^] in MSDN, which may help.


问题是父窗口的WS_POPUP标志.
很奇怪.据我所知,这不是应该产生的效果.

谢谢大家!
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!


这篇关于:: MoveWindow保留空白区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆