The interface
If (pWnd)
{
CRect the rect.
PWnd - & gt; GetWindowRect (& amp; The rect);//access controls the size of the change before
The ScreenToClient (& amp; The rect);//converting controls the size of the dialog in the regional coordinate
The rect. Left=the rect. Cx/m_rect left * Width (); Cx/m_rect.//adjust control size, Width () for the dialog box in proportion to the lateral changes of
The rect. Right=the rect. Cx/m_rect right * Width ();//cx storage is after change the width of the cy storage is after change the height of the
The rect. Top=the rect. Top * cy/m_rect Height ();//m_rect. Height () represents the changes in the height of the former main form
The rect. Bottom=the rect. Bottom * cy/m_rect Height ();
PWnd - & gt; MoveWindow (the rect);//set the control size
}
So to reduce the time control should be
Deal with relationship with easysize controls so much bad
How should do control change with the window size,
CodePudding user response:
Onsize in computing the relative position and then movewindowCodePudding user response:
Above is that is it not, to reduce the problem a lot should be how to calculateCodePudding user response:
"So narrow controls should be"Don't understand!
CodePudding user response:
Is, will become like this
CodePudding user response:
WPF?CodePudding user response:
Actually can achieve a layout manager, such as box layout HBoxLayout VBoxLayout, its role is to adjust its management control coordinates, the internal implementation is SetWindowPos, each adding a control on manual AddWidget (HWND) of course, these interfaces need to be yourself, is very simple,CodePudding user response:
SetWindowPos;MoveWindow
CodePudding user response:
Inside the OnSize SetWindowPos parameters with the Rect long and wideCodePudding user response:
This is the place where MFC more hurt, no layout manager, you can refer to the duilib layout manager, write their own oneCodePudding user response:
PWnd - & gt; MoveWindow (the rect);//that the rect must be Screen coordinates, you ScreenToClient (& amp; The rect); After no longer turn back!CodePudding user response:
Plus the ClientToScreen (& amp; The rect);After directly without control
CodePudding user response:
http://www.codeproject.com/Articles/125068/MFC-C-Helper-Class-for-Window-Resizinghttp://www.codeproject.com/Articles/34292/Helper-Class-for-Resizable-MFC-Dialogs
CodePudding user response:
The ScreenToClient (& amp; The rect);//converting controls the size of the dialog in the regional coordinateThis right,
You should put the code OnSize,
PWnd - & gt; GetWindowRect (& amp; The rect);// access control to change the size of the former in the init
OnSize (cx, cy) is the current client area,
If OnInitDialog ()
CRect rc;
GetClientRect (& amp; Rc);
//the original dialog W H
M_dlgW=rc. Width ();
M_dlgH=rc. Height ();
AfxDump & lt;
M_Button1. GetWindowRect (m_btRectOrig);
AfxDump & lt;
AfxDump & lt;
CodePudding user response:
Dialog is only one button:
Init:
//
CRect rc;
GetClientRect (& amp; Rc);
M_dlgW=rc. Width ();
M_dlgH=rc. Height ();
AfxDump & lt;M_Button1. GetWindowRect (m_btRectOrig);
AfxDump & lt;The ScreenToClient (& amp; M_btRectOrig);//
AfxDump & lt;,,,,,,,
Void CScalerDlg: : OnSize (UINT nType, cx, int int cy)
{
CDialog: : OnSize (cx, nType, cy);
Double xRate=cx/(double) m_dlgW (double);
Double yRate=(double) cy/(double) m_dlgH;
//afxDump & lt;If (: : IsWindow (m_Button1 m_hWnd))
{
CRect rcNow;
RcNow. Left=(int) (m_btRectOrig. Left * xRate);
RcNow. Right=(int) (m_btRectOrig. Right * xRate);
RcNow. Top=(int) (m_btRectOrig. Top * yRate);
RcNow. Bottom=(int) (m_btRectOrig. Bottom * yRate);
AfxDump & lt;//
M_Button1. MoveWindow (& amp; RcNow);
}
}
CodePudding user response:
Simple point, make a initial interface display and a maximum size, set up two controls the placement and size of, does not necessarily make the gradientCodePudding user response:
Recommended ETSLayout http://www.codeproject.com/Articles/116/Layout-Manager-for-Dialogs-Formviews-DialogBars-anTranslated articles window class - ETSLayout use
CodePudding user response:
When it starts to get size and location of all controls, this is called the original value. A, as well as the window size B, behind the window size changes, all based on change:M_btn1. GetWindowRect (& amp; The rect);
The ScreenToClient (& amp; The rect);
The rect cx (cy)/B=A *;
MoveWindow (the rect);
CodePudding user response:
, of course, this simple change may cause you don't want to see the effect, so in fact, you need to categorize control, different treatment for different types of controls, such as text box is usually only get longer or shorter, and high and low will not change, the button size remains the same, but this may change position, rich text box or used to display multi-line content control can change sizeCodePudding user response:
Using movewindow no problem, but have you ever thought, control size has changed, and controls whether the text on the need to change, also do not adaptive changes will only cause visual conflict,CodePudding user response:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull