The dialog box program maximizes the control and the adaptive font size.

Source: Internet
Author: User

You can create multiple toolbar to load different resources at different resolutions.

For controls
InitDialog:

// Obtain the size of the dialog box before the size is greater

CRect rect;
: GetWindowRect (m_hWnd, rect );
ScreenToClient (rect );
M_nDlgWidth = rect. right-rect. left;
M_nDlgHeight = rect. bottom-rect. top;
// Maximize the window size and obtain the resolution. Set the font size of the control based on the size.
ShowWindow (SW_MAXIMIZE );
M_nWidth = GetSystemMetrics (SM_CXSCREEN );
M_nHeight = GetSystemMetrics (SM_CYSCREEN );
// Calculate the magnification and record the three resolutions for the assumption that the resolution is 1280*1024 1024*768 800*768.
M_fWidthMul = float (m_nWidth)/float (m_nDlgWidth );
M_fHeightMul = float (m_nHeight)/float (m_nDlgHeight );
// Set three fonts under three resolutions and load different Toolbar
If (m_nWidth> = 1279)
{
M_newFont.CreateFont (26,0, FW_NORMAL, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH effecff_swiss, _ T (" "));
M_nToolBarID = IDR_TOOLBAR1;
}
Else
{
If (m_nWidth> = 1000)
{
M_newFont.CreateFont (16, 0, FW_NORMAL, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH effecff_swiss, _ T (" "));
M_nToolBarID = IDR_TOOLBAR2;
}
Else
{
M_newFont.CreateFont (, 0, FW_NORMAL, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH effecff_swiss, _ T (" "));
M_nToolBarID = IDR_TOOLBAR3;
}
}

ReSize (Control ID) // number of times that a widget is called resize


Class to add a function ReSize (int nAimID)

Void ReSize (nAimID)

{

CRect AimRect;
GetDlgItem (nAimID)-> GetWindowRect (AimRect );
ScreenToClient (AimRect );
// Record the points in the upper left corner and lower right corner of the area
CPoint OldTLPoint, AimTLPoint;
OldTLPoint = AimRect. TopLeft ();
AimTLPoint. x = long (OldTLPoint. x * m_fWid

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.