BaseDialog.cpp ( 文件浏览 )
- keepall 发布于 2016-08-23 13:24
- 浏览次数:349
- 下载次数: 1
- 下载需 20 积分
-
- 侵权举报
#include "StdAfx.h" #include "BaseDialog.h" // Download by http://www.codefans.net #include <memory> void BaseDialog::Notify(TNotifyUI& msg) { if ( msg.sType == _T("click")) { if( msg.pSender == static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn"))) ) SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); if( msg.pSender == static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn"))) ) PostQuitMessage(0); if( msg.pSender == static_cast<CButtonUI*>(m_pm.FindControl(_T("maxbtn"))) ) ::IsZoomed(*this) ? SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0) : SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); } } LRESULT BaseDialog::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { static std::auto_ptr<MessageMap> customMessageMap(InitMessageMap()); BOOL bHandled = TRUE; LRESULT lRes = 0; if ( customMessageMap->find(uMsg) != customMessageMap->end() ) { CustomMsgHandler handler = (*customMessageMap)[uMsg]; lRes = (this->*handler)(wParam, lParam, bHandled); if ( bHandled ) return lRes; } if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes; return CWindowWnd::HandleMessage(uMsg, wParam, lParam); } BaseDialog::MessageMap* BaseDialog::InitMessageMap() { MessageMap* map = new MessageMap; (*map)[WM_CREATE] = &BaseDialog::OnCreate; (*map)[WM_DESTROY] = &BaseDialog::OnDestory; (*map)[WM_ERASEBKGND] = &BaseDialog::OnErasebkgnd; (*map)[WM_SIZE] = &BaseDialog::OnSize; (*map)[WM_NCPAINT] = &BaseDialog::OnNcPaint; (*map)[WM_NCACTIVATE] = &BaseDialog::OnNcActive; (*map)[WM_NCCALCSIZE] = &BaseDialog::OnNcCalSize; (*map)[WM_NCHITTEST] = &BaseDialog::OnNcHitTest; (*map)[WM_SYSCOMMAND] = &BaseDialog::OnSysCommand; (*map)[WM_GETMINMAXINFO] = &BaseDialog::OnGetMinMaxInfo; return map; } HRESULT BaseDialog::OnCreate( WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); styleValue &= ~WS_CAPTION; ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); m_pm.Init(m_hWnd); CDialogBuilder builder; CControlUI* pRoot = builder.Create(_T("main_dlg.xml"), (UINT)0, NULL, &m_pm); m_pm.AttachDialog(pRoot); m_pm.AddNotifier(this); return 0; } HRESULT BaseDialog::OnDestory( WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { ::PostQuitMessage(0L); return 0; } HRESULT BaseDialog::OnErasebkgnd( WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { return 1; } HRESULT BaseDialog::OnSize( WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { SIZE szRoundCorner = m_pm.GetRoundCorner(); if( !::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0) ) { CRect rcWnd; ::GetWindowRect(*this, &rcWnd); rcWnd.Offset(-rcWnd.left, -rcWnd.top); rcWnd.right++; rcWnd.bottom++; HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy); ::SetWindowRgn(*this, hRgn, TRUE); ::DeleteObject(hRgn)[!==More==!]
...
展开> <收缩
Sponsored links
源码文件列表
温馨提示: 点击源码文件名可预览文件内容哦 ^_^ Sponsored links