The code below
Void CMyDlg: : ChangeSize (UINT nID, int x, int y)//nID to control ID, x, y, respectively, of the length and width of the dialog
{
The CWnd * pWnd.
Void CWnd: : GetDlgItem (int nID, HWND * PHWND) const;
If (pWnd!=NULL)//determine whether is empty, because when creating the window will call OnSize function, but each control has not yet been created, Pwnd is empty
{
CRect rec.
PWnd - & gt; GetWindowRect (& amp; Rec);//access controls the size of the change before
ScreenToClient (& amp; Rec); //the control size transposition area coordinates in the dialog
Rec. Left=rec. Left * x/m_rect Width ();//in accordance with the proportion of new position adjustment space
Rec. Top=rec. Top * y/m_rect Height ();
Rec. Bottom=rec. Bottom * y/m_rect Height ();
Rec. Right=rec. Right. * x/m_rect Width ();
PWnd - & gt; MoveWindow (rec);//slip control
}
}
CodePudding user response:
ChangeSize statement to the static type? Remove theAnother CWnd * pWnd=GetDlgItem (nID);
CodePudding user response:
Thank you for your answer! The CWnd * pWnd=GetDlgItem (nID); So right!I was just a primer, can you tell me where I can see ChangeSize statement to the static type? please do.
CodePudding user response:
The CWnd: : ScreenToClientVoid ScreenToClient (LPPOINT LPPOINT) const;
Void ScreenToClient (LPRECT LPRECT) const;
This is the CWnd class
BOOL ScreenToClient (
The HWND HWND,//the window handle for the source coordinates
LPPOINT LPPOINT//address of structure containing coordinates
);
This is a Windows API
CodePudding user response:
Thank you very much! I see ~