基于对话框的QQ抽屉效果的实现.doc

上传人:仙人指路1688 文档编号:3037875 上传时间:2023-03-09 格式:DOC 页数:4 大小:23.50KB
返回 下载 相关 举报
基于对话框的QQ抽屉效果的实现.doc_第1页
第1页 / 共4页
基于对话框的QQ抽屉效果的实现.doc_第2页
第2页 / 共4页
基于对话框的QQ抽屉效果的实现.doc_第3页
第3页 / 共4页
基于对话框的QQ抽屉效果的实现.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《基于对话框的QQ抽屉效果的实现.doc》由会员分享,可在线阅读,更多相关《基于对话框的QQ抽屉效果的实现.doc(4页珍藏版)》请在三一办公上搜索。

1、基于对话框的QQ抽屉效果的实现用CGfxOutBarCtrl控件来实现QQ的抽屉菜单界面操作步骤:1.创建一个基于对话框的应用程序,程序名:OutBarDialog2.删除原有的两个按钮和静态控件。3.添加GFXGROUPEDIT.CPP、GFXGROUPEDIT.h、GFXPOPUPMENU.CPP 、GFXPOPUPMENU.h、GFXOUTBARCTRL.CPP、GFXOUTBARCTRL.h到工程中。4.在文件GFXGROUPEDIT.CPP中添加如下代码:#include OutBarDialog.h。5.在资源文件中导入需要使用的图标,(本例子中导入了11个图标)用于构筑图像列表的

2、内容,显示在抽屉的子项中。再导入三个光标文件,其ID分别为:IDCNODRAGGING、IDCHANDCUR、IDCDRAGGING在OutBarDialogDlg.h文件中添加:#define IDC_LST_MENU WM_USER+1000#include resource.h#include GfxOutBarCtrl.h6.在OutBarDialogDlg.cpp文件中添加对象:CGfxOutBarCtrl wndBar;CImageList imaLarge,imaSmall;添加图像数组:static UINT nIcons = IDI_ICON1, IDI_ICON3, IDI

3、_ICON4, IDI_ICON7, IDI_ICON8, IDI_ICON2, IDI_ICON11, IDI_ICON6, IDI_ICON9, IDI_ICON10, IDI_ICON5;7.在对话框OnInitDialog()初始化函数中添加如下代码:/创建抽屉菜单控件DWORD dwf=CGfxOutBarCtrl:fDragItems |CGfxOutBarCtrl:fEditGroups |CGfxOutBarCtrl:fEditItems |CGfxOutBarCtrl:fRemoveGroups |CGfxOutBarCtrl:fRemoveItems |CGfxOutBar

4、Ctrl:fAddGroups |CGfxOutBarCtrl:fAnimation ;/抽屉控件的大小以及位置CRect rc;GetClientRect(&rc);int r1=rc.Height();int r2=rc.Width()/5; wndBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,r2,r1),this,IDC_LST_MENU,dwf);wndBar.SetOwner(this);/创建图像列表imaSmall.Create (16, 16, ILC_COLOR16|ILC_MASK, 2, 1);imaLarge.Create (32,

5、 32, ILC_COLOR16|ILC_MASK, 2, 1);/ 初始化图像列表for (int i = 0; i LoadIcon(nIconsi);ASSERT(hIcon);imaSmall.Add(hIcon);imaLarge.Add(hIcon);/ 添加图像到抽屉控件wndBar.SetImageList(&imaLarge,CGfxOutBarCtrl:fLargeIcon);wndBar.SetImageList(&imaSmall,CGfxOutBarCtrl:fSmallIcon);/设置并添加抽屉菜单项/wndBar.SetAnimationTickCount(20

6、);/wndBar.SetAnimSelHighlight(200);/ Add the first folder to the outlook bar.int iFolder; / index of the added folderiFolder = wndBar.AddFolder(_T(Shortcuts 1), 0);/ Add items to the folder, syntax is folder, index, text, image, and item data.wndBar.InsertItem(iFolder, 1, _T(Item 1), 0, NULL);wndBar

7、.InsertItem(iFolder, 2, _T(Item 2), 1, NULL);wndBar.InsertItem(iFolder, 3, _T(Item 3), 2, NULL);wndBar.InsertItem(iFolder, 4, _T(Item 4), 3, NULL);wndBar.InsertItem(iFolder, 5, _T(Item 5), 4, NULL);wndBar.InsertItem(iFolder, 6, _T(Item 6), 5, NULL);/ Add the second folder to the outlook bar.iFolder

8、= wndBar.AddFolder(_T(Shortcuts 2), 1);/ Add items to the folder, syntax is folder, index, text, image, and item data.wndBar.InsertItem(iFolder, 1, _T(Item 1), 0, NULL);wndBar.InsertItem(iFolder, 2, _T(Item 2), 1, NULL);wndBar.SetSelFolder(0);8.消息响应机制,在OutBarDialogDlg.cpp文件中添加如下消息响应函数:afx_msg long O

9、nOutbarNotify(WPARAM wParam, LPARAM lParam);以及:BEGIN_MESSAGE_MAP(COutBarDialogDlg, CDialog)/AFX_MSG_MAP(COutBarDialogDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_MESSAGE(WM_OUTBAR_NOTIFY, OnOutbarNotify)ON_WM_SIZE()/AFX_MSG_MAP手动添加如下代码(protected):long COutBarDialogDlg:OnOutbarNotify(WP

10、ARAM wParam, LPARAM lParam)switch (wParam)case NM_OB_ITEMCLICK:/ cast the lParam to an integer to get the clicked itemint index = (int) lParam;CString cs, cs1;cs1 = wndBar.GetItemText(index);int iFloder = wndBar.GetSelFolder();cs.Format(Clicked on %d Floder - %d : , iFloder, (int)lParam, cs1);AfxMes

11、sageBox(cs);return 0;case NM_OB_ONLABELENDEDIT:/ cast the lParam to an OUTBAR_INFO * struct; it will contain info about the edited item/ return 1 to do the change and 0 to cancel itOUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;TRACE2(Editing item %d, new text:%sn, pOI-index, pOI-cText);return 1;case NM

12、_OB_ONGROUPENDEDIT:/ cast the lParam to an OUTBAR_INFO * struct; it will contain info about the edited folder/ return 1 to do the change and 0 to cancel itOUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;TRACE2(Editing folder %d, new text:%sn, pOI-index, pOI-cText);return 1;case NM_OB_DRAGITEM:/ cast the lParam to an OUTBAR_INFO * struct; it will contain info about the dragged items/ return 1 to do the change and 0 to cancel itOUTBAR_INFO * pOI = (OUTBAR_INFO *) lParam;TRACE2(Drag item %d at position %dn, pOI-iDragFrom, pOI-iDragTo);return 1;return 0;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 教育教学 > 成人教育


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号