动距离
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<10) WidthX=350; //回到起始位置
WidthX=WidthX-6; //每步向左移动距离
UpdateWindow();
}
HBRUSH CGundongDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
return m_brush; //改变对话框背景颜色
枫叶文学网www.fywxw.com
Visual C++ 6.0 程序设计从入门到精通
·158·
// return hbr;
}
void CGundongDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add yourcomssage handler code here
if(TIMER!=0)
KillTcomr(TIMER);
}
运行结果如图6-2 所示。
图6-2 “动态字幕”示例运行结果
技巧:制作3D 空心字
有时在编程实践中需要输出一些特效文字,比如3D 空心文字。要在Visual C++程序中输
出3D 空心效果的文字,可以先输入3D 文字然后建立一个路径对象,向路径对象输出该文
字,之后用当前画刷填充区域内部并用当前画笔勾画路径的轮廓就可达到此目的。下面通
过一个实际的示例来说明具体的实现方法。
实例6-2:字体和文本输出实例。源代码在光盘中“\06\实例6-2\HollowFont”目录下。
下面的例子是基于SDI 结构的,其中核心源代码如下:
CHollowFontView::CHollowFontView()
{
LOGFONT lf;
lf.lfHe