在程序中启动记事本
::ShellExecute(NULL, NULL, "C:\\WINDOWS\\system32\\notepad.exe", NULL, NULL, SW_MAXIMIZE/*SW_SHOW*/);
在状态栏显示时间
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
//CTime t=GetCurrentTime();//这样 显示的时间不对 时位的变化速度赶上了秒
CTime t=CTime::GetCurrentTime(); //和桌面右下角的时间一致 这两个有什么不同呢?
CString str=t.Format("%H:%M:%S");
CClientDC dc(this);
CSize sz=dc.GetTextExtent(str);
int index=m_wndStatusBar.CommandToIndex(IDS_TIMER);
m_wndStatusBar.SetPaneInfo(index,IDS_TIMER,SBPS_NORMAL,sz.cx);
m_wndStatusBar.SetPaneText(index,str);
CFrameWnd::OnTimer(nIDEvent);
}
tmHeight为字符的高度,tmExternalLeading是行间距
cyChar = tm.tmHeight + tm.tmExternalLeading就是换行后的cy的坐标值
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
文中说cxCaps表示大写字母的宽度,请问tmPitchAndFamily&1是什么意思
TEXTMETRICS结构的tmPitchAndFamily属性是用来判断字体是否为变宽字体的,如果是等宽字体那么它的低位就为0
此时tm.tmPitchAndFamily&1=0 条件分支结果取2
如果为变宽字体那么它的低位就为1
此时tm.tmPitchAndFamily&1=1 条件分支结果取3
所以通过位运算我们可以判断是否为变宽字体,如果是就扩大150%(3/2)