📄 fodropcolorpalettewnd.cpp
字号:
// Copyright UCanCode Software Technology Inc, All Rights Reserved
// You can contact us.
// Support@UCanCode.net
// http://www.ucancode.net
/********************************************************************/
// FODropColorPaletteWnd.cpp: implementation of the CFODropColorPaletteWnd class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FODropColorPaletteWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFODropColorPaletteWnd
CFODropColorPaletteWnd::CFODropColorPaletteWnd()
{
m_pColorControl = NULL;
pNotifyWnd = NULL;
}
CFODropColorPaletteWnd::~CFODropColorPaletteWnd()
{
if(m_pColorControl != NULL)
delete m_pColorControl;
}
BEGIN_MESSAGE_MAP(CFODropColorPaletteWnd, CWnd)
//{{AFX_MSG_MAP(CFODropColorPaletteWnd)
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDBLCLK()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MBUTTONDBLCLK()
ON_WM_MBUTTONDOWN()
ON_WM_MBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_CHAR()
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
ON_WM_CANCELMODE()
ON_WM_KEYDOWN()
ON_WM_SIZE()
ON_WM_SYSCOLORCHANGE()
ON_WM_GETDLGCODE()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_FO_SELECTCOLOROK, OnSelectDayOK)
ON_MESSAGE(WM_FO_SELECTCOLORCANCEL, OnSelectDayCancel)
ON_MESSAGE(WM_FO_SELECTCOLORCUSTOM, OnSelectCustom)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFODropColorPaletteWnd message handlers
BOOL CFODropColorPaletteWnd::Create(DWORD dwStyle,CRect rcPos, CWnd* pParent,UINT nID,COLORREF crColor,BOOL bPopup)
{
LPVOID lp = (LPVOID)NULL;
if(!CreateEx(0,
AfxRegisterWndClass(CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW)),
_T("CFODropColorPaletteWnd"),
dwStyle,
rcPos.left,
rcPos.top,
rcPos.Width(),
rcPos.Height(),
pParent->GetSafeHwnd(),
(HMENU) nID,
lp))
{
// Not a lot we can do.
TRACE0("Failed to create CFODropColorPaletteWnd\n");
return FALSE;
}
pNotifyWnd = pParent;
m_pColorControl = new CFODropColorPaletteControl;
CRect rc;
GetClientRect(&rc);
m_pColorControl->Create(this,crColor,rc,bPopup);
UpdateWindow();
return TRUE;
}
BOOL CFODropColorPaletteWnd::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
pDC;
return TRUE;
}
void CFODropColorPaletteWnd::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetFocus();
m_pColorControl->OnLButtonDblClk(nFlags,point);
CWnd::OnLButtonDblClk(nFlags, point);
}
void CFODropColorPaletteWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCapture ();
SetFocus();
OnMouseMove (nFlags, point);
}
void CFODropColorPaletteWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (GetCapture() == this)
::ReleaseCapture();
m_pColorControl->OnLButtonUp(nFlags,point);
CWnd::OnLButtonUp(nFlags, point);
}
void CFODropColorPaletteWnd::OnMButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetFocus();
CWnd::OnMButtonDblClk(nFlags, point);
}
void CFODropColorPaletteWnd::OnMButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetFocus();
CWnd::OnMButtonDown(nFlags, point);
}
void CFODropColorPaletteWnd::OnMButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetFocus();
CWnd::OnMButtonUp(nFlags, point);
}
void CFODropColorPaletteWnd::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (GetCapture () != this)
{
return;
}
m_pColorControl->OnMouseMove(nFlags,point);
// CWnd::OnMouseMove(nFlags, point);
}
void CFODropColorPaletteWnd::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
m_pColorControl->OnChar(nChar,nRepCnt,nFlags);
CWnd::OnChar(nChar, nRepCnt, nFlags);
}
void CFODropColorPaletteWnd::OnDestroy()
{
CWnd::OnDestroy();
// TODO: Add your message handler code here
}
void CFODropColorPaletteWnd::OnPaint()
{
CPaintDC dcPaint(this); // device context for painting
CRect rectClient;
GetClientRect(rectClient);
CDC dc;
dc.CreateCompatibleDC(&dcPaint);
CBitmap bmpMem;
bmpMem.CreateCompatibleBitmap(&dcPaint, rectClient.Width(), rectClient.Height());
CBitmap* pBmpOld = dc.SelectObject(&bmpMem);
m_pColorControl->OnDraw(&dc);
dcPaint.BitBlt(rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), &dc, 0, 0, SRCCOPY);
dc.SelectObject(pBmpOld);
}
void CFODropColorPaletteWnd::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_pColorControl->OnRButtonDown(nFlags,point);
CWnd::OnRButtonDown(nFlags, point);
}
void CFODropColorPaletteWnd::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CWnd::OnRButtonUp(nFlags, point);
}
void CFODropColorPaletteWnd::OnCancelMode()
{
CWnd::OnCancelMode();
m_pColorControl->OnCancelMode();
}
void CFODropColorPaletteWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
m_pColorControl->OnKeyDown(nChar,nRepCnt,nFlags);
CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}
BOOL CFODropColorPaletteWnd::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
return CWnd::PreCreateWindow(cs);
}
void CFODropColorPaletteWnd::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CWnd::PreSubclassWindow();
}
void CFODropColorPaletteWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
CRect rc;
GetClientRect(&rc);
// TODO: Add your message handler code here
if(m_pColorControl != NULL)
{
m_pColorControl->SetRect(&rc);
m_pColorControl->UpdateAll();
}
}
LONG CFODropColorPaletteWnd::OnSelectDayOK(UINT wParam, LONG lParam)
{
// We receive this on a color change from one of the well buttons
// or one of the embedded color wells.
pNotifyWnd->PostMessage( WM_FO_SELECTCOLOROK, wParam, lParam );
if(m_pColorControl->IsPopupStyle())
{
ShowWindow(SW_HIDE);
}
return 0L;
}
LONG CFODropColorPaletteWnd::OnSelectDayCancel(UINT wParam, LONG lParam)
{
// We receive this on a color change from one of the well buttons
// or one of the embedded color wells.
pNotifyWnd->PostMessage( WM_FO_SELECTCOLORCANCEL, wParam, lParam );
if(m_pColorControl->IsPopupStyle())
{
ShowWindow(SW_HIDE);
}
return 0L;
}
LONG CFODropColorPaletteWnd::OnSelectCustom(UINT wParam, LONG lParam)
{
// We receive this on a color change from one of the well buttons
// or one of the embedded color wells.
pNotifyWnd->PostMessage( WM_FO_SELECTCOLORCUSTOM, wParam, lParam );
if(m_pColorControl->IsPopupStyle())
{
ShowWindow(SW_HIDE);
}
return 0L;
}
void CFODropColorPaletteWnd::OnSysColorChange()
{
gfxData.OnSysColorChange();
Invalidate ();
}
UINT CFODropColorPaletteWnd::OnGetDlgCode()
{
// TODO: Add your message handler code here and/or call default
ASSERT_VALID(this);
UINT nDlgCode = DLGC_WANTARROWS | DLGC_WANTCHARS;
nDlgCode |= DLGC_WANTTAB;
return nDlgCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -