//应用
// CoolClockDlg.h : header file
//
#if !defined(AFX_COOLCLOCKDLG_H__E6592336_D273_41DE_9520_CD85332A0F96__INCLUDED_)
#define AFX_COOLCLOCKDLG_H__E6592336_D273_41DE_9520_CD85332A0F96__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ColockStatic.h"
/////////////////////////////////////////////////////////////////////////////
// CCoolClockDlg dialog
class CCoolClockDlg : public CDialog
{
// Construction
public:
CCoolClockDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCoolClockDlg)
enum { IDD = IDD_COOLCLOCK_DIALOG };
CColockStatic m_ClockStatic;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCoolClockDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CCoolClockDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COOLCLOCKDLG_H__E6592336_D273_41DE_9520_CD85332A0F96__INCLUDED_)
// CoolClockDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CoolClock.h"
#include "CoolClockDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCoolClockDlg dialog
CCoolClockDlg::CCoolClockDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCoolClockDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCoolClockDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCoolClockDlg:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
//{{AFX_DATA_MAP(CCoolClockDlg)
DDX_Control(pDX, IDC_COOL_CLOCK, m_ClockStatic);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCoolClockDlg, CDialog)
//{{AFX_MSG_MAP(CCoolClockDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCoolClockDlg message handlers
BOOL CCoolClockDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCoolClockDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCoolClockDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCoolClockDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rcClient;
GetClientRect(&rcClient);
if(m_ClockStatic.m_hWnd)
{
m_ClockStatic.MoveWindow(&rcClient, TRUE);
}
} |