#include
"stdafx.h"
#include "Fle.h"
#include "FleDlg.h"
#include "openwebpage.h" //
openwebpage.h .cpp -
- ,
200
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define
bi_x 0 //
4
#define bi_y 0 //
//
- < > <>
#define OthesGamesUrl L"\\WebLinks\\index.htm"
#define BuyGameUrl L"\\WebLinks\\buy_fle.htm"
// CFle2Dlg dialog
CFle2Dlg::CFleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFleDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
pBigImage = NULL; //
CImage
pPlayImage = NULL; //
pBuyImage = NULL;
pOthesImage = NULL;
bPlayBtnUp = false; //
bBuyBtnUp = false; //
false
bOthesBtnUp = false;
}
CFle2Dlg::~CFleDlg()
{
delete pBigImage; //
CFleDlg
delete pPlayImage;
delete pBuyImage;
delete pOthesImage;
}
void
CFle2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CFleDlg,
CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
// ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
END_MESSAGE_MAP()
// CFle2Dlg message handlers
BOOL
CFle2Dlg::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
InitShell();
//
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
CFle2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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
{
CPaintDC dc(this); // device context for painting
//
pBigImage->Draw(dc, bi_x, bi_y);
pPlayImage->Draw(dc, m_rcPlayImage.left, m_rcPlayImage.top);
pBuyImage->Draw(dc, m_rcBuyImage.left, m_rcBuyImage.top);
pOthesImage->Draw(dc, m_rcOthesImage.left, m_rcOthesImage.top);
CDialog::OnPaint();
}
}
//
The system calls this function to obtain the cursor to display while the
user drags
// the minimized window.
HCURSOR CFleDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
//
,
CImage .
-
void
CFle2Dlg::InitShell()
{
SetCurrentDirectory(AppRootDir);
pBigImage = new CImage();
pBigImage->Load(L"Media\\shell_window\\fle.jpg");
pPlayImage = new CImage();
pPlayImage->Load(L"Media\\shell_window\\fle_play.jpg");
pBuyImage = new CImage();
pBuyImage->Load(L"Media\\shell_window\\fle_buy.jpg");
pOthesImage = new CImage();
pOthesImage->Load(L"Media\\shell_window\\fle_other_games.jpg");
GetClientRect(&m_rcClientBounds); //
int y = m_rcClientBounds.bottom - pPlayImage->GetHeight(); //
y <>
int x = 0;//
x
m_rcPlayImage.left = x;
m_rcPlayImage.top = y;
m_rcPlayImage.right = x + pPlayImage->GetWidth();
m_rcPlayImage.bottom = y + pPlayImage->GetHeight();
x = x + pPlayImage->GetWidth(); //
x <>
m_rcBuyImage.left = x;
m_rcBuyImage.top = y;
m_rcBuyImage.right = x + pBuyImage->GetWidth();
m_rcBuyImage.bottom = y + pBuyImage->GetHeight();
x = x + pPlayImage->GetWidth(); //
x < >
m_rcOthesImage.left = x;
m_rcOthesImage.top = y;
m_rcOthesImage.right = x + pOthesImage->GetWidth();
m_rcOthesImage.bottom = y + pOthesImage->GetHeight();
}
//
aBtnArea
bool CFle2Dlg::TargetBtnArea(CPoint* CursorPos,
RECT* aBtnArea)
{
if ( CursorPos->x >= aBtnArea->left &&
CursorPos->x <= aBtnArea->right &&
CursorPos->y >= aBtnArea->top &&
CursorPos->y <= aBtnArea->bottom )
return true;
else
return false;
}
//
-
- -
void
CFle2Dlg::OnLButtonUp(UINT nFlags, CPoint point)
{
CPoint pt = point;
bPlayBtnUp = TargetBtnArea(&pt, &m_rcPlayImage);
bBuyBtnUp = TargetBtnArea(&pt, &m_rcBuyImage);
bOthesBtnUp = TargetBtnArea(&pt, &m_rcOthesImage);
if ( bPlayBtnUp | bBuyBtnUp | bOthesBtnUp )
{
if ( bBuyBtnUp )
OpenSite(m_hWnd, BuyGameUrl);
if ( bOthesBtnUp )
OpenSite(m_hWnd, OthesGamesUrl);
if ( bPlayBtnUp )
{
EndDialog(IDOK);
StartD3DApp();
}
}
CDialog::OnLButtonUp(nFlags,
point);
}
|