Home > Software engineering >  Set CDialog width 150 mm, 100 mm high, and contains a CTabCtrl control, the control position and siz
Set CDialog width 150 mm, 100 mm high, and contains a CTabCtrl control, the control position and siz

Time:12-06

Set CDialog width 150 mm, 100 mm high, and contains a CTabCtrl control, the control position and size is in unit of millimeter control, how to implement under different screen resolution?

CodePudding user response:

1 get corresponding pixel 100 mm
//into pixels: * 144/2540
//# define HIMETRIC_PER_INCH 2540
//afxDump & lt; //int nPicWidth=MulDiv (hmWidth, GetDeviceCaps (pDC - & gt; M_hDC, LOGPIXELSX), 2540);//HIMETRIC_PER_INCH);
//int nPicHeight=MulDiv (hmHeight, GetDeviceCaps (pDC - & gt; M_hDC, LOGPIXELSY), 2540);//HIMETRIC_PER_INCH);
//afxDump & lt; 2 AdjustWindowRect
The AdjustWindowRect function calculates The required size of The window is a rectangle, on The desired client - a rectangle size. The window rectangle can then be passed to The CreateWindow function to create a window whose client area is The desired size.

BOOL AdjustWindowRect (
LPRECT LPRECT,//a pointer to the client - a rectangle structure
DWORD dwStyle,//the window styles
BOOL bMenu//menu - the present flag
);

  • Related