按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
·155 ·
…………………………………………………………Page 165……………………………………………………………
Visual C++ 6。0 程序设计从入门到精通
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect。Width() cxIcon + 1) / 2;
int y = (rect。Height() cyIcon + 1) / 2;
// Draw the icon
dc。DrawIcon(x; y; m_hIcon);
}
else
{
CPaintDC dc(this); // device context for painting
dc。SetTextColor(RGB (180;240;210));
dc。SetBkMode(TRANSPARENT); //设置背景为透明!
CRect rect;
rect。left=150;
rect。right=350;
rect。top=10;
rect。bottom=40;
dc。Rectangle(&rect);
dc。FillRect(▭&m_brush1);
rect。left=10;
rect。right=135;
rect。top=40;
rect。bottom=200;
dc。Rectangle(&rect);
dc。FillRect(▭&m_brush1);
dc。TextOut(WidthX;15;m_str);
dc。TextOut(15;Heighty;m_str);
// CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window。
HCURSOR CGundongDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGundongDlg::OnTimer(UINT nIDEvent)
{
·156 ·
…………………………………………………………Page 166……………………………………………………………
第 6 章 文本和字体类
// TODO: Add your message handler code here and/or call default
DrawV();
DrawH();
CDialog::OnTimer(nIDEvent);
}
void CGundongDlg::DrawV() //竖直方向滚动函数
{
CRect rect; //每次重画区域大小
rect。left=10;
rect。right=m_str。GetLength()+rect。left+120;
CFont * font=GetFont();
LOGFONT logFont;
font…》GetLogFont(&logFont);
rect。top=Heighty;
rect。bottom=rect。top+logFont。lfHeight+40;
InvalidateRect(&rect);
Heighty+=logFont。lfHeight+18; //每步向下移动距离
if(Heighty》=maxHeight) Heighty=15; // 回到起始位置
UpdateWindow();
}
void CGundongDlg::DrawH() //水平向滚动函数
{
CRect rect; //每次重画区域大小
rect。top=15;
CFont * font=GetFont();
LOGFONT logFont;
font…》GetLogFont(&logFont);
rect。bottom=rect。top+logFont。lfHeight+80;
rect。left=WidthX…m_str。GetLength()…10;
rect。right=rect。left+m_str。GetLength()+150;
InvalidateRect(&rect);
if(WidthX