設定CDialog寬150mm、高100mm,并包含一個CTabCtrl控制元件,該控制元件位置及大小也是用毫米為單位控制,怎么在不同的解析度螢屏下實作?
uj5u.com熱心網友回復:
1 得到 100mm 對應的 pixel// 轉化為象素: *144 /2540
// #define HIMETRIC_PER_INCH 2540
// afxDump << GetDeviceCaps(pDC->m_hDC, LOGPIXELSX) << "\n";// 144
// int nPicWidth = MulDiv(hmWidth, GetDeviceCaps(pDC->m_hDC, LOGPIXELSX), 2540);//HIMETRIC_PER_INCH);
// int nPicHeight = MulDiv(hmHeight, GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 2540);//HIMETRIC_PER_INCH);
// afxDump << nPicWidth << "=W;H=" << nPicHeight << "\n";// 220=W;H=220
2 AdjustWindowRect
The AdjustWindowRect function calculates the required size of the window rectangle, based on the desired client-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, // pointer to client-rectangle structure
DWORD dwStyle, // window styles
BOOL bMenu // menu-present flag
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/230446.html
標籤:界面
上一篇:在 vs2017里寫了一個畫圖的程式,為什么滑鼠單擊按下,拖動,線潭訓不出來?
下一篇:MFC頭檔案報錯
