MoveWindow的问题?
应用中有一对话,对话上放置有CStatic控件(用户可移动),对话退出时记录控件位置(GetWindowRect()得到);对话再次显示时,按记录位置显示控件(MoveWindow());
根据我的理解,MoveWindow()移动窗口(控件)位置是相对于父窗口的,所以:
已知:CStatic控件位置CRect MoveRect;
在dlg的WM_SHOWWINDOW消息处理中:
CRect pParentWndRect;
GetWindowRect(&pParentWndRect);
CStatic *pMoveWnd;
pMoveWnd=(CStatic *)GetDlgItem(IDC_STATIC_CTL1);
pMoveWnd->MoveWindow(MoveRect.left-pParentWndRect.left,
MoveRect.top-pParentWndRect.top,MoveRect.width(),MoveRect.height());
但控件位置有时正确,有时不正确,我自己也觉得我的方法不正规,但又没有更好的办法,请指点!