forked from metin2/client
233 lines
4.3 KiB
C++
233 lines
4.3 KiB
C++
|
// PageCtrl.cpp : implementation file
|
|||
|
//
|
|||
|
// <20><><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>ڿ<EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD>۱<EFBFBD><DBB1><EFBFBD> (c) 2001 <20>ſ<EFBFBD><C5BF><EFBFBD> (grace77@hanimail.com)
|
|||
|
//
|
|||
|
// <20><> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǹ<EFBFBD><C7B8><EFBFBD> <20><><EFBFBD>۱<EFBFBD><DBB1>ڿ<EFBFBD><DABF><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
|||
|
// <20><><EFBFBD>۱<EFBFBD><DBB1><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><>ġ/<2F><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
|||
|
|
|||
|
#include "stdafx.h"
|
|||
|
#include "PageCtrl.h"
|
|||
|
|
|||
|
#ifdef _DEBUG
|
|||
|
#define new DEBUG_NEW
|
|||
|
#undef THIS_FILE
|
|||
|
static char THIS_FILE[] = __FILE__;
|
|||
|
#endif
|
|||
|
|
|||
|
/////////////////////////////////////////////////////////////////////////////
|
|||
|
// CPageCtrl dialog
|
|||
|
|
|||
|
|
|||
|
CPageCtrl::CPageCtrl(UINT nIDTemplate, CWnd* pParent /*=NULL*/)
|
|||
|
: CDialog(nIDTemplate, pParent)
|
|||
|
{
|
|||
|
//{{AFX_DATA_INIT(CPageCtrl)
|
|||
|
// NOTE: the ClassWizard will add member initialization here
|
|||
|
//}}AFX_DATA_INIT
|
|||
|
|
|||
|
m_nScrollPos = 0;
|
|||
|
}
|
|||
|
|
|||
|
void CPageCtrl::DoDataExchange(CDataExchange* pDX)
|
|||
|
{
|
|||
|
CDialog::DoDataExchange(pDX);
|
|||
|
//{{AFX_DATA_MAP(CPageCtrl)
|
|||
|
// NOTE: the ClassWizard will add DDX and DDV calls here
|
|||
|
//}}AFX_DATA_MAP
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
BEGIN_MESSAGE_MAP(CPageCtrl, CDialog)
|
|||
|
//{{AFX_MSG_MAP(CPageCtrl)
|
|||
|
ON_WM_LBUTTONDOWN()
|
|||
|
ON_WM_LBUTTONUP()
|
|||
|
ON_WM_MOUSEMOVE()
|
|||
|
ON_WM_MOUSEWHEEL()
|
|||
|
ON_WM_SETCURSOR()
|
|||
|
//}}AFX_MSG_MAP
|
|||
|
END_MESSAGE_MAP()
|
|||
|
|
|||
|
/////////////////////////////////////////////////////////////////////////////
|
|||
|
// CPageCtrl message handlers
|
|||
|
|
|||
|
void CPageCtrl::CalcLayout()
|
|||
|
{
|
|||
|
CRect drc, prc;
|
|||
|
GetClientRect(&drc);
|
|||
|
GetParent()->GetClientRect(&prc);
|
|||
|
|
|||
|
if (prc.Width() >= drc.Width())
|
|||
|
{
|
|||
|
int gap = (prc.Width() - drc.Width())/2;
|
|||
|
CRect rc = drc;
|
|||
|
rc.left += gap;
|
|||
|
rc.right += gap;
|
|||
|
MoveWindow(&rc);
|
|||
|
}
|
|||
|
|
|||
|
// recalc scroll window
|
|||
|
int dy = 0;
|
|||
|
|
|||
|
if (m_nScrollPos + dy < 0)
|
|||
|
{
|
|||
|
|
|||
|
int max_pos = 0;
|
|||
|
if (drc.Height() > prc.Height()) max_pos = drc.Height() - prc.Height();
|
|||
|
|
|||
|
if (m_nScrollPos + dy > -max_pos)
|
|||
|
{
|
|||
|
ScrollWindow(0, dy);
|
|||
|
m_nScrollPos += dy;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ScrollWindow(0, -max_pos - m_nScrollPos);
|
|||
|
m_nScrollPos = -max_pos;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ScrollWindow(0, -m_nScrollPos);
|
|||
|
m_nScrollPos = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void CPageCtrl::OnLButtonDown(UINT nFlags, CPoint point)
|
|||
|
{
|
|||
|
// TODO: Add your message handler code here and/or call default
|
|||
|
SetFocus();
|
|||
|
|
|||
|
SetCapture();
|
|||
|
m_pt = point;
|
|||
|
|
|||
|
CDialog::OnLButtonDown(nFlags, point);
|
|||
|
}
|
|||
|
|
|||
|
void CPageCtrl::OnMouseMove(UINT nFlags, CPoint point)
|
|||
|
{
|
|||
|
// TODO: Add your message handler code here and/or call default
|
|||
|
if (nFlags == MK_LBUTTON)
|
|||
|
{
|
|||
|
int dy = point.y - m_pt.y;
|
|||
|
|
|||
|
if (m_nScrollPos + dy < 0)
|
|||
|
{
|
|||
|
CRect drc, prc;
|
|||
|
GetClientRect(&drc);
|
|||
|
GetParent()->GetClientRect(&prc);
|
|||
|
|
|||
|
int max_pos = 0;
|
|||
|
if (drc.Height() > prc.Height())
|
|||
|
max_pos = drc.Height() - prc.Height();
|
|||
|
|
|||
|
if (m_nScrollPos + dy > -max_pos)
|
|||
|
{
|
|||
|
ScrollWindow(0, dy);
|
|||
|
m_nScrollPos += dy;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ScrollWindow(0, -max_pos - m_nScrollPos);
|
|||
|
m_nScrollPos = -max_pos;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ScrollWindow(0, -m_nScrollPos);
|
|||
|
m_nScrollPos = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
m_pt = point;
|
|||
|
|
|||
|
CDialog::OnMouseMove(nFlags, point);
|
|||
|
}
|
|||
|
|
|||
|
void CPageCtrl::OnLButtonUp(UINT nFlags, CPoint point)
|
|||
|
{
|
|||
|
// TODO: Add your message handler code here and/or call default
|
|||
|
ReleaseCapture();
|
|||
|
|
|||
|
CDialog::OnLButtonUp(nFlags, point);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void CPageCtrl::OnOK()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void CPageCtrl::OnCancel()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
BOOL CPageCtrl::EnableWindow(BOOL bEnable)
|
|||
|
{
|
|||
|
CWnd *pWnd = GetWindow(GW_CHILD);
|
|||
|
while (pWnd != NULL)
|
|||
|
{
|
|||
|
pWnd->EnableWindow(bEnable);
|
|||
|
pWnd = pWnd->GetNextWindow();
|
|||
|
}
|
|||
|
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
BOOL CPageCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
|
|||
|
{
|
|||
|
// TODO: Add your message handler code here and/or call default
|
|||
|
int dy = zDelta/6;
|
|||
|
|
|||
|
if (m_nScrollPos + dy < 0)
|
|||
|
{
|
|||
|
CRect drc, prc;
|
|||
|
GetClientRect(&drc);
|
|||
|
GetParent()->GetClientRect(&prc);
|
|||
|
|
|||
|
int max_pos = 0;
|
|||
|
if (drc.Height() > prc.Height()) max_pos = drc.Height() - prc.Height();
|
|||
|
|
|||
|
if (m_nScrollPos + dy > -max_pos)
|
|||
|
{
|
|||
|
ScrollWindow(0, dy);
|
|||
|
m_nScrollPos += dy;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ScrollWindow(0, -max_pos - m_nScrollPos);
|
|||
|
m_nScrollPos = -max_pos;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ScrollWindow(0, -m_nScrollPos);
|
|||
|
m_nScrollPos = 0;
|
|||
|
}
|
|||
|
|
|||
|
return CDialog::OnMouseWheel(nFlags, zDelta, pt);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
BOOL CPageCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|||
|
{
|
|||
|
// TODO: Add your message handler code here and/or call default
|
|||
|
CRect drc, prc;
|
|||
|
GetClientRect(&drc);
|
|||
|
GetParent()->GetClientRect(&prc);
|
|||
|
|
|||
|
if (nHitTest == HTCLIENT)
|
|||
|
if (drc.Height() > prc.Height())
|
|||
|
{
|
|||
|
SetCursor(AfxGetApp()->LoadCursor(IDC_VIEWMOVE));
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
return CDialog::OnSetCursor(pWnd, nHitTest, message);
|
|||
|
}
|
|||
|
|
|||
|
void CPageCtrl::UpdateUI()
|
|||
|
{
|
|||
|
|
|||
|
}
|