?? index177.htm
字號(hào):
<html>
<style type="text/css"><!--
.p9 { font-family: "宋體"; font-size: 9pt}a {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../di2001.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">關(guān)于使用MS SANS SERIF字體</font></td></tr>
<tr><td><p>
</Br>
我看過(guò)好多關(guān)于創(chuàng)建對(duì)話框、組合框等等使用MS SANS SERIF的例子,自己也做過(guò)多次。如: m_font.CreatePointFont (80, _T("MS Sans Serif")); 或 m_font.Create (-8, ....., _T("MS Sans Serif")); 那么想問(wèn)一下:1)該字體是否在所有的版本中都能實(shí)現(xiàn)(包括國(guó)際版本) 2)在控制面板上有沒(méi)有更好的字體代替“SYSTEM”字體?如果有人這樣做了,那又是怎樣設(shè)置字體大小等相關(guān)設(shè)置的?我希望有一個(gè)徹底的方法來(lái)選擇組合框等的字體。<Br>
</Br>
1)有件事情我做過(guò),在我所有的程序界面中都改變了字體.消息框來(lái)顯示用戶選擇的字體. 菜單,工具條以及其他控件的字體都隨用戶意愿改變.但在對(duì)話框中最好還是用對(duì)話框編輯器, 其基本字體都是MS SANS SERIF,所以我也以這種字體來(lái)作為所有的用戶界面. 以下為我所做的代碼:<Br>
</Br>
</Br>
// here's the font I use:<Br>
SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);<Br>
m_fntUI.CreateFontIndirect(&ncm.lfMessageFont);<Br>
</Br>
// here's the code to change the font for a wnd and all it's children, and<Br>
resize the controls appropriately<Br>
void ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag)<Br>
{<Br>
CRect windowRect;<Br>
</Br>
// grab old and new text metrics<Br>
TEXTMETRIC tmOld, tmNew;<Br>
CDC * pDC = pWnd->GetDC();<Br>
CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont());<Br>
pDC->GetTextMetrics(&tmOld);<Br>
pDC->SelectObject(pFont);<Br>
pDC->GetTextMetrics(&tmNew);<Br>
pDC->SelectObject(pSavedFont);<Br>
pWnd->ReleaseDC(pDC);<Br>
</Br>
long oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading;<Br>
long newHeight = tmNew.tmHeight+tmNew.tmExternalLeading;<Br>
</Br>
if (nFlag != CDF_NONE)<Br>
{<Br>
// calculate new dialog window rectangle<Br>
CRect clientRect, newClientRect, newWindowRect;<Br>
</Br>
pWnd->GetWindowRect(windowRect);<Br>
pWnd->GetClientRect(clientRect);<Br>
long xDiff = windowRect.Width() - clientRect.Width();<Br>
long yDiff = windowRect.Height() - clientRect.Height();<Br>
</Br>
newClientRect.left = newClientRect.top = 0;<Br>
newClientRect.right = clientRect.right * tmNew.tmAveCharWidth /<Br>
tmOld.tmAveCharWidth;<Br>
newClientRect.bottom = clientRect.bottom * newHeight / oldHeight;<Br>
</Br>
if (nFlag == CDF_TOPLEFT) // resize with origin at top/left of window<Br>
{<Br>
newWindowRect.left = windowRect.left;<Br>
newWindowRect.top = windowRect.top;<Br>
newWindowRect.right = windowRect.left + newClientRect.right + xDiff;<Br>
newWindowRect.bottom = windowRect.top + newClientRect.bottom + yDiff;<Br>
}<Br>
else if (nFlag == CDF_CENTER) // resize with origin at center of window<Br>
{<Br>
newWindowRect.left = windowRect.left -<Br>
(newClientRect.right - clientRect.right)/2;<Br>
newWindowRect.top = windowRect.top -<Br>
(newClientRect.bottom - clientRect.bottom)/2;<Br>
newWindowRect.right = newWindowRect.left + newClientRect.right + xDiff;<Br>
newWindowRect.bottom = newWindowRect.top + newClientRect.bottom + yDiff;<Br>
}<Br>
pWnd->MoveWindow(newWindowRect);<Br>
}<Br>
</Br>
pWnd->SetFont(pFont);<Br>
</Br>
// iterate through and move all child windows and change their font.<Br>
CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD);<Br>
</Br>
while (pChildWnd)<Br>
{<Br>
pChildWnd->SetFont(pFont);<Br>
pChildWnd->GetWindowRect(windowRect);<Br>
</Br>
CString strClass;<Br>
::GetClassName(pChildWnd->m_hWnd, strClass.GetBufferSetLength(32), 31);<Br>
strClass.MakeUpper();<Br>
if(strClass==_T("COMBOBOX"))<Br>
{<Br>
CRect rect;<Br>
pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect);<Br>
windowRect.right = rect.right;<Br>
windowRect.bottom = rect.bottom;<Br>
}<Br>
</Br>
pWnd->ScreenToClient(windowRect);<Br>
windowRect.left = windowRect.left * tmNew.tmAveCharWidth /<Br>
tmOld.tmAveCharWidth;<Br>
windowRect.right = windowRect.right * tmNew.tmAveCharWidth /<Br>
tmOld.tmAveCharWidth;<Br>
windowRect.top = windowRect.top * newHeight / oldHeight;<Br>
windowRect.bottom = windowRect.bottom * newHeight / oldHeight;<Br>
pChildWnd->MoveWindow(windowRect);<Br>
</Br>
pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);<Br>
}<Br>
}<Br>
</Br>
</Br>
</p></td></tr>
</table>
</body></html>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -