⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index177.htm

📁 关于vc的一本问题集,很不错的,有很多精采的问题
💻 HTM
字号:
<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="../../../backg.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">关于使用MS SANS SERIF字体</font></td></tr>
<tr><td><p>
</Br>
我看过好多关于创建对话框、组合框等等使用MS SANS SERIF的例子,自己也做过多次。如: m_font.CreatePointFont (80, _T("MS Sans Serif")); 或 m_font.Create (-8, ....., _T("MS Sans Serif")); 那么想问一下:1)该字体是否在所有的版本中都能实现(包括国际版本) 2)在控制面板上有没有更好的字体代替“SYSTEM”字体?如果有人这样做了,那又是怎样设置字体大小等相关设置的?我希望有一个彻底的方法来选择组合框等的字体。<Br>
</Br>
1)有件事情我做过,在我所有的程序界面中都改变了字体.消息框来显示用户选择的字体. 菜单,工具条以及其他控件的字体都随用户意愿改变.但在对话框中最好还是用对话框编辑器, 其基本字体都是MS SANS SERIF,所以我也以这种字体来作为所有的用户界面. 以下为我所做的代码:<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>
&nbsp;CRect windowRect;<Br>
</Br>
&nbsp;// grab old and new text metrics<Br>
&nbsp;TEXTMETRIC tmOld, tmNew;<Br>
&nbsp;CDC * pDC = pWnd->GetDC();<Br>
&nbsp;CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont());<Br>
&nbsp;pDC->GetTextMetrics(&tmOld);<Br>
&nbsp;pDC->SelectObject(pFont);<Br>
&nbsp;pDC->GetTextMetrics(&tmNew);<Br>
&nbsp;pDC->SelectObject(pSavedFont);<Br>
&nbsp;pWnd->ReleaseDC(pDC);<Br>
</Br>
&nbsp;long oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading;<Br>
&nbsp;long newHeight = tmNew.tmHeight+tmNew.tmExternalLeading;<Br>
</Br>
&nbsp;if (nFlag != CDF_NONE)<Br>
&nbsp;{<Br>
&nbsp;&nbsp;// calculate new dialog window rectangle<Br>
&nbsp;&nbsp;CRect clientRect, newClientRect, newWindowRect;<Br>
</Br>
&nbsp;&nbsp;pWnd->GetWindowRect(windowRect);<Br>
&nbsp;&nbsp;pWnd->GetClientRect(clientRect);<Br>
&nbsp;&nbsp;long xDiff = windowRect.Width() - clientRect.Width();<Br>
&nbsp;&nbsp;long yDiff = windowRect.Height() - clientRect.Height();<Br>
</Br>
&nbsp;&nbsp;newClientRect.left = newClientRect.top = 0;<Br>
&nbsp;&nbsp;newClientRect.right = clientRect.right * tmNew.tmAveCharWidth /<Br>
tmOld.tmAveCharWidth;<Br>
&nbsp;&nbsp;newClientRect.bottom = clientRect.bottom * newHeight / oldHeight;<Br>
</Br>
&nbsp;&nbsp;if (nFlag == CDF_TOPLEFT) // resize with origin at top/left of window<Br>
&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.left = windowRect.left;<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.top = windowRect.top;<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.right = windowRect.left + newClientRect.right + xDiff;<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.bottom = windowRect.top + newClientRect.bottom + yDiff;<Br>
&nbsp;&nbsp;}<Br>
&nbsp;&nbsp;else if (nFlag == CDF_CENTER) // resize with origin at center of window<Br>
&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.left = windowRect.left -<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(newClientRect.right - clientRect.right)/2;<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.top = windowRect.top -<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(newClientRect.bottom - clientRect.bottom)/2;<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.right = newWindowRect.left + newClientRect.right + xDiff;<Br>
&nbsp;&nbsp;&nbsp;newWindowRect.bottom = newWindowRect.top + newClientRect.bottom + yDiff;<Br>
&nbsp;&nbsp;}<Br>
&nbsp;&nbsp;pWnd->MoveWindow(newWindowRect);<Br>
&nbsp;}<Br>
</Br>
&nbsp;pWnd->SetFont(pFont);<Br>
</Br>
&nbsp;// iterate through and move all child windows and change their font.<Br>
&nbsp;CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD);<Br>
</Br>
&nbsp;while (pChildWnd)<Br>
&nbsp;{<Br>
&nbsp;&nbsp;pChildWnd->SetFont(pFont);<Br>
&nbsp;&nbsp;pChildWnd->GetWindowRect(windowRect);<Br>
</Br>
&nbsp;&nbsp;CString strClass;<Br>
&nbsp;&nbsp;::GetClassName(pChildWnd->m_hWnd, strClass.GetBufferSetLength(32), 31);<Br>
&nbsp;&nbsp;strClass.MakeUpper();<Br>
&nbsp;&nbsp;if(strClass==_T("COMBOBOX"))<Br>
&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;CRect rect;<Br>
&nbsp;&nbsp;&nbsp;pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect);<Br>
&nbsp;&nbsp;&nbsp;windowRect.right = rect.right;<Br>
&nbsp;&nbsp;&nbsp;windowRect.bottom = rect.bottom;<Br>
&nbsp;&nbsp;}<Br>
</Br>
&nbsp;&nbsp;pWnd->ScreenToClient(windowRect);<Br>
&nbsp;&nbsp;windowRect.left = windowRect.left * tmNew.tmAveCharWidth /<Br>
tmOld.tmAveCharWidth;<Br>
&nbsp;&nbsp;windowRect.right = windowRect.right * tmNew.tmAveCharWidth /<Br>
tmOld.tmAveCharWidth;<Br>
&nbsp;&nbsp;windowRect.top = windowRect.top * newHeight / oldHeight;<Br>
&nbsp;&nbsp;windowRect.bottom = windowRect.bottom * newHeight / oldHeight;<Br>
&nbsp;&nbsp;pChildWnd->MoveWindow(windowRect);<Br>
</Br>
&nbsp;&nbsp;pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);<Br>
&nbsp;}<Br>
}<Br>
</Br>
</Br>
</p></td></tr>
</table><p align="center"><img src="../../../logo.gif" align="center"><center><table><tr><td><a href="http://www.ourcode.net" target=_top>www.OurCode.net</a><Br>版权所有: 2002-2008</a></td></tr></table></center></p>
</body><SCRIPT LANGUAGE='JavaScript' SRC='../../../navigate_bar.js'></SCRIPT><SCRIPT LANGUAGE='JavaScript'>write_tail();</SCRIPT></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -