




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/ 树形控件Dlg.h : header file/#if !defined(AFX_DLG_H_9C0815C7_7612_4272_ADD1_882A0E6885FE_INCLUDED_)#define AFX_DLG_H_9C0815C7_7612_4272_ADD1_882A0E6885FE_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000/ CMyDlg dialogclass CMyDlg : public CDialog/ Constructionpublic:CMyDlg(CWnd* pParent = NULL);/ standard constructor/ Dialog Data/AFX_DATA(CMyDlg)enum IDD = IDD_MY_DIALOG ;CTreeCtrlm_TreeCtrl;/AFX_DATA/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CMyDlg)protected:virtual void DoDataExchange(CDataExchange* pDX);/ DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:HICON m_hIcon;/ Generated message map functions/AFX_MSG(CMyDlg)virtual BOOL OnInitDialog();afx_msg void OnSysCommand(UINT nID, LPARAM lParam);afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();afx_msg void OnButton1();afx_msg void OnDblclkTree1(NMHDR* pNMHDR, LRESULT* pResult);afx_msg void OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult);/AFX_MSGDECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_DLG_H_9C0815C7_7612_4272_ADD1_882A0E6885FE_INCLUDED_)/ 树形控件Dlg.cpp : implementation file/#include stdafx.h#include 树形控件.h#include 树形控件Dlg.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;/AFX_DATA/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CAboutDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:/AFX_MSG(CAboutDlg)/AFX_MSGDECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg)/ No message handlers/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMyDlg dialogCMyDlg:CMyDlg(CWnd* pParent /*=NULL*/): CDialog(CMyDlg:IDD, pParent)/AFX_DATA_INIT(CMyDlg)/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CMyDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CMyDlg)DDX_Control(pDX, IDC_TREE1, m_TreeCtrl);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CMyDlg, CDialog)/AFX_MSG_MAP(CMyDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BUTTON1, OnButton1)ON_NOTIFY(NM_DBLCLK, IDC_TREE1, OnDblclkTree1)ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1)/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMyDlg message handlersBOOL CMyDlg:OnInitDialog()CDialog:OnInitDialog();/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.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_hIcon, TRUE);/ Set big iconSetIcon(m_hIcon, FALSE);/ Set small icon/ TODO: Add extra initialization hereHTREEITEM hTREEITEM;HTREEITEM hTREEITEM_2;hTREEITEM = m_TreeCtrl.InsertItem(菜单,0,0);hTREEITEM_2 = m_TreeCtrl.InsertItem(音乐设置,0,0,hTREEITEM);m_TreeCtrl.InsertItem(卡农(也能响应双击的哦),0,0,hTREEITEM_2);m_TreeCtrl.InsertItem(背景设置,0,0,hTREEITEM);m_TreeCtrl.InsertItem(画面设置,0,0,hTREEITEM);m_TreeCtrl.Expand( hTREEITEM, TVE_EXPAND );return TRUE; / return TRUE unless you set the focus to a controlvoid CMyDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CMyDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);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 icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CMyDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CMyDlg:OnButton1() / TODO: Add your control notification handler code herevoid CMyDlg:OnDblclkTree1(NMHDR* pNMHDR, LRESULT* pResult) / TODO: Add your control notification handler code hereHTREEITEM hSel = m_TreeCtrl.GetSelectedItem();CString cText = m_TreeCtrl.GetItemText(hSel);if ( cText = 卡农(也能响应双击的哦) )MessageBox(你双击了“卡农”);*pResult = 0;void CMyDlg:OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult) NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;/ TODO: Add your control notification handler code hereint
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河北安全员试题及答案
- 改错练习的初级会计师试题及答案
- 系统规划与管理师备考路径试题及答案
- 网络设计师在项目管理中的角色定位试题及答案
- 深入西医临床知识体系试题及答案
- 用心学习西医临床考试应对试题及答案
- 考二建实物试题及答案
- 纺织产品性能标准化分析试题及答案
- 母猪营养配方优化试题及答案
- 网络规划设计师考试知识与实际应用的结合试题及答案
- (2024年)剪映入门教程课件
- 提升服务行业人员的职业道德和职业素养
- 眩晕诊治中国专家共识解读课件
- 按摩椅行业分析及市场前景展望报告
- 2024年上海外服招聘笔试参考题库附带答案详解
- 校园足球教育知识讲座
- 关于设备性能评估报告
- 教育专家报告合集:年度得到:沈祖芸全球教育报告(2023-2024)
- 化妆品研发与美容技术学习资料
- 中职英语 基础模块2 Unit 4 Volunteer Work
- 腹膜后肿瘤护理查房
评论
0/150
提交评论