// SlideDlg.cpp : implementation file
// Download by http://www.codefans.net
#include "stdafx.h"
#include "Slide.h"
#include "SlideDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSlideDlg dialog
CSlideDlg::CSlideDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSlideDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSlideDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_nCurrPage = 0;
memset( m_arhwndPage, 0, sizeof(HWND)*3 );
}
void CSlideDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSlideDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSlideDlg, CDialog)
//{{AFX_MSG_MAP(CSlideDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_PREV, OnPrev)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSlideDlg message handlers
BOOL CSlideDlg::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
CRect rcBaseFrm;
GetDlgItem( IDC_BASE_FRM )->GetWindowRect( &rcBaseFrm );
d0.Create( IDD_FORMVIEW_0, this );
m_arhwndPage[0] = d0.GetSafeHwnd();
d1.Create( IDD_FORMVIEW_1, this );
m_arhwndPage[1] = d1.GetSafeHwnd();
d2.Create( IDD_FORMVIEW_2, this );
m_arhwndPage[2] = d2.GetSafeHwnd();
ScreenToClient( &rcBaseFrm );
for(int i=0;i<3;i++)
{
::MoveWindow( m_arhwndPage[ i ],
rcBaseFrm.left+2, rcBaseFrm.top+2, rcBaseFrm.Width()-4, rcBaseFrm.Height()-4,
0 );
}
::ShowWindow( m_arhwndPage[0], SW_SHOW );
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 CSlideDlg::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 CSlideDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSlideDlg::OnPrev()
{
if( m_nCurrPage <= 0 )
MessageBeep(0xffffffff);
else
{
m_nCurrPage--;
DWORD flag = AW_SLIDE | AW_HOR_NEGATIVE;
BOOL b =::AnimateWindow(
m_arhwndPage[ m_nCurrPage ],
200,
flag
);
::ShowWindow( m_arhwndPage[ m_nCurrPage+1 ], SW_HIDE );
}
}
void CSlideDlg::OnNext()
{
if( m_nCurrPage >= 2 )
MessageBeep(0xffffffff);
else
{
m_nCurrPage++;
DWORD flag = AW_SLIDE | AW_HOR_POSITIVE;
BOOL b =::AnimateWindow(
m_arhwndPage[ m_nCurrPage ],
200,
flag
);
::ShowWindow( m_arhwndPage[ m_nCurrPage-1 ], SW_HIDE );
}
}
void CSlideDlg::OnDestroy()
{
CDialog::OnDestroy();
//其实到这了,已经没啥必要
d0.DestroyWindow();
d1.DestroyWindow();
d2.DestroyWindow();
}