MQQAppearanceDlg.cpp
上传用户:aokegd
上传日期:2009-12-14
资源大小:1276k
文件大小:6k
源码类别:

书籍源码

开发平台:

Visual C++

  1. // MQQAppearanceDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MQQAppearance.h"
  5. #include "MQQAppearanceDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CAboutDlg dialog used for App About
  13. class CAboutDlg : public CDialog
  14. {
  15. public:
  16. CAboutDlg();
  17. // Dialog Data
  18. //{{AFX_DATA(CAboutDlg)
  19. enum { IDD = IDD_ABOUTBOX };
  20. //}}AFX_DATA
  21. // ClassWizard generated virtual function overrides
  22. //{{AFX_VIRTUAL(CAboutDlg)
  23. protected:
  24. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  25. //}}AFX_VIRTUAL
  26. // Implementation
  27. protected:
  28. //{{AFX_MSG(CAboutDlg)
  29. //}}AFX_MSG
  30. DECLARE_MESSAGE_MAP()
  31. };
  32. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  33. {
  34. //{{AFX_DATA_INIT(CAboutDlg)
  35. //}}AFX_DATA_INIT
  36. }
  37. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CAboutDlg)
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  44. //{{AFX_MSG_MAP(CAboutDlg)
  45. // No message handlers
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CMQQAppearanceDlg dialog
  50. CMQQAppearanceDlg::CMQQAppearanceDlg(CWnd* pParent /*=NULL*/)
  51. : CDialog(CMQQAppearanceDlg::IDD, pParent)
  52. {
  53. //{{AFX_DATA_INIT(CMQQAppearanceDlg)
  54. // NOTE: the ClassWizard will add member initialization here
  55. //}}AFX_DATA_INIT
  56. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  57. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  58. }
  59. void CMQQAppearanceDlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CMQQAppearanceDlg)
  63. // NOTE: the ClassWizard will add DDX and DDV calls here
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP(CMQQAppearanceDlg, CDialog)
  67. //{{AFX_MSG_MAP(CMQQAppearanceDlg)
  68. ON_WM_SYSCOMMAND()
  69. ON_WM_PAINT()
  70. ON_WM_QUERYDRAGICON()
  71. //}}AFX_MSG_MAP
  72. END_MESSAGE_MAP()
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CMQQAppearanceDlg message handlers
  75. BOOL CMQQAppearanceDlg::OnInitDialog()
  76. {
  77. CDialog::OnInitDialog();
  78. // Add "About..." menu item to system menu.
  79. // IDM_ABOUTBOX must be in the system command range.
  80. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  81. ASSERT(IDM_ABOUTBOX < 0xF000);
  82. CMenu* pSysMenu = GetSystemMenu(FALSE);
  83. if (pSysMenu != NULL)
  84. {
  85. CString strAboutMenu;
  86. strAboutMenu.LoadString(IDS_ABOUTBOX);
  87. if (!strAboutMenu.IsEmpty())
  88. {
  89. pSysMenu->AppendMenu(MF_SEPARATOR);
  90. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  91. }
  92. }
  93. // Set the icon for this dialog.  The framework does this automatically
  94. //  when the application's main window is not a dialog
  95. SetIcon(m_hIcon, TRUE); // Set big icon
  96. SetIcon(m_hIcon, FALSE); // Set small icon
  97. // TODO: Add extra initialization here
  98. //创建抽屉菜单控件
  99. DWORD dwf = CGfxOutBarCtrl::fDragItems|CGfxOutBarCtrl::fEditGroups|CGfxOutBarCtrl::fEditItems|CGfxOutBarCtrl::fRemoveGroups|
  100. CGfxOutBarCtrl::fRemoveItems|CGfxOutBarCtrl::fAddGroups|CGfxOutBarCtrl::fAnimation
  101. |CGfxOutBarCtrl::fSelHighlight;
  102. CRect rc;
  103. GetClientRect(&rc);
  104. wndBar.Create(WS_CHILD|WS_VISIBLE, rc, this,IDC_LST_MENU, dwf);
  105. wndBar.SetOwner(this);
  106. //创建并设置大小图标链表
  107. imaLarge.Create(IDB_IMAGELIST, 32, 0, RGB(0,130,132));
  108. imaSmall.Create(IDB_SMALL_IMAGELIST, 16, 0, RGB(0,128,128));
  109. wndBar.SetImageList(&imaLarge, CGfxOutBarCtrl::fLargeIcon);
  110. wndBar.SetImageList(&imaSmall, CGfxOutBarCtrl::fSmallIcon);
  111. //创建4个抽屉
  112. wndBar.SetAnimationTickCount(20);
  113. wndBar.SetAnimSelHighlight(200);
  114. wndBar.AddFolder("我的好友", 0);
  115. wndBar.AddFolder("mm",1);
  116. wndBar.AddFolder("陌生人", 2);
  117. wndBar.AddFolder("黑名单", 3);
  118. //给第一个抽屉加图标按钮
  119. wndBar.InsertItem(0, 0, "mm", 0, 0);
  120. wndBar.InsertItem(0, 1, "angle", 1, 0);
  121. wndBar.InsertItem(0, 2, "格格", 2, 0);
  122. wndBar.InsertItem(0, 6, "杨晨", 2, 0);
  123. wndBar.InsertItem(0, 1, "小杂皮", 3, 0);
  124. wndBar.InsertItem(0, 17, "郝海东", 3, 0);
  125. //给第二个抽屉加图标按钮
  126. wndBar.InsertItem(1, 0, "朱茵", 0, 0);
  127. wndBar.InsertItem(1, 1, "梁永琪",0,0);
  128. //给第三个抽屉加图标按钮
  129. wndBar.InsertItem(2, 0, "不认识", 0, 0);
  130. //给第四个抽屉加图标按钮
  131. wndBar.InsertItem(3, 0, "强盗", 3, 0);
  132. wndBar.InsertItem(3, 1, "小偷",3,0);
  133. //打开第一个抽屉
  134. wndBar.SetSelFolder(0);
  135. return TRUE;  // return TRUE  unless you set the focus to a control
  136. }
  137. void CMQQAppearanceDlg::OnSysCommand(UINT nID, LPARAM lParam)
  138. {
  139. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  140. {
  141. CAboutDlg dlgAbout;
  142. dlgAbout.DoModal();
  143. }
  144. else
  145. {
  146. CDialog::OnSysCommand(nID, lParam);
  147. }
  148. }
  149. // If you add a minimize button to your dialog, you will need the code below
  150. //  to draw the icon.  For MFC applications using the document/view model,
  151. //  this is automatically done for you by the framework.
  152. void CMQQAppearanceDlg::OnPaint() 
  153. {
  154. if (IsIconic())
  155. {
  156. CPaintDC dc(this); // device context for painting
  157. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  158. // Center icon in client rectangle
  159. int cxIcon = GetSystemMetrics(SM_CXICON);
  160. int cyIcon = GetSystemMetrics(SM_CYICON);
  161. CRect rect;
  162. GetClientRect(&rect);
  163. int x = (rect.Width() - cxIcon + 1) / 2;
  164. int y = (rect.Height() - cyIcon + 1) / 2;
  165. // Draw the icon
  166. dc.DrawIcon(x, y, m_hIcon);
  167. }
  168. else
  169. {
  170. CDialog::OnPaint();
  171. }
  172. }
  173. // The system calls this to obtain the cursor to display while the user drags
  174. //  the minimized window.
  175. HCURSOR CMQQAppearanceDlg::OnQueryDragIcon()
  176. {
  177. return (HCURSOR) m_hIcon;
  178. }