Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a dialog and I want to rezie this dilog with code, but I don't konw how to do it.
Posted

1 solution

You can use SetWindowPos :
C++
this->SetWindowPos(NULL,0,0,newWidth,newHeight,SWP_NOMOVE | SWP_NOZORDER);

This will change the size of the dialog, but you will need to move and resize the control inside the dialog using the same function but with the CWnd of the control.
You should put this code in the OnSize members of the dialog and use the client width and height provided.
C++
CWnd* pCtrl = GetDlgItem(IDC_CONTROL1);
// keep it centered
CRect rectCtrl;
pCtrl->GetWindowRect(rectCtrl);
pCtrl->SetWindowPos(NULL,(dialogWidth-rectCtrl.Width())/2,(dialogHeight-rectCtrl.Height())/2,0,0,SWP_NOSIZE | SWP_NOZORDER);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900