vc++
-
How to use Different font sizes in a VC++ Dialog Box
-
How to use Different font sizes in a VC++ Dialog Box
-
How to use Different font sizes in a VC++ Dialog Box
If you want to do it at run time, override the virtual function DoModal();
#include <afxpriv.h> // Required for CDialogTemplate int CMyDlg::DoModal() { CDialogTemplate dlt; // Load dialog Template if (!dlt.Load(MAKEINTRESOURCE(CMyDlg::IDD))) { return -1; } // Set Font Size; // Default Value WORD nFontSize = 10; TCHAR chFaceName[100] = "Courier New"; // Open an ini file or read from the registry to get the new font size and face name if (GetNewFontSize(....)) { nFontSize = newsize; } if (GetNewFaceName(....)) { lstrcpy(chFaceName, newfacename); } dlt.SetFont(chFaceName, (WORD)nFontSize); // Get pointer to the modified dialog template LPSTR pData = (LPSTR)GlobalLock(dlt.m_hTemplate); if (pData == NULL) { return -1; } // Let MFC know that you are using your own template m_lpszTemplateName = NULL; InitModalIndirect(pData); // Display Dialog Box INT nResult = CDialog::DoModal(); // Unlock memory object GlobalUnlock(dlt.m_hTemplate); return nResult; }
-
If you want to do it at run time, override the virtual function DoModal();
#include <afxpriv.h> // Required for CDialogTemplate int CMyDlg::DoModal() { CDialogTemplate dlt; // Load dialog Template if (!dlt.Load(MAKEINTRESOURCE(CMyDlg::IDD))) { return -1; } // Set Font Size; // Default Value WORD nFontSize = 10; TCHAR chFaceName[100] = "Courier New"; // Open an ini file or read from the registry to get the new font size and face name if (GetNewFontSize(....)) { nFontSize = newsize; } if (GetNewFaceName(....)) { lstrcpy(chFaceName, newfacename); } dlt.SetFont(chFaceName, (WORD)nFontSize); // Get pointer to the modified dialog template LPSTR pData = (LPSTR)GlobalLock(dlt.m_hTemplate); if (pData == NULL) { return -1; } // Let MFC know that you are using your own template m_lpszTemplateName = NULL; InitModalIndirect(pData); // Display Dialog Box INT nResult = CDialog::DoModal(); // Unlock memory object GlobalUnlock(dlt.m_hTemplate); return nResult; }
I use a method similar to this with a highres app and it works great. On a highres monitor (2048 x 2560) I use 15pt font and on the second (1024x768) I use 10pt... John