Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ...
I create the A MFC dialog based application. In that I create the report using the listcontrol.
As the record changes accordingly the record from the database. I want to change the dialog box size as per its content.
I read about it , by using on overriding the OnSize() method. but i Till unable to do this.
So please help me.
Posted
Updated 22-Apr-13 23:46pm
v2
Comments
Style-7 1-May-13 8:24am    
Do not change size of dialog box^ too many problems. Use list control with scroll bars or etc.

For programmatiaclly change the window size you may use CWnd::SetWindowPos[^] method.
The OnSize event handler is called by the framework after the window's size changed. You may use it to accordingly resize dialog child controls.
 
Share this answer
 
Comments
Yogesh25 16-May-13 3:28am    
// Resize the Dialog
Report reportDlg(AfxGetMainWnd()) ;
CRect rect10 ;
CWnd *pWnd1 = reportDlg.GetDlgItem(IDD_REPORT);

// CWnd *pWnd = GetDlgItem(IDD_REPORT) ;
pWnd1->GetWindowRect(&rect10);
ScreenToClient(&rect10);
pWnd1->SetWindowPos(NULL, 0, 0, rect10.Width(), rect8.bottom, SWP_NOMOVE |SWP_NOZORDER | SWP_NOACTIVATE );

I use this code for Dialog for resize as per content, still it not work. Please suggest any idea.
calculate the control position when the application is started.

according to that maintain same length between controls.

for example:
CRect rc;
GetDlgItem(IDC_EDIT)->GetWindowRect(&rc);


height = rc.Height();
width = rc.Width();

rc.top = rcDlg.top ;
rc.bottom = rc.top + height;
rc.left = center_position - width ;
rc.right = rc.left +width;

GetDlgItem(IDC_EDIT)->MoveWindow(rc);
 
Share this answer
 
v2
Comments
Yogesh25 16-May-13 2:57am    
Hi Uday ...
I use your code, but still it not work.
I have generate the Report, which content the dynamic growable(which i build) List Control. I want to adjust the window dialog of Report as per Content of ListControl.
P Uday kishore 17-May-13 6:07am    
got any other solution??
Yogesh25 20-May-13 4:53am    
No, I have to change the dialog windows as per the my listcontrol, I enable do this.but unable to change the size of dialog as per contents.
So, please any suggestion how to do it.

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