?? dockingwindow.h
字號:
{
T* pThis=static_cast<T*>(this);
bRes=pThis->PinUp(CDockingSide(dockHdr.dwDockSide),dockHdr.nWidth,bVisualize);
}
}
return bRes;
}
#endif
protected:
BEGIN_MSG_MAP(thisClass)
if(IsDocking())
{
MESSAGE_HANDLER(WM_WINDOWPOSCHANGING,OnWindowPosChanging)
MESSAGE_HANDLER(WM_NCCALCSIZE, OnNcCalcSize)
MESSAGE_HANDLER(WM_NCACTIVATE, OnNcActivate)
MESSAGE_HANDLER(WM_NCHITTEST,OnNcHitTest)
MESSAGE_HANDLER(WM_NCPAINT,OnNcPaint)
MESSAGE_HANDLER(WM_SETTEXT,OnCaptionChange)
MESSAGE_HANDLER(WM_SETICON,OnCaptionChange)
MESSAGE_HANDLER(WM_NCLBUTTONDOWN, OnNcLButtonDown)
MESSAGE_HANDLER(WM_NCLBUTTONUP,OnNcLButtonUp)
MESSAGE_HANDLER(WM_NCLBUTTONDBLCLK,OnNcLButtonDblClk)
#ifdef DF_FOCUS_FEATURES
ATLASSERT(CDockingFocusHandler::This());
CHAIN_MSG_MAP_ALT_MEMBER((*CDockingFocusHandler::This()),0)
#endif
}
MESSAGE_HANDLER(WM_GETMINMAXINFO,OnGetMinMaxInfo)
MESSAGE_HANDLER(WM_SETTINGCHANGE,OnSettingChange)
MESSAGE_HANDLER(WM_SYSCOLORCHANGE,OnSysColorChange)
CHAIN_MSG_MAP(baseClass)
END_MSG_MAP()
LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
{
T* pThis=static_cast<T*>(this);
LRESULT lRes=pThis->DefWindowProc(uMsg,wParam,lParam);
pThis->GetMinMaxInfo(reinterpret_cast<LPMINMAXINFO>(lParam));
return lRes;
}
LRESULT OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if(!IsDocking())
{
// If we're floating, we're a top level window.
// We might be getting this message before the main frame
// (which is also a top-level window).
// The main frame handles this message, and refreshes
// system settings cached in CDWSettings. In case we
// are getting this message before the main frame,
// update these cached settings (so that when we update
// our caption's settings that depend on them,
// its using the latest).
CDWSettings settings;
settings.Update();
// In addition, because we are a top-level window,
// we should be sure to send this message to all our descendants
// in case there are common controls and other windows that
// depend on cached system metrics.
this->SendMessageToDescendants(uMsg, wParam, lParam, TRUE);
}
m_caption.UpdateMetrics();
T* pThis=static_cast<T*>(this);
pThis->SetWindowPos(NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
bHandled = FALSE;
return 1;
}
LRESULT OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if(!IsDocking())
{
// If we're floating, we're a top level window.
// We might be getting this message before the main frame
// (which is also a top-level window).
// The main frame handles this message, and refreshes
// system settings cached in CDWSettings. In case we
// are getting this message before the main frame,
// update these cached settings (so that when we update
// our caption's settings that depend on them,
// its using the latest).
CDWSettings settings;
settings.Update();
// In addition, because we are a top-level window,
// we should be sure to send this message to all our descendants
// in case there are common controls and other windows that
// depend on cached system metrics.
this->SendMessageToDescendants(uMsg, wParam, lParam, TRUE);
}
m_caption.UpdateMetrics();
T* pThis=static_cast<T*>(this);
pThis->SetWindowPos(NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
bHandled = FALSE;
return 1;
}
LRESULT OnWindowPosChanging(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
return NULL;
}
LRESULT OnNcActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
bHandled=IsWindowEnabled();
return TRUE;
}
LRESULT OnNcCalcSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
T* pThis=static_cast<T*>(this);
CRect* pRc=reinterpret_cast<CRect*>(lParam);
CPoint ptTop(pRc->TopLeft());
(*pRc)-=ptTop;
pThis->NcCalcSize(pRc);
(*pRc)+=ptTop;
return NULL;
}
LRESULT OnNcHitTest(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
CPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
T* pThis=static_cast<T*>(this);
CRect rcWnd;
GetWindowRect(&rcWnd);
pt.x-=rcWnd.TopLeft().x;
pt.y-=rcWnd.TopLeft().y;
return pThis->NcHitTest(pt);
}
//OnSetIcon
//OnSetText
LRESULT OnCaptionChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
{
// LockWindowUpdate();
DWORD style = ::GetWindowLong(m_hWnd,GWL_STYLE);
::SetWindowLong(m_hWnd, GWL_STYLE, style&(~WS_CAPTION));
LRESULT lRes=DefWindowProc(uMsg,wParam,lParam);
::SetWindowLong(m_hWnd, GWL_STYLE, style);
T* pThis=static_cast<T*>(this);
pThis->SetWindowPos(NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
// CWindowDC dc(m_hWnd);
// pThis->NcDraw(dc);
// LockWindowUpdate(FALSE);
return lRes;
}
LRESULT OnNcPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CWindowDC dc(m_hWnd);
T* pThis=static_cast<T*>(this);
pThis->NcDraw(dc);
return NULL;
}
LRESULT OnNcLButtonDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
bHandled=m_caption.OnAction(m_hWnd, (unsigned int)wParam);
if(!bHandled && wParam == HTCAPTION)
this->SetFocus();
return !bHandled;
}
LRESULT OnNcLButtonUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
T* pThis=static_cast<T*>(this);
HWND hWndFocus = ::GetFocus();
switch(wParam)
{
case HTCLOSE:
bHandled=pThis->CloseBtnPress();
break;
#ifdef DF_AUTO_HIDE_FEATURES
case HTPIN:
bHandled=pThis->PinBtnPress();
break;
#endif
default:
bHandled=FALSE;
}
if(hWndFocus != ::GetFocus())
{
if(::IsWindow(hWndFocus) && ::IsWindowVisible(hWndFocus))
{
::SetFocus(hWndFocus);
}
else
{
::SetFocus(this->GetTopLevelParent());
}
}
return 0;
}
LRESULT OnNcLButtonDblClk(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
return 0;
}
protected:
CCaption m_caption;
};
template <class T,
class TBase = CWindow,
class TDockingWinTraits = CEmptyTitleDockingWindowTraits>
class ATL_NO_VTABLE CTitleDockingWindowImpl
: public CTitleDockingWindowBaseImpl< T, TBase, TDockingWinTraits >
{
typedef CTitleDockingWindowBaseImpl< T, TBase, TDockingWinTraits > baseClass;
typedef CTitleDockingWindowImpl< T, TBase, TDockingWinTraits > thisClass;
public:
CTitleDockingWindowImpl()
{
::ZeroMemory(&m_pos, sizeof(DFDOCKPOS));
m_pos.hdr.hBar=HNONDOCKBAR;
}
virtual bool Undock()
{
assert(IsDocking());
GetDockingPosition(&m_pos);
return baseClass::Undock();
}
virtual bool Hide()
{
bool bRes=true;
if(IsDocking())
{
bRes=GetDockingPosition(&m_pos);
assert(bRes);
if(bRes)
// bRes=Undock();
bRes=Float(&m_rcUndock,SWP_HIDEWINDOW);
assert(bRes);
}
else
m_pos.hdr.hBar=HNONDOCKBAR;
return (bRes && ShowWindow(SW_HIDE));
}
virtual bool Show()
{
bool bRes=true;
if(m_pos.hdr.hBar!=HNONDOCKBAR)
bRes=SetDockingPosition(&m_pos);
else
ShowWindow(SW_SHOW);
assert(bRes);
return bRes;
}
bool Toggle()
{
bool bRes=(static_cast<T*>(this)->IsWindowVisible()!=FALSE);
if(bRes)
Hide();
else
Show();
return bRes;
}
bool GetDockingWindowPlacement(DFDOCKPOSEX* pHdr) const
{
bool bRes=baseClass::GetDockingWindowPlacement(pHdr);
pHdr->bVisible=static_cast<const T*>(this)->IsWindowVisible();
if((!pHdr->bDocking)
&& (!pHdr->bVisible)
&& (m_pos.hdr.hBar!=HNONDOCKBAR))
::CopyMemory(&pHdr->dockPos,&m_pos,sizeof(DFDOCKPOS));
return bRes;
}
bool SetDockingWindowPlacement(DFDOCKPOSEX* pHdr)
{
bool bRes=true;
pHdr->dockPos.hdr.hWnd=m_hWnd;
::CopyMemory(&m_pos,&(pHdr->dockPos),sizeof(DFDOCKPOS));
if(pHdr->bVisible)
bRes=baseClass::SetDockingWindowPlacement(pHdr);
else
{
if(IsDocking())
Undock();
::CopyRect(&m_rcUndock,&pHdr->rect);
bRes=(SetWindowPos(NULL,&m_rcUndock,
SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE )!=FALSE);
}
#ifdef DF_AUTO_HIDE_FEATURES
// Update from Peter Carlson.
// A fix for the pin restore problem.
CDockingSide side(pHdr->dockPos.dwDockSide);
if (side.IsPinned())
PinUp(side, (side.IsHorizontal() ? pHdr->dockPos.nHeight : pHdr->dockPos.nWidth));
//
#endif
return bRes;
}
bool CanBeClosed(unsigned long /*param*/)
{
HWND hWndFocus = ::GetFocus();
this->Hide();
if(hWndFocus != ::GetFocus())
{
if(::IsWindow(hWndFocus) && ::IsWindowVisible(hWndFocus))
{
::SetFocus(hWndFocus);
}
else
{
::SetFocus(this->GetTopLevelParent());
}
}
return false;
}
BEGIN_MSG_MAP(thisClass)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_NCLBUTTONDBLCLK, OnNcLButtonDblClk)
CHAIN_MSG_MAP(baseClass)
END_MSG_MAP()
LRESULT OnClose(UINT /*uMsg*/, WPARAM wParam, LPARAM/* lParam*/, BOOL& bHandled)
{
bHandled=!(static_cast<T*>(this)->CanBeClosed((unsigned long)wParam));
return 0;
}
LRESULT OnNcLButtonDblClk(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
if(IsIconic() || IsZoomed())
{
// Docking a minimised window is a bad idea!
// Let Windows restore.
bHandled = FALSE;
return 0;
}
if(wParam==HTCAPTION)
{
if(IsDocking())
Float();
else
{
if(m_pos.hdr.hBar!=HNONDOCKBAR)
SetDockingPosition(&m_pos);
}
}
return 0;
}
protected:
DFDOCKPOS m_pos;
};
#define COMMAND_TOGGLE_MEMBER_HANDLER(id, member) \
if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \
{ \
member.Toggle(); \
}
//please don't use CStateKeeper class anymore!
//this class is obsolete and provided only for compatibility with previous versions.
//the CTitleDockingWindowImpl class provide all functionality of CStateKeeper
template<class T>
struct CStateKeeper : public T
{
};
//please don't use CTitleExDockingWindowImpl class anymore!
//this class is obsolete and provided only for compatibility with previous versions.
//the CTitleDockingWindowImpl class provide all functionality of CTitleExDockingWindowImpl
template <class T,
class TBase = CWindow,
class TDockingWinTraits = CEmptyTitleDockingWindowTraits>
struct ATL_NO_VTABLE CTitleExDockingWindowImpl : CTitleDockingWindowImpl< T, TBase, TDockingWinTraits >
{
};
}//namespace dockwins
#endif // __WTL_DW__DOCKINGWINDOW_H__
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -