上位机MFC文本滚动特效源代码
例程效果如上图
可以设置文本滚动速度,
绚丽背景,用户是否可通过鼠标操作文本等功能。
程序是通过从CWnd派生自己的集成类实现的。
class CCreditsCtrl : public CWnd;
可以在自己的工程中实例化一个对象 CCreditsCtrl m_wndCredits;
再初始化此对象,添加文本内容。
- BOOL CCreditsDlgDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- srand((unsigned)time(NULL));
-
- // initialize credits control...
- // Content
- CString s;
- s = "<font color='255,255,255' face='arial' size='12' align='center'>";
- s += "<font size='28' face='Comic Sans MS' style='ui' color='255,255,255'>Demo Stuff </font><p>";
- s += " <font style='bu' align='left'>Color:<br></font><font color='255,0,0'>y</font><font color='220,30,10'>e</font><font color='200,60,30'>e</font><font color='200,100,50'>e</font><font color='180,120,80'>e</font><font color='160,140,100'>e</font><font color='140,160,120'>e</font><font color='120,180,140'>e</font><font color='100,200,160'>e</font><font color='80,180,180'>e</font><font color='60,140,220'>e</font><font color='80,120,250'>h</font><font color='110,100,255'>a</font><font color='130,90,255'>a</font><font color='150,80,255'>a</font><font color='170,70,255'>a</font><font color='180,50,255'>a</font><br>";
- s += " <font style='bu' align='left'>Font:<br></font><font color='0,200,100' size='14' face='Comic Sans MS'>Comic Sans MS</font><br><font color='0,200,100' size='14' face='Courier New'>Courier New</font><br><font color='0,200,100' size='14' face='Tahoma'>Tahoma</font><br>";
- s += " <font style='bu' align='left'>Size:<br></font><font color='150,100,255'><font size='42'>W</font><font size='36'>H</font><font size='28'>O</font><font size='18'>O</font><font size='14'>O</font><font size='18'>O</font><font size='28'>O</font><font size='36'>O</font><font size='42'>W</font></font><br>";
- s += " <font style='bu' align='left'>Styles:<br></font><font color='40,120,240' size='14'><font style='b'>bold</font> <font style='i'>italic</font> <font style='u'>underline</font> <font style='s'>strikeout</font></font><br>";
- s += " <font style='bu' align='left'>Background:<br></font><font color='255,255,255' size='14' style='b'><font background='0,0,255'>Blue</font> <font background='255,0,0'>Red</font> <font background='210,150,40'>Brown</font> <font background='0,0,255' color='none'>Ghost Font</font></font><br>";
- s += " <font style='bu' align='left'>Alignment:<br></font><font color='255,150,40' size='14' style='b'><font align='right'>right <br></font><font align='center'>center<br></font><font align='left'> left<br></font></font>";
- s += " <font style='bu' align='left'>Vertical Alignment:<br></font><font color='0,220,160' size='12' style='b'><font valign='top'>top</font><font valign='middle'>middle</font><font valign='bottom'>bottom</font><font size='48'>BIG</font></font><br>";
- s += " <font style='bu' align='left'>Resource Bitmap:<br></font><font color='30,70,255' size='12' style='b'><img src='#%d'><font color='255,0,0'> red </font><font valign='bottom'>bo</font><font valign='middle'>rd</font><font valign='top'>er </font><img src='#%d' border='4' color='255,0,0'></font><br>";
- s += " <font style='bu' align='left'>Links:<br></font><font color='100,160,220' size='14' style='b'><a href='#Hello World!#%d' color='100,220,160'>Click Me!</a><br><a href='notepad.exe' color='100,220,160' style='bui'>notepad</a><br><a href='http://www.w3c.org' color='100,220,160' face='Courier New' size='16'>www.w3c.org</a><br><a href='mailto:devix@devix.cjb.net?SUBJECT=Hello World!! ;)' color='100,220,160' face='Comic Sans MS' size='18'>devix@devix.cjb.net</a><br><font size='36' color='255,200,0' style='u'><a href='#\nDo or do not. There is no try.\n\n\t\t-Yoda#%d' color='none' background='255,200,0' style='-uis'>Click Here</a></font><vspace size='4'><font valign='top' size='12' style='-b'>image link: </font><a href='#%d#%d' color='255,200,0'><img src='#%d' border='2' color='none'></a></font><vspace size='80'>";
- s += "<font size='28' face='Comic Sans MS' style='ui'>CCreditsCtrl </font><p><font size='18' style='u' color='255,200,0'>About</font><p>Coded in January 2001<br>by <font style='b'>Marc Richarme</font><vspace size='5'><font align='left' size='11'><hspace size='30'><font style='i'>mail: </font><font style='ub'><a href='mailto:devix@devix.cjb.net?SUBJECT=Hello World!' color='255,200,0'>devix@devix.cjb.net</a></font><br><hspace size='30'><font style='i'>web: </font><font style='ub'><a href='http://devix.cjb.net' color='255,200,0'>http://devix.cjb.net</a></font><p></font><font size='18' style='u' color='255,200,0'>Credits</font><p>Thanks to <font style='ub'><a href='http://www.codeproject.com' color='255,200,0'>The Code Project</a></font> for being<br> the coolest VC++/MFC site out there!<br></font><vspace size='80'>";
- // Content Data
- m_wndCredits.FormatDataString(s,IDB_BITMAP1,IDB_BITMAP1,(long)CCreditsDlgDlg::TestFunction,(long)CCreditsDlgDlg::TestFunction,(long)this,(long)CCreditsDlgDlg::TestFunction2,IDB_BITMAP2);
-
- // use our own function for background drawing
- m_wndCredits.m_pBackgroundPaint = CCreditsDlgDlg::DrawCreditsBackground;
- m_wndCredits.m_dwBackgroundPaintLParam = TRUE;
- // as our background is going to be black, use black as default transparent color
- m_wndCredits.m_crInternalTransparentColor = RGB(0,0,0);
-
- // now, we're ready to begin... create the window
- m_wndCredits.Create(WS_EX_CLIENTEDGE,WS_VISIBLE|WS_CHILD,IDC_PLACEHOLDER,this,0,IDC_SMILEY,0);
- // for details on what more can be customized, RTFM.
- // default options
- ((CButton*)GetDlgItem(IDC_BACKGROUND))->SetCheck(TRUE);
- ((CButton*)GetDlgItem(IDC_USERSCROLL))->SetCheck(TRUE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
复制代码 整体使用上还是很方便的。
更多的功能可以下载源代码编译运行查看。
上位机VC MFC程序开发精典实例大全源码与视频讲解配套下载408例 经历1年的编程与录制点击进入查看
如果您认可,可联系功能定制! 如果您着急,充值会员可直接联系发您资料!
|