父母调整尺寸时,孩子未调整尺寸 [英] Child not Resizing when parent Resize

查看:115
本文介绍了父母调整尺寸时,孩子未调整尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个Dialog及其OnInitDialog(),在运行时创建另一个无模式对话框,该对话框运行良好,但是当父窗口为调整大小"时,子窗口(无模型对话框)不会与父窗口一起移动.请有人帮忙使子窗口(无模型对话框)与父窗口一起移动?

[edit]代表OP
非常感谢所有回答我的查询的人,终于我实现了所需的东西.
我只是使用ClientToScreen()函数根据父窗口及其正常工作来获取坐标.
捕获下面的代码

  void  CParentDialog :: OnMove( int  x, int  y)
{
    CDialogEx :: OnMove(x,y);
    CRect rt;
    GetClientRect(& rt);
    ClientToScreen(& rt);
    如果(:: IsWindow(m_pModelles-> m_hWnd))
    {
        m_pModelles-> SetWindowPos(NULL,rt.left + 214,rt.bottom-  220 ,(rt.right-  10 )-(rt.left + 214, 222 ,SWP_SHOWWINDOW | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
    }
} 

解决方案

无模式对话框不会直接连接到父级,因此在父级移动或调整大小时不会发出信号.发生这些事件时,您将需要添加一些逻辑以向其发送消息.


对话框默认情况下不会停靠在其父窗口中.如果要实现它,可以在父窗口中添加OnSize()OnMove()处理程序,以将WM_SIZEWM_MOVE消息发送到子对话框.

当调整父窗口的大小时,这也可以处理子窗口的移动.

I am using a Dialog and on its OnInitDialog() ,creating another modeless dialog at run time ,the Dialog runs fine but when Parent window is Resize the child window(modelless dialog) is not moving with parent.Please someone help how to make child window (modelless dialog) move with parent Window?

[edit]on behalf of OP
Thanks a lot to all who replied to my query, Finally i achieved what was needed.
I just used ClientToScreen() function to get co ordinates according to parent window and its working fine.
Catch the code below

void CParentDialog::OnMove(int x, int y)
{
    CDialogEx::OnMove(x, y);
    CRect rt;
    GetClientRect(&rt);
    ClientToScreen(&rt);     
    if(::IsWindow (m_pModelles->m_hWnd ))
    {     
        m_pModelles->SetWindowPos(NULL,rt.left+214,rt.bottom-220,(rt.right- 10)-(rt.left+214,222,SWP_SHOWWINDOW|SWP_NOOWNERZORDER|SWP_NOACTIVATE);
    }
}

解决方案

A modeless dialog is not directly connected to the parent so it will not be signalled when the parent moves or resizes. You will need to add some logic to send it a message when those events occur.


Dialogs are by default not docked to their parent window. If you want to implement it, you may add OnSize() and OnMove() handlers to your parent window to send WM_SIZE and WM_MOVE messages to the child dialog.

This can also handle moving of the child window when resizing the parent (which is extraordinary behaviour).


这篇关于父母调整尺寸时,孩子未调整尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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