📄 ymselector.h
字号:
// YMSelector.h
// Control to select year and month
// Designed and developed by Shekar Narayanan
// ShekarNarayanan@Hotmail.com
//
#if !defined(AFX_YMSELECTOR_H__12C342F1_008C_11D2_AECD_0004AC31E75C__INCLUDED_)
#define AFX_YMSELECTOR_H__12C342F1_008C_11D2_AECD_0004AC31E75C__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// YMSelector.h : header file
//
#define START_YEAR 1900
#define END_YEAR 2050
#define YM_SELECTED WM_USER + 50
#define YM_ABORTED WM_USER + 51
/////////////////////////////////////////////////////////////////////////////
// CYMPopUp window
// Used by the YMSelector control
class CYMPopUp : public CWnd
{
// Construction
public:
CYMPopUp(CPoint p, CWnd* pParent, int nYear = -1, int nMonth = -1);
// Attributes
public:
// Operations
public:
BOOL Create(CPoint p, CWnd* pParent);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CYMPopUp)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CYMPopUp();
// Generated message map functions
protected:
BOOL m_inPlus;
BOOL m_inMinus;
int m_nYear;
int m_nMonth;
CBrush m_bkBrush;
CWnd* m_pParent;
CRect m_rCells[12];
CRect m_rMinus;
CRect m_rPlus;
CRect m_rYear;
//{{AFX_MSG(CYMPopUp)
afx_msg void OnNcDestroy();
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg BOOL OnEraseBkgnd(CDC* pDC) ;
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CYMSelector window
class CYMSelector : public CButton
{
// Construction
public:
CYMSelector();
// Attributes
public:
void SetYear(int y);
void SetMonth(int m);
int GetYear();
int GetMonth();
LPCTSTR GetMonthString();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CYMSelector)
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CYMSelector();
// Generated message map functions
protected:
int m_nMonth;
int m_nYear;
//{{AFX_MSG(CYMSelector)
afx_msg void OnClicked();
//}}AFX_MSG
afx_msg LONG YMSelected(WPARAM wParam = 0, LPARAM lParam = 0);
afx_msg LONG YMAborted (WPARAM wParam = 0, LPARAM lParam = 0);
DECLARE_MESSAGE_MAP()
};
// MemDC.h : header file
//
//////////////////////////////////////////////////
// CMemDC - memory DC
//
// Author: Keith Rule
// Email: keithr@europa.com
// Copyright 1996-1997, Keith Rule
//
// You may freely use or modify this code provided this
// Copyright is included in all derived versions.
//
// History - 10/3/97 Fixed scrolling bug.
// Added print support.
// 25 feb 98 - fixed minor assertion bug
//
// This class implements a memory Device Context
class CMemDC : public CDC
{
public:
// constructor sets up the memory DC
CMemDC(CDC* pDC) : CDC()
{
ASSERT(pDC != NULL);
m_pDC = pDC;
m_pOldBitmap = NULL;
m_bMemDC = !pDC->IsPrinting();
if (m_bMemDC) // Create a Memory DC
{
pDC->GetClipBox(&m_rect);
CreateCompatibleDC(pDC);
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_pOldBitmap = SelectObject(&m_bitmap);
SetWindowOrg(m_rect.left, m_rect.top);
}
else // Make a copy of the relevent parts of the current DC for printing
{
m_bPrinting = pDC->m_bPrinting;
m_hDC = pDC->m_hDC;
m_hAttribDC = pDC->m_hAttribDC;
}
}
// Destructor copies the contents of the mem DC to the original DC
~CMemDC()
{
if (m_bMemDC)
{
// Copy the offscreen bitmap onto the screen.
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
this, m_rect.left, m_rect.top, SRCCOPY);
//Swap back the original bitmap.
SelectObject(m_pOldBitmap);
} else {
// All we need to do is replace the DC with an illegal value,
// this keeps us from accidently deleting the handles associated with
// the CDC that was passed to the constructor.
m_hDC = m_hAttribDC = NULL;
}
}
// Allow usage as a pointer
CMemDC* operator->() {return this;}
// Allow usage as a pointer
operator CMemDC*() {return this;}
private:
CBitmap m_bitmap; // Offscreen bitmap
CBitmap* m_pOldBitmap; // bitmap originally found in CMemDC
CDC* m_pDC; // Saves CDC passed in constructor
CRect m_rect; // Rectangle of drawing area.
BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_YMSELECTOR_H__12C342F1_008C_11D2_AECD_0004AC31E75C__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -