| XP风格复活节彩蛋的实现 下载本文示例代码 #define WM_SHOWHOTKEY WM_USER + 101 //自定义系统热键消息BOOL CAboutDlg::OnInitDialog() { //"关于"对话框中对话框可收缩效果 CRect Rect1,Rect2; //对话框收缩时大小 GetDlgItem(IDC_DYCREDITS)->GetWindowRect(Rect1); GetDlgItem(IDC_COPYRIGHT)->GetWindowRect(Rect2); m_nReducedHeight = Rect1.Height()+(Rect1.top -Rect2.bottom)/2; //收缩后窗体高度 dlgRect.bottom -= (Rect1.Height()+(Rect1.top -Rect2.bottom)/2); MoveWindow(&dlgRect); //如果要显示对话框起始动态效果的话,不能使用该句 m_bVertical=false; //默认收缩对话框 //注册系统热键,用来显示隐藏信息<Ctrl+Alt+F3键> RegisterHotKey(GetSafeHwnd(),WM_SHOWHOTKEY,MOD_ALT|MOD_CONTROL,VK_F3); return TRUE; } 2、隐藏信息的激活或隐藏的函数//功能: 是否荣誉显示void CAboutDlg::OnMore() { m_bVertical = !m_bVertical; if(m_bVertical == FALSE) //不显示 { SetDlgItemText(ID_MORE,_T("更多>>")); SizeWindow(m_nReducedHeight,true); } else //显示 { SetDlgItemText(ID_MORE,_T("<<隐藏")); SizeWindow(m_nReducedHeight,false); } UpdateWindow(); }//功能: 伸展或收缩对话框 void CAboutDlg::SizeWindow(int ReduceHeight, bool bExtend){ CRect rc; GetWindowRect(&rc); if(bExtend) { for (int i= 0; i < ReduceHeight; i++) { rc.bottom--; MoveWindow(&rc); } } else { for (int i= 0; i < ReduceHeight; i++) { rc.bottom++; MoveWindow(&rc); } }} 3、在特殊的键盘及鼠标热键下激隐藏信息显示//功能: 鼠标热键,在图片框按住Ctrl键,双击鼠标右键可显示,显示隐藏的信息。 void CAboutDlg::OnRButtonDblClk(UINT nFlags, CPoint point) { if(nFlags==(MK_CONTROL|MK_RBUTTON )) { CPictureEx *pAbout =(CPictureEx *)GetDlgItem(IDC_FLAG); CRect rcAbout; pAbout->GetWindowRect(&rcAbout); CPoint pt; GetCursorPos(&pt); if(rcAbout.PtInRect(pt)) OnMore(); } CDialog::OnLButtonDblClk(nFlags, point); }//*功能:键盘热键<Ctrl+Alt+F3键>显示隐藏的信息LRESULT CAboutDlg::OnHotKey(WPARAM wParam,LPARAM lParam){ if(wParam==WM_SHOWHOTKEY) { OnMore(); } return 0;} 4、别忘了收尾工作,销毁已注册的系统热键//* 功能:程序关闭时的处理工作BOOL CAboutDlg::DestroyWindow() { //注销已注册的系统热键 UnregisterHotKey(GetSafeHwnd(),WM_SHOWHOTKEY); return CDialog::DestroyWindow(); } 以上部分代码具体实现的细节问题,可在下载实例代码后,仔细查看源码既可(内有详细注释)。
|
0
顶一下
XP风格复活节彩蛋的实现
| 与 相关的 | 教程 |



发表评论
告诉好友