+ -
当前位置:首页 → 问答吧 → 求解释MoveWindow的用法

求解释MoveWindow的用法

时间:2011-12-25

来源:互联网

我用VC在画框框的时候,要移动一个子窗口form到指定的容器位置,弄不清楚以下这几个函数的用法,求达人指点迷津,


我的函数如下:

void GuideOnSize(HWND hwnd, UINT state, int cx, int cy)
{
  RECT rt;
  HWND hBorder = GetDlgItem(hwnd,GUIDE_STATIC_BORDER);
   
  GetClientRect(hBorder,&rt);//用这个
  POINT pt;
   
  GetWindowRect(hBorder,&rt);//还是用这个
  RECT rtw;

  GetClientRect(hBorder,&rtw);
  pt.y = rtw.top;
  pt.x= rtw.left;

  ClientToScreen(hwnd,&pt); //这个转换函数,是容器窗口,还是。

  ShowWindow(hDLG[0],SW_SHOW);
  MoveWindow(hDLG[0],pt.x,pt.y,rtw.right,rtw.bottom,TRUE);
   
}

这几个函数没有弄明白,move来move去,都move不进我的容器窗口啊。要疯了,求人指点。

作者: asmfox   发布时间: 2011-12-25

试试如下代码:
C/C++ code
CRect myRect;
HWND hBorder = GetDlgItem(hwnd,GUIDE_STATIC_BORDER);
GetClientRect(hBorder,&myRect);
ClientToScreen(myRect);
MoveWindow(hDLG[0],myRect.left, myRect.top,myRect.Width(), myRect.Height(),TRUE);

作者: fight_in_dl   发布时间: 2011-12-25