www.pudn.com > VC生成漂亮界面.zip > VCFaceDlg.cpp
// VCFaceDlg.cpp : implementation file
//
#include "stdafx.h"
#include "VCFace.h"
#include "VCFaceDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVCFaceDlg dialog
CVCFaceDlg::CVCFaceDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVCFaceDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVCFaceDlg)
// 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 CVCFaceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVCFaceDlg)
DDX_Control(pDX, IDC_BUTTON3, m_StyleButton);
DDX_Control(pDX, IDC_SHADOW, m_Shadow);
DDX_Control(pDX, IDC_LINK, m_Link);
DDX_Control(pDX, IDC_BUTTON2, m_IconButton);
DDX_Control(pDX, IDC_BUTTON1, m_FlatButton);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVCFaceDlg, CDialog)
//{{AFX_MSG_MAP(CVCFaceDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCFaceDlg message handlers
BOOL CVCFaceDlg::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
HCURSOR hHand=AfxGetApp()->LoadCursor(IDC_CURSOR1);
HICON hIcon0=AfxGetApp()->LoadIcon(IDI_ICON0);
HICON hIcon1=AfxGetApp()->LoadIcon(IDI_ICON1);
m_FlatButton.m_hCursor=hHand;
m_IconButton.m_hIcon_Active=hIcon0;
m_IconButton.m_hIcon_Enable=hIcon1;
m_IconButton.m_IconSize=CSize(32,32);
m_IconButton.m_hCursor=hHand;
m_StyleButton.m_hIcon_Active=hIcon0;
m_StyleButton.m_hIcon_Enable=hIcon1;
m_StyleButton.m_IconSize=CSize(32,32);
m_StyleButton.m_hCursor=hHand;
m_Link.m_hCursor=hHand;
LOGFONT logfont;
CFont Font;
GetFont()->GetLogFont(&logfont);
logfont.lfHeight=20;
logfont.lfWidth=10;
logfont.lfWeight=8;
strcpy(logfont.lfFaceName,"华文行楷");
m_Shadow.m_Font.CreateFontIndirect(&logfont);
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 CVCFaceDlg::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 CVCFaceDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CVCFaceDlg::OnButton1()
{
// TODO: Add your control notification handler code here
AfxMessageBox("这是Flat模式按纽");
}
void CVCFaceDlg::OnButton2()
{
// TODO: Add your control notification handler code here
AfxMessageBox("这是Icon模式按纽");
}
void CVCFaceDlg::OnButton3()
{
// TODO: Add your control notification handler code here
AfxMessageBox("这是Icon与Text模式按纽");
}