实验报告8-10

上传人:痛*** 文档编号:135862046 上传时间:2022-08-16 格式:DOC 页数:13 大小:291.50KB
收藏 版权申诉 举报 下载
实验报告8-10_第1页
第1页 / 共13页
实验报告8-10_第2页
第2页 / 共13页
实验报告8-10_第3页
第3页 / 共13页
资源描述:

《实验报告8-10》由会员分享,可在线阅读,更多相关《实验报告8-10(13页珍藏版)》请在装配图网上搜索。

1、实验8:EX_Timer1变量定义代码:class CEX_Timer1Dlg : public CDialogpublic:CEX_Timer1Dlg(CWnd* pParent = NULL);/ standard constructorenum IDD = IDD_EX_TIMER1_DIALOG ;CProgressCtrlm_wndProgress;CTimem_curTime;protected:virtual void DoDataExchange(CDataExchange* pDX);/ DDX/DDV supportOnInitDialog()代码:BOOL CEX_Tim

2、er1Dlg:OnInitDialog()CDialog:OnInitDialog();m_wndProgress.SetRange(0,59);SetTimer(1,200,NULL);ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);SetIcon(m_hIcon, TRUE);/ Set big iconSetIcon(m_hIcon, FA

3、LSE);/ Set small iconreturn TRUE; / return TRUE unless you set the focus to a control获取当前时间代码:void CEX_Timer1Dlg:OnTimer(UINT nIDEvent) m_curTime=CTime:GetCurrentTime();UpdateData(FALSE);int nSec=m_curTime.GetSecond();m_wndProgress.SetPos(nSec);CDialog:OnTimer(nIDEvent);实验结果:EX_BkColor:BOOL CEX_BkCo

4、lorDlg:OnInitDialog()CDialog:OnInitDialog();/ Add About. menu item to system menu. / IDM_ABOUTBOX must be in the system command range.m_scrollRed.SetScrollRange(0,255);m_sliderBlue.SetRange(0,255); m_sliderGreen.SetRange(0,255);m_nBlue=m_nGreen=m_nRedValue=192;UpdateData(FALSE);m_scrollRed.SetScroll

5、Pos(m_nRedValue);ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIc

6、on, TRUE);/ Set big iconSetIcon(m_hIcon, FALSE);/ Set small icon/ TODO: Add extra initialization herereturn TRUE; / return TRUE unless you set the focus to a controlvoid CEX_BkColorDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDi

7、alog:OnSysCommand(nID, lParam);实验结果:思考题:先注释掉CEx_TimerDlg:OnInitDialog()然后再修改以下代码:void CEx_TimerDlg:OnButtonStart()m_wndProgress.SetRange(0,500);SetTimer(1,2000,NULL);实验9:EX_bqqA4:void CMainFrame:OnViewOp() int bShow = m_wndOpBar.IsWindowVisible(); ShowControlBar( &m_wndOpBar, !bShow, FALSE); UpdateO

8、pMenu( !bShow ); void CMainFrame:OnUpdateViewOp(CCmdUI* pCmdUI) int bShow = m_wndOpBar.IsWindowVisible(); pCmdUI -SetCheck( bShow ); int CMainFrame:OnCreate(LPCREATESTRUCT lpCreateStruct)if (CFrameWnd:OnCreate(lpCreateStruct) = -1)return -1;int nRes=m_wndOpBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD|WS_

9、VISIBLE|CBRS_TOP|CBRS_GRIPPER|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC,CRect(0,0,0,0), AFX_IDW_TOOLBAR+10);if(!nRes|!m_wndOpBar.LoadToolBar(IDR_TOOLBAR1)TRACE0(Failed to create toolbarn);return -1;if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP| CBRS_GRIPPER | CBRS_

10、TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) |!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)TRACE0(Failed to create toolbarn);return -1; / fail to createif (!m_wndStatusBar.Create(this) |!m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)TRACE0(Failed to create status barn);return -1;

11、/ fail to create/ TODO: Delete these three lines if you dont want the toolbar to/ be dockablem_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);m_wndOpBar.EnableDocking(CBRS_ALIGN_ANY);EnableDocking(CBRS_ALIGN_ANY);DockControlBar(&m_wndOpBar);DockControlBar(&m_wndToolBar);m_wndOpBar.SetWindowText(操作);return

12、 0;BOOL CMainFrame:PreCreateWindow(CREATESTRUCT& cs)if( !CFrameWnd:PreCreateWindow(cs) )return FALSE;/ TODO: Modify the Window class or styles here by modifying/ the CREATESTRUCT csreturn TRUE;void CMainFrame:OnOpAdd() CScoreDlg dlg;if (IDOK = dlg.DoModal() ) / 当输入记录有效后,获取相关记录,然后在状态上显示出来CString strR

13、es;strRes.Format( 姓名:%s, 学号:%s, 3门成绩: %.1f, %0.1f, %.1f,dlg.m_strName, dlg.m_strNO, dlg.m_fScore1, dlg.m_fScore2, dlg.m_fScore3 );m_wndStatusBar.SetPaneText( 1, strRes ); elsem_wndStatusBar.SetPaneText( 1, 无有效的学生成绩记录! );实验结果:思考题:void CmainFrame:OnOpDel()m_wndStatusBar.SetPaneText(1,”);实验十:Ex_bqqCurs

14、or:BOOL CMainFrame:OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) BOOL bRes=CFrameWnd:OnSetCursor(pWnd,nHitTest,message);if(nHitTest=HTCAPTION)m_hCursor=LoadCursorFromFile(c:windowscursorshand.ani);SetCursor(m_hCursor);bRes=TRUE;else if(nHitTest=HTCLIENT)m_hCursor=AfxGetApp()-LoadCursor(IDC_CU

15、RSOR1);SetCursor(m_hCursor);bRes=TRUE;return bRes;return CFrameWnd:OnSetCursor(pWnd, nHitTest, message);设计图案:实验结果:Ex_bqqA5:int CMainFrame:OnCreate(LPCREATESTRUCT lpCreateStruct)if (CFrameWnd:OnCreate(lpCreateStruct) = -1)return -1;if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE

16、| CBRS_TOP| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) |!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)TRACE0(Failed to create toolbarn);return -1; / fail to createif (!m_wndStatusBar.Create(this) |!m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)TRACE0(Failed to

17、 create status barn);return -1; / fail to create/ TODO: Delete these three lines if you dont want the toolbar to/ be dockablem_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);EnableDocking(CBRS_ALIGN_ANY);DockControlBar(&m_wndToolBar);this-SetWindowText(第五章综合应用);return 0;BOOL CMainFrame:PreCreateWindow(CRE

18、ATESTRUCT& cs)if( !CFrameWnd:PreCreateWindow(cs) )return FALSE;cs.style &=FWS_ADDTOTITLE;cs.style &=WS_MINIMIZEBOX;cs.style &=WS_MAXIMIZEBOX;return TRUE;BOOL CEx_bqqA5App:InitInstance()AfxEnableControlContainer();/ Standard initialization/ If you are not using these features and wish to reduce the s

19、ize/ of your final executable, you should remove from the following/ the specific initialization routines you do not need.#ifdef _AFXDLLEnable3dControls();/ Call this when using MFC in a shared DLL#elseEnable3dControlsStatic();/ Call this when linking to MFC statically#endif/ Change the registry key

20、 under which our settings are stored./ TODO: You should modify this string to be something appropriate/ such as the name of your company or organization.SetRegistryKey(_T(Local AppWizard-Generated Applications);LoadStdProfileSettings(); / Load standard INI file options (including MRU)/ Register the

21、applications document templates. Document templates/ serve as the connection between documents, frame windows and views.CSingleDocTemplate* pDocTemplate;pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME,RUNTIME_CLASS(CEx_bqqA5Doc),RUNTIME_CLASS(CMainFrame), / main SDI frame windowRUNTIME_CLASS(CEx

22、_bqqA5View);AddDocTemplate(pDocTemplate);/ Parse command line for standard shell commands, DDE, file openCCommandLineInfo cmdInfo;ParseCommandLine(cmdInfo);/ Dispatch commands specified on the command lineif (!ProcessShellCommand(cmdInfo)return FALSE;/ The one and only window has been initialized, s

23、o show and update it.m_pMainWnd-ShowWindow(SW_SHOW);m_pMainWnd-UpdateWindow();m_pMainWnd-SetWindowPos(NULL,0,0,400,300,SWP_NOZORDER);m_pMainWnd-CenterWindow();return TRUE;BOOL CMainFrame:PreTranslateMessage(MSG* pMsg) if(pMsg-message=WM_LBUTTONDBLCLK)/隐藏窗口ShowWindow(SW_HIDE);/向托盘中添加图标NOTIFYICONDATA

24、tnid;tnid.cbSize=sizeof(NOTIFYICONDATA); tnid.hWnd=m_hWnd;tnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;tnid.uCallbackMessage=WM_ICON_NOTIFY;tnid.hIcon=AfxGetApp()-LoadIcon(IDR_MAINFRAME);lstrcpyn(tnid.szTip,综合应用,sizeof(tnid.szTip);Shell_NotifyIcon(NIM_ADD,&tnid);/启动计时器SetTimer(1,500,NULL);return CFrameW

25、nd:PreTranslateMessage(pMsg);BOOL CMainFrame:DeleteTaskBarIcon(HWND hwnd,UINT uID) NOTIFYICONDATA tnid;tnid.cbSize=sizeof(NOTIFYICONDATA);tnid.hWnd=hwnd;return Shell_NotifyIcon(NIM_DELETE,&tnid);void CMainFrame:OnDestroy() CFrameWnd:OnDestroy(); KillTimer(1);DeleteTaskBarIcon(m_hWnd,IDR_MAINFRAME);v

26、oid CMainFrame:OnTrayNotify(WPARAM wParam,LPARAM lParam)UINT uMouseMsg =(UINT)lParam;if(uMouseMsg=WM_LBUTTONDOWN)ShowWindow(SW_SHOWNORMAL);DeleteTaskBarIcon(m_hWnd,IDR_MAINFRAME);return;void CMainFrame:OnTimer(UINT nIDEvent) static UINT nIDs=IDI_ICON1,IDR_MAINFRAME;static int nIndex=0;NOTIFYICONDATA tnid;tnid.cbSize=sizeof(NOTIFYICONDATA);tnid.hWnd=m_hWnd;tnid.uFlags=NIF_ICON;tnid.uCallbackMessage=WM_ICON_NOTIFY;tnid.hIcon=AfxGetApp()-LoadIcon(nIDsnIndex);Shell_NotifyIcon(NIM_MODIFY,&tnid);nIndex+;if(nIndex1) nIndex=0;CFrameWnd:OnTimer(nIDEvent);

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!