QQDlg.cpp 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. /************************************************************************
  2. * 程序名: 精仿QQ主界面
  3. * 制作人: 李克平, 2011年04月11日
  4. * 版本号: 1.0
  5. ************************************************************************/
  6. // QQDlg.cpp : 实现文件
  7. //
  8. #include "stdafx.h"
  9. #include "QQ.h"
  10. #include "QQDlg.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #endif
  14. //收缩模式
  15. #define HM_NONE 0 //不收缩
  16. #define HM_TOP 1 //向上收缩
  17. #define HM_BOTTOM 2 //向下收缩
  18. #define HM_LEFT 3 //向左收缩
  19. #define HM_RIGHT 4 //向右收缩
  20. #define CM_ELAPSE 200 //检测鼠标是否离开窗口的时间间隔
  21. #define HS_ELAPSE 5 //隐藏或显示过程每步的时间间隔
  22. #define HS_STEPS 5 //隐藏或显示过程分成多少步
  23. #define INTERVAL 10 //触发粘附时鼠标与屏幕边界的最小间隔,单位为象素
  24. #define INFALTE 20 //触发收缩时鼠标与窗口边界的最小间隔,单位为象素
  25. #define MINCX 200 //窗口最小宽度
  26. #define MINCY 400 //窗口最小高度
  27. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  28. class CAboutDlg : public CDialog
  29. {
  30. public:
  31. CAboutDlg();
  32. // 对话框数据
  33. enum { IDD = IDD_ABOUTBOX };
  34. protected:
  35. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  36. // 实现
  37. protected:
  38. DECLARE_MESSAGE_MAP()
  39. };
  40. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  41. {
  42. }
  43. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. }
  47. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  48. END_MESSAGE_MAP()
  49. // CQQDlg 对话框
  50. CQQDlg::CQQDlg(CWnd* pParent /*=NULL*/)
  51. : CDialog(CQQDlg::IDD, pParent)
  52. {
  53. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  54. m_hrgn = NULL;
  55. bScreenMax = FALSE;
  56. m_isSizeChanged = FALSE;
  57. m_isSetTimer = FALSE;
  58. m_hsFinished = TRUE;
  59. m_hiding = FALSE;
  60. m_oldWndHeight = MINCY;
  61. m_taskBarHeight = 30;
  62. m_edgeHeight = 0;
  63. m_edgeWidth =0;
  64. m_hideMode = HM_NONE;
  65. }
  66. void CQQDlg::DoDataExchange(CDataExchange* pDX)
  67. {
  68. CDialog::DoDataExchange(pDX);
  69. DDX_Control(pDX, IDC_BTN_CLOSE, m_btnClose);
  70. DDX_Control(pDX, IDC_BTN_MAX, m_btnMax);
  71. DDX_Control(pDX, IDC_BTN_MIN, m_btnMin);
  72. DDX_Control(pDX, IDC_BTN_WEALTH, m_btnWealth);
  73. DDX_Control(pDX, IDC_BTN_TOOL, m_btnTool);
  74. DDX_Control(pDX, IDC_BTN_SMS, m_btnSMS);
  75. DDX_Control(pDX, IDC_BTN_SELL, m_btnSell);
  76. DDX_Control(pDX, IDC_BTN_PET, m_btnPet);
  77. DDX_Control(pDX, IDC_BTN_MUSIC, m_btnMusic);
  78. DDX_Control(pDX, IDC_BTN_MSG, m_btnMSG);
  79. DDX_Control(pDX, IDC_BTN_MAIL, m_btnMail);
  80. DDX_Control(pDX, IDC_BTN_LIVE, m_btnLive);
  81. DDX_Control(pDX, IDC_BTN_LIST, m_btnList);
  82. DDX_Control(pDX, IDC_BTN_GAME, m_btnGame);
  83. DDX_Control(pDX, IDC_BTN_FIND, m_btnSearch);
  84. DDX_Control(pDX, IDC_BTN_COLOR, m_btnColor);
  85. DDX_Control(pDX, IDC_BTN_CHAT, m_btnChat);
  86. DDX_Control(pDX, IDC_BTN_BRW, m_btnBRW);
  87. DDX_Control(pDX, IDC_BTN_APP, m_btnApp);
  88. DDX_Control(pDX, IDC_BTN_ONLINE, m_btnOnline);
  89. DDX_Control(pDX, IDC_BTN_MAINMENU, m_btnMainMenu);
  90. DDX_Control(pDX, IDC_BTN_MAINFIGURE, m_btnMainFigure);
  91. DDX_Control(pDX, IDC_BTN_CLOSE, m_btnClose);
  92. DDX_Control(pDX, IDC_BTN_MAX, m_btnMax);
  93. DDX_Control(pDX, IDC_BTN_MIN, m_btnMin);
  94. DDX_Control(pDX, IDC_EDIT_SEARCH, m_editSearch);
  95. DDX_Control(pDX, IDC_STATIC_USERSTATUS, m_staUserStatus);
  96. DDX_Control(pDX, IDC_STATIC_SYSTIME, m_staSysTime);
  97. DDX_Control(pDX, IDC_STATIC_TAB, m_skinTab);
  98. DDX_Control(pDX, IDC_STATIC_USERHEAD, m_staUserHead);
  99. }
  100. BEGIN_MESSAGE_MAP(CQQDlg, CDialog)
  101. ON_WM_SYSCOMMAND()
  102. ON_WM_PAINT()
  103. ON_WM_QUERYDRAGICON()
  104. ON_WM_SIZE()
  105. ON_WM_ERASEBKGND()
  106. ON_WM_GETMINMAXINFO()
  107. ON_WM_CTLCOLOR()
  108. ON_WM_SIZING()
  109. ON_WM_MOVING()
  110. ON_WM_TIMER()
  111. ON_WM_CREATE()
  112. ON_WM_NCHITTEST()
  113. ON_WM_LBUTTONDOWN()
  114. ON_BN_CLICKED(IDC_BTN_CLOSE, OnClose)
  115. ON_BN_CLICKED(IDC_BTN_MIN, OnMin)
  116. ON_BN_CLICKED(IDC_BTN_MAX, OnMax)
  117. ON_BN_CLICKED(IDC_BTN_MAINMENU, OnBnClickedBtnMainmenu)
  118. ON_BN_CLICKED(IDC_BTN_COLOR, OnBnClickedBtnColor)
  119. END_MESSAGE_MAP()
  120. // CQQDlg 消息处理程序
  121. BOOL CQQDlg::OnInitDialog()
  122. {
  123. CDialog::OnInitDialog();
  124. // 将“关于...”菜单项添加到系统菜单中。
  125. // IDM_ABOUTBOX 必须在系统命令范围内。
  126. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  127. ASSERT(IDM_ABOUTBOX < 0xF000);
  128. CMenu* pSysMenu = GetSystemMenu(FALSE);
  129. if (pSysMenu != NULL)
  130. {
  131. CString strAboutMenu;
  132. strAboutMenu.LoadString(IDS_ABOUTBOX);
  133. if (!strAboutMenu.IsEmpty())
  134. {
  135. pSysMenu->AppendMenu(MF_SEPARATOR);
  136. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  137. }
  138. }
  139. // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
  140. // 执行此操作
  141. SetIcon(m_hIcon, TRUE); // 设置大图标
  142. SetIcon(m_hIcon, FALSE); // 设置小图标
  143. //修改窗体扩展风格
  144. //ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW);
  145. // TODO: 在此添加额外的初始化代码
  146. SetWindowText("QQ2009");
  147. // TODO: Add extra initialization here
  148. m_bFirst = TRUE;
  149. if ( m_bFirst )
  150. {
  151. m_skinWin.InstallSkin( this );
  152. m_bFirst = FALSE;
  153. }
  154. CRect rcClient;
  155. GetClientRect(&rcClient);
  156. int cx = rcClient.Width();
  157. int cy = rcClient.Height();
  158. GetAppDir(strThemePath);
  159. strThemePath += _T("Skin\\DefaultTheme\\");
  160. m_mainPanle.LoadImage(strThemePath + _T("MainPanle.bmp"));
  161. CString strMouseOut,strMouseIn;
  162. m_btnClose.LoadImage(strThemePath+"Close.bmp");
  163. m_btnMax.LoadImage(strThemePath+"Max.bmp");
  164. m_btnMin.LoadImage(strThemePath+"Min.bmp");
  165. m_btnMainFigure.LoadImage(strThemePath+"MainFigure.bmp");
  166. m_staUserHead.SetParent(&m_btnMainFigure);
  167. m_staUserHead.LoadBitmap(strThemePath+"figure.bmp");
  168. //设置字体
  169. m_font.CreateFont(15, //字体高度
  170. 0, //系统选取字体最佳宽度
  171. 0, //倾斜度为0,表示水平
  172. 0, //字体倾斜度为0
  173. FW_BOLD, //字体粗度,400为正常
  174. 0, //无斜体字
  175. 0, //无下划线
  176. 0, //无删除线
  177. ANSI_CHARSET, //所用的字符集
  178. OUT_DEFAULT_PRECIS, //输出粗度为默认值
  179. OUT_DEFAULT_PRECIS, //裁减粗度为默认值
  180. DEFAULT_QUALITY, //输出质量为默认值
  181. DEFAULT_PITCH|FF_DONTCARE, //字间距和字体系列
  182. _T("Arial"));
  183. m_staUserStatus.SetText("8968737[在线]",0,RGB(7,30,129));
  184. m_staUserStatus.SetFont(&m_font);
  185. m_staSysTime.SetText(GetStrCurrentTime(),0,RGB(27,79,116));
  186. m_editSearch.LoadBitmap(strThemePath+"EditBox.bmp");
  187. m_editSearch.SetText("搜索我的好友...",20,RGB(176,176,176));
  188. m_editSearch.SetExtendPoint(12,5);
  189. m_btnOnline.LoadImage(strThemePath+"imonline.bmp",RGB(255,255,255));
  190. strMouseIn = strThemePath+"icon\\mail.ico";
  191. m_btnMail.SetIcon(strMouseIn,strMouseIn);
  192. strMouseIn = strThemePath+"icon\\sell.ico";
  193. m_btnSell.SetIcon(strMouseIn,strMouseIn);
  194. strMouseIn = strThemePath+"icon\\wealth.ico";
  195. m_btnWealth.SetIcon(strMouseIn,strMouseIn);
  196. strMouseIn = strThemePath+"icon\\list.ico";
  197. m_btnList.SetIcon(strMouseIn,strMouseIn);
  198. strMouseIn = strThemePath+"icon\\color.ico";
  199. m_btnColor.SetIcon(strMouseIn,strMouseIn);
  200. strMouseIn = strThemePath+"icon\\sms.ico";
  201. m_btnSMS.SetIcon(strMouseIn,strMouseIn);
  202. strMouseIn = strThemePath+"icon\\game.ico";
  203. m_btnGame.SetIcon(strMouseIn,strMouseIn);
  204. strMouseIn = strThemePath+"icon\\brw.ico";
  205. m_btnBRW.SetIcon(strMouseIn,strMouseIn);
  206. strMouseIn = strThemePath+"icon\\chat.ico";
  207. m_btnChat.SetIcon(strMouseIn,strMouseIn);
  208. strMouseIn = strThemePath+"icon\\pet.ico";
  209. m_btnPet.SetIcon(strMouseIn,strMouseIn);
  210. strMouseIn = strThemePath+"icon\\music.ico";
  211. m_btnMusic.SetIcon(strMouseIn,strMouseIn);
  212. strMouseIn = strThemePath+"icon\\live.ico";
  213. m_btnLive.SetIcon(strMouseIn,strMouseIn);
  214. strMouseIn = strThemePath+"icon\\app.ico";
  215. m_btnApp.SetIcon(strMouseIn,strMouseIn);
  216. strMouseIn = strThemePath+"icon\\tool.ico";
  217. m_btnTool.SetIcon(strMouseIn,strMouseIn);
  218. strMouseIn = strThemePath+"icon\\msg.ico";
  219. m_btnMSG.SetIcon(strMouseIn,strMouseIn);
  220. strMouseIn = strThemePath+"icon\\search.ico";
  221. m_btnSearch.SetIcon(strMouseIn,strMouseIn);
  222. m_btnSearch.SetWindowText(_T("查找"));
  223. m_btnSearch.SetColor(RGB(11,77,124),RGB(11,77,124));
  224. m_leftPanle.LoadImage(strThemePath+"leftBar.bmp");
  225. m_outBarCtrl.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),this,IDC_GFXOUTBAR);
  226. m_outBarCtrl.SetFolderImage(strThemePath+"Bar.bmp");
  227. m_outBarCtrl.SetSelIcon(strThemePath+"icon\\Find.ico");
  228. wndTree.Create(WS_CHILD|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS, CRect(0,0,0,0), &m_outBarCtrl, 1010);
  229. //wndTree.SetImageList(&imaSmall, TVSIL_NORMAL);
  230. HTREEITEM htm = wndTree.InsertItem("tree 1", 0,0);
  231. HTREEITEM htm1 = wndTree.InsertItem("tree 2", 1,1, htm);
  232. wndTree.InsertItem("tree 3", 1,1, htm);
  233. for (int xx = 0; xx < 15; xx ++)
  234. {
  235. htm = wndTree.InsertItem("tree 1", 0,0);
  236. htm1 = wndTree.InsertItem("tree 2", 1,1, htm);
  237. wndTree.InsertItem("tree 3", 1,1, htm);
  238. htm = wndTree.InsertItem("tree 1", 0,0);
  239. htm1 = wndTree.InsertItem("tree asda2", 1,1, htm);
  240. wndTree.InsertItem("tree 3", 1,1, htm);
  241. }
  242. m_imHead.Create(40, 40, ILC_MASK|ILC_COLOR32, 1, 1);
  243. //添加ID 为IDI_ICON的图标
  244. //m_imHead.Add( AfxGetApp()->LoadIcon(IDI_ICON));
  245. //从图标文件中加载并添加
  246. // HICON hIcon = (HICON)LoadImage(NULL, ".\\image\\SQQun.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE)
  247. // m_imHead.Add(hIcon);
  248. //从位图文件中加载并添加
  249. CBitmap *pBitmap=new CBitmap;
  250. CString strHead,strApp;
  251. GetAppDir(strApp);
  252. for(int i = 1;i<=134;i++)
  253. {
  254. strHead.Format("NEWFACE\\%d.bmp",i);
  255. strHead = strApp + strHead;
  256. pBitmap->m_hObject = (HBITMAP) LoadImage(NULL, strHead, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
  257. m_imHead.Add(pBitmap, RGB(255,255, 255)/*mask color*/);
  258. }
  259. delete pBitmap;
  260. //先创建ListCtrl (m_MyFriendListCtrl)
  261. if(m_MyFriendListCtrl.Create(LVS_REPORT |LVS_NOCOLUMNHEADER|LVS_OWNERDRAWFIXED|LVS_SHOWSELALWAYS|WS_CHILD,
  262. CRect(0,0,0,0), &m_outBarCtrl, IDD_TALKER_LIST/*ID*/))
  263. {
  264. m_MyFriendListCtrl.SetExtendedStyle( m_MyFriendListCtrl.GetExtendedStyle()| LVS_EX_FULLROWSELECT);
  265. m_MyFriendListCtrl.SetImageList(&m_imHead,LVSIL_SMALL);
  266. m_MyFriendListCtrl.InsertColumn(0,"名字",LVCFMT_LEFT);
  267. //m_MyFriendListCtrl.SetColumnWidth(0 ,100);
  268. //往ListCtrl 中添加好友
  269. for(int i=0; i<134; i++)
  270. {
  271. CString strTemp = _T("");
  272. LUSERITEM userInfo = {0};
  273. //CString strTemp;
  274. strTemp.Format("我的好友%d",i);
  275. userInfo.szUserID = strTemp.GetBuffer(strTemp.GetLength());
  276. strTemp.ReleaseBuffer();
  277. userInfo.szNoticeMsg = _T("没有你,世界寸步难行!");
  278. m_MyFriendListCtrl.InsertItem(i,strTemp, i,&userInfo);//第三个参数 Index of the ImageList
  279. m_MyFriendListCtrl.SetItemData(i,(i%2)? i|CMyListCtrl::TVS_EMAIL:i);
  280. }
  281. }
  282. m_outBarCtrl.AddFolderBar("QQ好友",&m_MyFriendListCtrl,0);
  283. m_outBarCtrl.AddFolderBar("通讯录", &wndTree,1);
  284. m_outBarCtrl.AddFolder("QQ群",2);
  285. m_outBarCtrl.AddFolder("最近联系人",3);
  286. m_outBarCtrl.SetSelFolder(0);
  287. m_skinTab.SetSkin(strThemePath+"TabBG.bmp");
  288. //m_skinTab.SetSkinBG(strThemePath+"leftBar.bmp");
  289. m_skinTab.SetIcon(0,strThemePath+"icon\\FriendButton.ico",&m_outBarCtrl);
  290. m_skinTab.SetIcon(1,strThemePath+"icon\\NetDiskButton.ico",NULL);
  291. m_skinTab.SetIcon(2,strThemePath+"icon\\QZONE_Bar.ico",NULL);
  292. m_skinTab.SetIcon(3,strThemePath+"icon\\papa.ico",NULL);
  293. m_skinTab.SetIcon(4,strThemePath+"icon\\ContentsButton.ico",NULL);
  294. m_skinTab.SetIcon(5,strThemePath+"icon\\BlankPanel.ico",NULL);
  295. m_skinTab.m_iCurrentSelect=0;
  296. m_btnMainMenu.LoadImage(strThemePath+"MainMenu.bmp");
  297. SetTimer(3,1000,NULL); //开启系统时间显示
  298. return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
  299. }
  300. void CQQDlg::OnSysCommand(UINT nID, LPARAM lParam)
  301. {
  302. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  303. {
  304. CAboutDlg dlgAbout;
  305. dlgAbout.DoModal();
  306. }
  307. else
  308. {
  309. CDialog::OnSysCommand(nID, lParam);
  310. }
  311. }
  312. // 如果向对话框添加最小化按钮,则需要下面的代码
  313. // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
  314. // 这将由框架自动完成。
  315. void CQQDlg::OnPaint()
  316. {
  317. if (IsIconic())
  318. {
  319. CPaintDC dc(this); // 用于绘制的设备上下文
  320. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  321. // 使图标在工作区矩形中居中
  322. int cxIcon = GetSystemMetrics(SM_CXICON);
  323. int cyIcon = GetSystemMetrics(SM_CYICON);
  324. CRect rect;
  325. GetClientRect(&rect);
  326. int x = (rect.Width() - cxIcon + 1) / 2;
  327. int y = (rect.Height() - cyIcon + 1) / 2;
  328. // 绘制图标
  329. dc.DrawIcon(x, y, m_hIcon);
  330. }
  331. else
  332. {
  333. ChangeWindowRgn();
  334. AdjustControl();
  335. CPaintDC dc(this); // 用于绘制的设备上下文
  336. CRect rcClient;
  337. GetClientRect(&rcClient);
  338. //调整控件位置////////////////////////////
  339. //内存画图//////////////////////////
  340. CDC m_MemDC;
  341. m_MemDC.CreateCompatibleDC(&dc);
  342. CBitmap btScreen;
  343. btScreen.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
  344. m_MemDC.SelectObject(&btScreen);
  345. btScreen.DeleteObject();
  346. //画背景
  347. //MemDC.Rectangle(rcClient);
  348. //m_MemDC.FillSolidRect(rcClient,RGB(91,195,252));//draw the backGround
  349. if (m_mainPanle.m_hObject !=0)
  350. m_mainPanle.ExtendDraw(&m_MemDC,rcClient,100,125);
  351. if(m_leftPanle.m_hObject != 0)
  352. {
  353. m_leftPanle.ExtendDraw(&m_MemDC,
  354. CRect(2,115,m_leftPanle.Width()+1,rcClient.bottom-50),2,10);
  355. }
  356. //创建不规则窗体
  357. //ChangeWindowRgn(&m_MemDC);
  358. //ChangeWindowRgn();
  359. //重画控件/////////////////////////
  360. ReDrawCrl(&m_MemDC);
  361. //画到显示器上////////////////////////////
  362. dc.BitBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), &m_MemDC, 0, 0, SRCCOPY);
  363. m_MemDC.DeleteDC();
  364. }
  365. }
  366. //当用户拖动最小化窗口时系统调用此函数取得光标
  367. //显示。
  368. HCURSOR CQQDlg::OnQueryDragIcon()
  369. {
  370. return static_cast<HCURSOR>(m_hIcon);
  371. }
  372. BOOL CQQDlg::PreTranslateMessage(MSG* pMsg)
  373. {
  374. // TODO: 在此添加专用代码和/或调用基类
  375. // 单击除了窗口标题栏以外的区域使窗口移动
  376. if (pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_hWnd)
  377. {
  378. pMsg->message = WM_NCLBUTTONDOWN;
  379. pMsg->wParam = HTCAPTION;
  380. }
  381. if (pMsg->message == WM_LBUTTONDBLCLK && pMsg->hwnd == m_hWnd)
  382. {
  383. OnMax();
  384. }
  385. return CDialog::PreTranslateMessage(pMsg);
  386. }
  387. void CQQDlg::OnMax()
  388. {
  389. // TODO: Add your control notification handler code here
  390. if(bScreenMax)
  391. {
  392. m_btnMax.LoadImage(strThemePath+"max.bmp");
  393. ::MoveWindow( m_hWnd, m_rectRestoreWin.left, m_rectRestoreWin.top,
  394. m_rectRestoreWin.Width(), m_rectRestoreWin.Height(), TRUE );
  395. bScreenMax = FALSE;
  396. UpdateWindow();
  397. }
  398. else
  399. {
  400. CRect rc;
  401. SystemParametersInfo(SPI_GETWORKAREA, 0, rc, 0);
  402. GetWindowRect(m_rectRestoreWin );
  403. m_btnMax.LoadImage(strThemePath+"restore.bmp");
  404. //ShowWindow(SW_SHOWMAXIMIZED);
  405. ::MoveWindow( m_hWnd, rc.left, rc.top, rc.Width(), rc.Height(), TRUE);
  406. bScreenMax = TRUE;
  407. UpdateWindow();
  408. }
  409. }
  410. void CQQDlg::OnSize(UINT nType, int cx, int cy)
  411. {
  412. CDialog::OnSize(nType, cx, cy);
  413. Invalidate();
  414. // TODO: 在此处添加消息处理程序代码
  415. }
  416. BOOL CQQDlg::OnEraseBkgnd(CDC* pDC)
  417. {
  418. // TODO: 在此添加消息处理程序代码和/或调用默认值
  419. return TRUE;
  420. //return CDialog::OnEraseBkgnd(pDC);
  421. }
  422. //创建不规则窗体
  423. void CQQDlg::ChangeWindowRgn()
  424. {
  425. CRect rc;
  426. GetClientRect(&rc);
  427. CEnBitmap bmpMain;
  428. if (m_mainPanle.m_hObject !=NULL)
  429. m_mainPanle.ExtendDrawImage(bmpMain,rc,100,125);
  430. if(m_hrgn)
  431. DeleteObject(m_hrgn);
  432. m_hrgn = bmpMain.BitmapToRegion(RGB(255,0,255));
  433. SetWindowRgn(m_hrgn,TRUE);
  434. bmpMain.DeleteObject();
  435. }
  436. void CQQDlg::ReDrawCrl(CDC* m_MemDC)
  437. {
  438. CRect rcClient;
  439. GetClientRect(&rcClient);
  440. static bool firstGetClientRect = true;
  441. static int preClientHeight = rcClient.Height();
  442. static int preClientWidth = rcClient.Width();
  443. if(firstGetClientRect)
  444. {
  445. firstGetClientRect = false;
  446. }
  447. if(firstGetClientRect||preClientHeight!=rcClient.Height()||preClientWidth!=rcClient.Width())
  448. {
  449. preClientHeight = rcClient.Height();
  450. preClientWidth = rcClient.Width();
  451. CEnBitmap *bmpPaint = NULL;
  452. CImage *image=NULL;
  453. CRect rect;
  454. CRect rcIcon;
  455. CPoint ptText;
  456. CString strText;
  457. //CFont font;
  458. //font.CreatePointFont(90,_T("Arial"));
  459. //m_MemDC->SelectObject(&font);
  460. GetClientRect(&rect);
  461. int cx=rect.Width();
  462. int cy=rect.Height();
  463. m_staUserStatus.Redraw(m_MemDC);
  464. m_staSysTime.Redraw(m_MemDC);
  465. m_MemDC->BitBlt(5,90,cx-10,m_editSearch.Height(),m_editSearch.GetWindowDC(),0,0,SRCCOPY);
  466. m_MemDC->BitBlt(1,115,m_skinTab.Width(),m_skinTab.Heighth(),m_skinTab.GetWindowDC(),0,0,SRCCOPY);
  467. if(m_skinTab.m_iCurrentSelect == 0)
  468. m_MemDC->BitBlt(37,117,cx-43,cy-173,m_outBarCtrl.GetWindowDC(),0,0,SRCCOPY);
  469. bmpPaint = m_btnMainFigure.GetPaintBmp();
  470. rect = m_btnMainFigure.GetRectInParent();
  471. if(bmpPaint->m_hObject != 0)
  472. bmpPaint->TransparentBlt(*m_MemDC, rect, RGB(255,0,255));
  473. bmpPaint = m_btnMin.GetPaintBmp();
  474. rect = m_btnMin.GetRectInParent();
  475. if(bmpPaint->m_hObject != 0)
  476. bmpPaint->TransparentBlt(*m_MemDC, rect, RGB(255,0,255));
  477. bmpPaint = m_btnMax.GetPaintBmp();
  478. rect = m_btnMax.GetRectInParent();
  479. if(bmpPaint->m_hObject != 0)
  480. bmpPaint->TransparentBlt(*m_MemDC, rect, RGB(255,0,255));
  481. bmpPaint = m_btnClose.GetPaintBmp();
  482. rect = m_btnClose.GetRectInParent();
  483. if(bmpPaint->m_hObject != 0)
  484. bmpPaint->TransparentBlt(*m_MemDC, rect, RGB(255,0,255));
  485. bmpPaint = m_btnMainMenu.GetPaintBmp();
  486. rect = m_btnMainMenu.GetRectInParent();
  487. if(bmpPaint->m_hObject != 0)
  488. bmpPaint->TransparentBlt(*m_MemDC, rect, RGB(255,0,255));
  489. bmpPaint = m_btnOnline.GetPaintBmp();
  490. rect = m_btnOnline.GetRectInParent();
  491. if(bmpPaint->m_hObject != 0)
  492. bmpPaint->TransparentBlt(*m_MemDC, rect, RGB(255,255,255));
  493. image=m_btnMail.GetPaintIcon();
  494. rect = m_btnMail.GetRectInParent();
  495. if(!image->IsNull())
  496. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  497. image=m_btnSell.GetPaintIcon();
  498. rect = m_btnSell.GetRectInParent();
  499. if(!image->IsNull())
  500. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  501. image=m_btnWealth.GetPaintIcon();
  502. rect = m_btnWealth.GetRectInParent();
  503. if(!image->IsNull())
  504. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  505. image=m_btnList.GetPaintIcon();
  506. rect = m_btnList.GetRectInParent();
  507. if(!image->IsNull())
  508. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  509. image=m_btnColor.GetPaintIcon();
  510. rect = m_btnColor.GetRectInParent();
  511. if(!image->IsNull())
  512. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  513. image=m_btnSMS.GetPaintIcon();
  514. rect = m_btnSMS.GetRectInParent();
  515. if(!image->IsNull())
  516. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  517. image=m_btnGame.GetPaintIcon();
  518. rect = m_btnGame.GetRectInParent();
  519. if(!image->IsNull())
  520. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  521. image=m_btnBRW.GetPaintIcon();
  522. rect = m_btnBRW.GetRectInParent();
  523. if(!image->IsNull())
  524. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  525. image=m_btnChat.GetPaintIcon();
  526. rect = m_btnChat.GetRectInParent();
  527. if(!image->IsNull())
  528. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  529. image=m_btnPet.GetPaintIcon();
  530. rect = m_btnPet.GetRectInParent();
  531. if(!image->IsNull())
  532. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  533. image=m_btnMusic.GetPaintIcon();
  534. rect = m_btnMusic.GetRectInParent();
  535. if(!image->IsNull())
  536. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  537. image=m_btnLive.GetPaintIcon();
  538. rect = m_btnLive.GetRectInParent();
  539. if(!image->IsNull())
  540. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  541. image=m_btnApp.GetPaintIcon();
  542. rect = m_btnApp.GetRectInParent();
  543. if(!image->IsNull())
  544. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  545. image=m_btnTool.GetPaintIcon();
  546. rect = m_btnTool.GetRectInParent();
  547. if(!image->IsNull())
  548. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  549. image=m_btnMSG.GetPaintIcon();
  550. rect = m_btnMSG.GetRectInParent();
  551. if(!image->IsNull())
  552. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  553. image=m_btnSearch.GetPaintIcon();
  554. rect = m_btnSearch.GetRectInParent();
  555. if(!image->IsNull())
  556. {
  557. image->TransparentBlt(m_MemDC->m_hDC, rect.left+2,rect.top+2,16,16, RGB(0,0,0));
  558. ptText = m_btnSearch.GetTextPos();
  559. m_btnSearch.GetWindowText(strText);
  560. m_MemDC->TextOut(rect.left+ptText.x+2,rect.top+ptText.y+2,strText);
  561. }
  562. }
  563. }
  564. void CQQDlg::AdjustControl()
  565. {
  566. CRect rc;
  567. GetClientRect(&rc);
  568. int cx=rc.Width();
  569. int cy=rc.Height();
  570. m_btnClose.SetWindowPos(NULL,cx-m_btnClose.Width()-10 ,0 ,0,0, SWP_NOSIZE);
  571. m_btnMax.SetWindowPos(NULL,cx-m_btnClose.Width()-m_btnMax.Width()-10 ,0 ,0,0, SWP_NOSIZE);
  572. m_btnMin.SetWindowPos(NULL,cx-m_btnClose.Width()-m_btnMax.Width()-m_btnMin.Width()-10 ,0 ,0,0, SWP_NOSIZE);
  573. m_btnMainFigure.SetWindowPos(NULL,5,30,0,0,SWP_NOSIZE);
  574. m_staUserHead.SetWindowPos(NULL,9,9,40,40,NULL);
  575. m_btnMail.SetWindowPos(NULL,70 ,66,0,0, SWP_NOSIZE);
  576. m_btnSell.SetWindowPos(NULL,70 +25,66,0,0, SWP_NOSIZE);
  577. m_btnWealth.SetWindowPos(NULL,70 +25*2,66,0,0, SWP_NOSIZE);
  578. m_btnList.SetWindowPos(NULL,70 +25*3,66,0,0, SWP_NOSIZE);
  579. m_btnColor.SetWindowPos(NULL,cx-30,66,0,0, SWP_NOSIZE);
  580. m_staUserStatus.SetWindowPos(NULL,85,30,0,0,SWP_NOSIZE);
  581. m_staSysTime.SetWindowPos(NULL,70,50,0,0,SWP_NOSIZE);
  582. m_editSearch.SetWindowPos(NULL,5,90,cx-10,m_editSearch.Height(),NULL);
  583. m_btnOnline.SetWindowPos(NULL,70,35,0,0,SWP_NOSIZE);
  584. m_btnSMS.SetWindowPos(NULL,50,cy-50,0,0, SWP_NOSIZE);
  585. m_btnGame.SetWindowPos(NULL,50 +25,cy-50,0,0, SWP_NOSIZE);
  586. m_btnBRW.SetWindowPos(NULL,50 +25*2,cy-50,0,0, SWP_NOSIZE);
  587. m_btnChat.SetWindowPos(NULL,50 +25*3,cy-50,0,0, SWP_NOSIZE);
  588. m_btnPet.SetWindowPos(NULL,50 +25*4,cy-50,0,0, SWP_NOSIZE);
  589. m_btnMusic.SetWindowPos(NULL,50 +25*5,cy-50,0,0, SWP_NOSIZE);
  590. m_btnLive.SetWindowPos(NULL,50 +25*6,cy-50,0,0, SWP_NOSIZE);
  591. m_btnApp.SetWindowPos(NULL,50 ,cy-25,0,0, SWP_NOSIZE);
  592. m_btnTool.SetWindowPos(NULL,50+25,cy-25,0,0, SWP_NOSIZE);
  593. m_btnMSG.SetWindowPos(NULL,50 +25*2 ,cy-25,0,0, SWP_NOSIZE);
  594. m_btnSearch.SetWindowPos(NULL,50 +25*3 ,cy-25,50,20, NULL);
  595. m_skinTab.SetWindowPos(NULL,1,115,m_skinTab.Width(),m_skinTab.Heighth(),NULL);
  596. m_outBarCtrl.SetWindowPos(NULL,37,117,cx-43,cy-173,NULL);
  597. m_btnMainMenu.SetWindowPos(NULL,0 ,cy-m_btnMainMenu.Heighth(),0,0, SWP_NOSIZE);
  598. }
  599. void CQQDlg::OnClose()
  600. {
  601. // TODO: 在此添加控件通知处理程序代码
  602. PostQuitMessage(0);
  603. }
  604. void CQQDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
  605. {
  606. // TODO: 在此添加消息处理程序代码和/或调用默认值
  607. lpMMI->ptMinTrackSize = CPoint( m_mainPanle.Width()+10, m_mainPanle.Height()+300 );
  608. CDialog::OnGetMinMaxInfo(lpMMI);
  609. }
  610. HBRUSH CQQDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  611. {
  612. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  613. // TODO: 在此更改 DC 的任何属性
  614. switch (nCtlColor)
  615. {
  616. case CTLCOLOR_STATIC:
  617. {
  618. //判断背景画刷和位图背景是否有效,当二者之一有效时
  619. //类名字符串最大长度
  620. #define MAX_CLASS_NAME 255
  621. //对于静态控件
  622. if (nCtlColor == CTLCOLOR_STATIC)
  623. {
  624. TCHAR lpszClassName [MAX_CLASS_NAME + 1];
  625. //获取控件的类名信息
  626. ::GetClassName (pWnd->GetSafeHwnd (), lpszClassName, MAX_CLASS_NAME);
  627. CString strClass = lpszClassName;
  628. //一般静态文本
  629. if (strClass == _T("Static"))
  630. {
  631. pDC->SetBkMode(TRANSPARENT);
  632. return (HBRUSH) ::GetStockObject (HOLLOW_BRUSH);
  633. }
  634. //分组框左上角静态文本
  635. if (strClass == _T("Button"))
  636. {
  637. //pDC->SetBkMode(TRANSPARENT);
  638. pDC->SetBkColor(GetSysColor(COLOR_3DFACE));
  639. return (HBRUSH) ::GetStockObject (NULL_BRUSH);
  640. //return (HBRUSH)m_brBkgr.GetSafeHandle();
  641. }
  642. }
  643. }
  644. break;
  645. }
  646. // TODO: 如果默认的不是所需画笔,则返回另一个画笔
  647. return hbr;
  648. }
  649. void CQQDlg::OnMin()
  650. {
  651. ShowWindow(SW_SHOWMINIMIZED);
  652. }
  653. void CQQDlg::OnSizing(UINT fwSide, LPRECT pRect)
  654. {
  655. FixSizing(fwSide,pRect); //修正pRect
  656. CDialog::OnSizing(fwSide, pRect);
  657. }
  658. void CQQDlg::FixSizing(UINT fwSide, LPRECT pRect)
  659. {
  660. CRect curRect(pRect);
  661. if(curRect.Width() < MINCX || curRect.Height() < MINCY)
  662. { //小于指定的最小宽度或高度
  663. switch(fwSide)
  664. {
  665. case WMSZ_BOTTOM:
  666. pRect->bottom = pRect->top + MINCY;
  667. break;
  668. case WMSZ_BOTTOMLEFT:
  669. if(curRect.Width() <= MINCX)
  670. pRect->left = pRect->right - MINCX;
  671. if(curRect.Height() <= MINCY)
  672. pRect->bottom = pRect->top + MINCY;
  673. break;
  674. case WMSZ_BOTTOMRIGHT:
  675. if(curRect.Width() < MINCX)
  676. pRect->right = pRect->left + MINCX;
  677. if(curRect.Height() < MINCY)
  678. pRect->bottom = pRect->top + MINCY;
  679. break;
  680. case WMSZ_LEFT:
  681. pRect->left = pRect->right - MINCX;
  682. break;
  683. case WMSZ_RIGHT:
  684. pRect->right = pRect->left + MINCX;
  685. break;
  686. case WMSZ_TOP:
  687. pRect->top = pRect->bottom - MINCY;
  688. break;
  689. case WMSZ_TOPLEFT:
  690. if(curRect.Width() <= MINCX)
  691. pRect->left = pRect->right - MINCX;
  692. if(curRect.Height() <= MINCY)
  693. pRect->top = pRect->bottom - MINCY;
  694. break;
  695. case WMSZ_TOPRIGHT:
  696. if(curRect.Width() < MINCX)
  697. pRect->right = pRect->left + MINCX;
  698. if(curRect.Height() < MINCY)
  699. pRect->top = pRect->bottom - MINCY;
  700. break;
  701. }
  702. }
  703. }
  704. void CQQDlg::OnMoving(UINT fwSide, LPRECT pRect)
  705. {
  706. FixMoving(fwSide,pRect); //修正pRect
  707. CDialog::OnMoving(fwSide, pRect);
  708. }
  709. void CQQDlg::FixMoving(UINT fwSide, LPRECT pRect)
  710. {
  711. POINT curPos;
  712. GetCursorPos(&curPos);
  713. INT screenHeight = GetSystemMetrics(SM_CYSCREEN);
  714. INT screenWidth = GetSystemMetrics(SM_CXSCREEN);
  715. INT height = pRect->bottom - pRect->top;
  716. INT width = pRect->right - pRect->left;
  717. if (curPos.y <= INTERVAL)
  718. { //粘附在上边
  719. pRect->bottom = height - m_edgeHeight;
  720. pRect->top = -m_edgeHeight;
  721. m_hideMode = HM_TOP;
  722. }
  723. else if(curPos.y >= (screenHeight - INTERVAL - m_taskBarHeight))
  724. { //粘附在下边
  725. pRect->top = screenHeight - m_taskBarHeight - height;
  726. pRect->bottom = screenHeight - m_taskBarHeight;
  727. m_hideMode = HM_BOTTOM;
  728. }
  729. else if (curPos.x < INTERVAL)
  730. { //粘附在左边
  731. if(!m_isSizeChanged)
  732. {
  733. CRect tRect;
  734. GetWindowRect(tRect);
  735. m_oldWndHeight = tRect.Height();
  736. }
  737. pRect->right = width;
  738. pRect->left = 0;
  739. pRect->top = -m_edgeHeight;
  740. pRect->bottom = screenHeight - m_taskBarHeight;
  741. m_isSizeChanged = TRUE;
  742. m_hideMode = HM_LEFT;
  743. }
  744. else if(curPos.x >= (screenWidth - INTERVAL))
  745. { //粘附在右边
  746. if(!m_isSizeChanged)
  747. {
  748. CRect tRect;
  749. GetWindowRect(tRect);
  750. m_oldWndHeight = tRect.Height();
  751. }
  752. pRect->left = screenWidth - width;
  753. pRect->right = screenWidth;
  754. pRect->top = -m_edgeHeight;
  755. pRect->bottom = screenHeight - m_taskBarHeight;
  756. m_isSizeChanged = TRUE;
  757. m_hideMode = HM_RIGHT;
  758. }
  759. else
  760. { //不粘附
  761. if(m_isSizeChanged)
  762. { //如果收缩到两边,则拖出来后会变回原来大小
  763. //在"拖动不显示窗口内容下"只有光栅变回原来大小
  764. pRect->bottom = pRect->top + m_oldWndHeight;
  765. m_isSizeChanged = FALSE;
  766. }
  767. if(m_isSetTimer)
  768. { //如果Timer开启了,则关闭之
  769. if(KillTimer(1) == 1)
  770. m_isSetTimer = FALSE;
  771. }
  772. m_hideMode = HM_NONE;
  773. //GetDlgItem(IDC_TIMER)->SetWindowText("Timer off");
  774. }
  775. }
  776. void CQQDlg::OnTimer(UINT_PTR nIDEvent)
  777. {
  778. // TODO: Add your message handler code here and/or call default
  779. if(nIDEvent == 1 )
  780. {
  781. POINT curPos;
  782. GetCursorPos(&curPos);
  783. //CString str;
  784. //str.Format("Timer On(%d,%d)",curPos.x,curPos.y);
  785. //GetDlgItem(IDC_TIMER)->SetWindowText(str);
  786. CRect tRect;
  787. //获取此时窗口大小
  788. GetWindowRect(tRect);
  789. //膨胀tRect,以达到鼠标离开窗口边沿一定距离才触发事件
  790. tRect.InflateRect(INFALTE,INFALTE);
  791. if(!tRect.PtInRect(curPos)) //如果鼠标离开了这个区域
  792. {
  793. KillTimer(1); //关闭检测鼠标Timer
  794. m_isSetTimer = FALSE;
  795. //GetDlgItem(IDC_TIMER)->SetWindowText("Timer Off");
  796. m_hsFinished = FALSE;
  797. m_hiding = TRUE;
  798. SetTimer(2,HS_ELAPSE,NULL); //开启收缩过程
  799. }
  800. }
  801. if(nIDEvent == 2)
  802. {
  803. if(m_hsFinished) //如果收缩或显示过程完毕则关闭Timer
  804. KillTimer(2);
  805. else
  806. m_hiding ? DoHide() : DoShow();
  807. }
  808. if(nIDEvent == 3)
  809. {
  810. m_staSysTime.SetText(GetStrCurrentTime(),0,RGB(27,79,116));
  811. InvalidateRect(m_staSysTime.GetRectInParent(),TRUE);
  812. }
  813. CDialog::OnTimer(nIDEvent);
  814. }
  815. CString CQQDlg::GetStrCurrentTime()
  816. {
  817. CTime CurTime=CTime::GetCurrentTime();
  818. int nWeek = CurTime.GetDayOfWeek();
  819. CString strWeek,strTime;
  820. switch(nWeek)
  821. {
  822. case 1: strWeek = _T("星期日"); break;
  823. case 2: strWeek = _T("星期一"); break;
  824. case 3: strWeek = _T("星期二"); break;
  825. case 4: strWeek = _T("星期三"); break;
  826. case 5: strWeek = _T("星期四"); break;
  827. case 6: strWeek = _T("星期五"); break;
  828. case 7: strWeek = _T("星期六"); break;
  829. default: break;
  830. }
  831. //strTime = CurTime.Format("%m月%d日 星期%w %X");
  832. strTime.Format(_T("%d月%d日 %s %s"),CurTime.GetMonth(),CurTime.GetDay(),strWeek,CurTime.Format("%X"));
  833. return strTime;
  834. }
  835. BOOL CQQDlg::SetWindowPos(const CWnd* pWndInsertAfter, LPCRECT pCRect, UINT nFlags)
  836. {
  837. return CDialog::SetWindowPos(pWndInsertAfter,pCRect->left, pCRect->top,
  838. pCRect->right - pCRect->left, pCRect->bottom - pCRect->top, nFlags);
  839. }
  840. void CQQDlg::DoHide()
  841. {
  842. if(m_hideMode == HM_NONE)
  843. return;
  844. CRect tRect;
  845. GetWindowRect(tRect);
  846. INT height = tRect.Height();
  847. INT width = tRect.Width();
  848. INT steps = 0;
  849. switch(m_hideMode)
  850. {
  851. case HM_TOP:
  852. steps = height/HS_STEPS;
  853. tRect.bottom -= steps;
  854. if(tRect.bottom <= m_edgeWidth)
  855. { //你可以把下面一句替换上面的 ...+=|-=steps 达到取消抽屉效果
  856. //更好的办法是添加个BOOL值来控制,其他case同样.
  857. tRect.bottom = m_edgeWidth;
  858. m_hsFinished = TRUE; //完成隐藏过程
  859. }
  860. tRect.top = tRect.bottom - height;
  861. break;
  862. case HM_BOTTOM:
  863. steps = height/HS_STEPS;
  864. tRect.top += steps;
  865. if(tRect.top >= (GetSystemMetrics(SM_CYSCREEN) - m_edgeWidth))
  866. {
  867. tRect.top = GetSystemMetrics(SM_CYSCREEN) - m_edgeWidth;
  868. m_hsFinished = TRUE;
  869. }
  870. tRect.bottom = tRect.top + height;
  871. break;
  872. case HM_LEFT:
  873. steps = width/HS_STEPS;
  874. tRect.right -= steps;
  875. if(tRect.right <= m_edgeWidth)
  876. {
  877. tRect.right = m_edgeWidth;
  878. m_hsFinished = TRUE;
  879. }
  880. tRect.left = tRect.right - width;
  881. tRect.top = -m_edgeHeight;
  882. tRect.bottom = GetSystemMetrics(SM_CYSCREEN) - m_taskBarHeight;
  883. break;
  884. case HM_RIGHT:
  885. steps = width/HS_STEPS;
  886. tRect.left += steps;
  887. if(tRect.left >= (GetSystemMetrics(SM_CXSCREEN) - m_edgeWidth))
  888. {
  889. tRect.left = GetSystemMetrics(SM_CXSCREEN) - m_edgeWidth;
  890. m_hsFinished = TRUE;
  891. }
  892. tRect.right = tRect.left + width;
  893. tRect.top = -m_edgeHeight;
  894. tRect.bottom = GetSystemMetrics(SM_CYSCREEN) - m_taskBarHeight;
  895. break;
  896. default:
  897. break;
  898. }
  899. SetWindowPos(&wndTopMost,tRect);
  900. }
  901. void CQQDlg::DoShow()
  902. {
  903. if(m_hideMode == HM_NONE)
  904. return;
  905. CRect tRect;
  906. GetWindowRect(tRect);
  907. INT height = tRect.Height();
  908. INT width = tRect.Width();
  909. INT steps = 0;
  910. switch(m_hideMode)
  911. {
  912. case HM_TOP:
  913. steps = height/HS_STEPS;
  914. tRect.top += steps;
  915. if(tRect.top >= -m_edgeHeight)
  916. { //你可以把下面一句替换上面的 ...+=|-=steps 达到取消抽屉效果
  917. //更好的办法是添加个BOOL值来控制,其他case同样.
  918. tRect.top = -m_edgeHeight;
  919. m_hsFinished = TRUE; //完成显示过程
  920. }
  921. tRect.bottom = tRect.top + height;
  922. break;
  923. case HM_BOTTOM:
  924. steps = height/HS_STEPS;
  925. tRect.top -= steps;
  926. if(tRect.top <= (GetSystemMetrics(SM_CYSCREEN) - height))
  927. {
  928. tRect.top = GetSystemMetrics(SM_CYSCREEN) - height;
  929. m_hsFinished = TRUE;
  930. }
  931. tRect.bottom = tRect.top + height;
  932. break;
  933. case HM_LEFT:
  934. steps = width/HS_STEPS;
  935. tRect.right += steps;
  936. if(tRect.right >= width)
  937. {
  938. tRect.right = width;
  939. m_hsFinished = TRUE;
  940. }
  941. tRect.left = tRect.right - width;
  942. tRect.top = -m_edgeHeight;
  943. tRect.bottom = GetSystemMetrics(SM_CYSCREEN) - m_taskBarHeight;
  944. break;
  945. case HM_RIGHT:
  946. steps = width/HS_STEPS;
  947. tRect.left -= steps;
  948. if(tRect.left <= (GetSystemMetrics(SM_CXSCREEN) - width))
  949. {
  950. tRect.left = GetSystemMetrics(SM_CXSCREEN) - width;
  951. m_hsFinished = TRUE;
  952. }
  953. tRect.right = tRect.left + width;
  954. tRect.top = -m_edgeHeight;
  955. tRect.bottom = GetSystemMetrics(SM_CYSCREEN) - m_taskBarHeight;
  956. break;
  957. default:
  958. break;
  959. }
  960. SetWindowPos(&wndTopMost,tRect);
  961. }
  962. int CQQDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
  963. {
  964. if (CDialog::OnCreate(lpCreateStruct) == -1)
  965. return -1;
  966. //获得任务栏高度
  967. CWnd* p;
  968. p = this->FindWindow("Shell_TrayWnd",NULL);
  969. if(p != NULL)
  970. {
  971. CRect tRect;
  972. p->GetWindowRect(tRect);
  973. m_taskBarHeight = tRect.Height();
  974. }
  975. //修改风格使得他不在任务栏显示
  976. //ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW);
  977. //去掉关闭按键(如果想画3个按键的话)
  978. //ModifyStyle(WS_SYSMENU,NULL);
  979. //获得边缘高度和宽度
  980. m_edgeHeight = GetSystemMetrics(SM_CYEDGE);
  981. m_edgeWidth = GetSystemMetrics(SM_CXFRAME);
  982. //可以在这里读取上次关闭后保存的大小
  983. return 0;
  984. }
  985. LRESULT CQQDlg::OnNcHitTest(CPoint point)
  986. {
  987. //CString str;
  988. //str.Format("Mouse (%d,%d)",point.x,point.y);
  989. //GetDlgItem(IDC_CURSOR)->SetWindowText(str);
  990. if(m_hideMode != HM_NONE && !m_isSetTimer &&
  991. //防止鼠标超出屏幕右边时向右边收缩造成闪烁
  992. point.x < GetSystemMetrics(SM_CXSCREEN) + INFALTE)
  993. { //鼠标进入时,如果是从收缩状态到显示状态则开启Timer
  994. SetTimer(1,CM_ELAPSE,NULL);
  995. m_isSetTimer = TRUE;
  996. m_hsFinished = FALSE;
  997. m_hiding = FALSE;
  998. SetTimer(2,HS_ELAPSE,NULL); //开启显示过程
  999. }
  1000. return CDialog::OnNcHitTest(point);
  1001. }
  1002. void CQQDlg::OnLButtonDown(UINT nFlags, CPoint point)
  1003. {
  1004. // TODO: 在此添加消息处理程序代码和/或调用默认值
  1005. //SetCapture();
  1006. CDialog::OnLButtonDown(nFlags, point);
  1007. }
  1008. void CQQDlg::OnBnClickedBtnMainmenu()
  1009. {
  1010. // TODO: 在此添加控件通知处理程序代码
  1011. CAboutDlg dlg;
  1012. dlg.DoModal();
  1013. }
  1014. void CQQDlg::OnBnClickedBtnColor()
  1015. {
  1016. // TODO: 在此添加控件通知处理程序代码
  1017. CAboutDlg dlg;
  1018. dlg.DoModal();
  1019. }