📄 skyriverdlg.cpp
字号:
// SkyRiverDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SkyRiver.h"
#include "About.h"
#include "SkyRiverDlg.h"
#include "AboutGame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual void OnOK();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSkyRiverDlg dialog
CSkyRiverDlg::CSkyRiverDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSkyRiverDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSkyRiverDlg)
// 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 CSkyRiverDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSkyRiverDlg)
DDX_Control(pDX, IDC_TAB1, m_Tab);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSkyRiverDlg, CDialog)
//{{AFX_MSG_MAP(CSkyRiverDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_ABOUT, OnAbout)
ON_BN_CLICKED(IDC_LOCK, OnLock)
ON_BN_CLICKED(IDC_HELP, OnHelp)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSkyRiverDlg message handlers
BOOL CSkyRiverDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTME, _T("关于我(&I)..."));
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTGAME, _T("游戏攻略(&H)..."));
}
}
// 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
m_hSkyRiver=NULL;
SetButton(this,IDCANCEL ,3,IDI_ICON12,NULL,NULL,_T("退出"), NULL,TRUE);
SetButton(this,IDC_ABOUT,3,IDI_ICON7 ,NULL,NULL,_T("说明书"), NULL,TRUE);
SetButton(this,IDC_LOCK ,3,IDI_ICON2 ,NULL,NULL,_T("锁定游戏"),NULL,TRUE);
m_Tab.InsertItem(0,"杨别");
m_Tab.InsertItem(1,"丽子");
m_Tab.InsertItem(2,"宛儿");
m_Tab.InsertItem(3,"长孙无忌");
m_Tab.InsertItem(4,"张彩");
m_Tab.InsertItem(5,"杨遂");
m_Tab.InsertItem(6,"橘一树");
m_Tab.InsertItem(7,"李沁");
m_Tab.InsertItem(8,"其它");
m_pRole=new CRole;
m_pRole->Create(CRole::IDD,&m_Tab);
m_pRole->ShowWindow(SW_SHOW);
m_pRole->SetWindowPos(&wndTop,1,25,0,0,SWP_NOSIZE);
m_pOther=new COther;
m_pOther->Create(COther::IDD,&m_Tab);
m_pOther->ShowWindow(SW_HIDE);
m_pOther->SetWindowPos(&wndTop,1,25,0,0,SWP_NOSIZE);
OnLock();
return TRUE; // return TRUE unless you set the focus to a control
}
void CSkyRiverDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else if((nID & 0xFFF0) == IDM_ABOUTME)
{
CAbout* aboutDlg=new CAbout;
aboutDlg->Create(CAbout::IDD,NULL);
aboutDlg->ShowWindow(SW_SHOW);
aboutDlg->AboutMe();
}
else if((nID & 0xFFF0) == IDM_ABOUTGAME)
{
CAboutGame* gameDlg=new CAboutGame;
gameDlg->Create(CAboutGame::IDD,NULL);
gameDlg->ShowWindow(SW_SHOW);
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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 CSkyRiverDlg::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 CSkyRiverDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSkyRiverDlg::OnAbout()
{
// TODO: Add your control notification handler code here
CAbout dlg;
dlg.DoModal();
}
void CSkyRiverDlg::OnLock()
{
// TODO: Add your control notification handler code here
HWND hWnd=::FindWindow(NULL,"SkyRiver");
if(hWnd)
{
DWORD pid;
GetWindowThreadProcessId(hWnd,&pid);
m_hSkyRiver=OpenProcess(PROCESS_ALL_ACCESS,false,pid);
m_pRole->SetHProcess(m_hSkyRiver);
m_pOther->SetHProcess(m_hSkyRiver);
int curPos=m_Tab.GetCurSel();
if(curPos>=0&&curPos<8)
{
m_pRole->ShowWindow(SW_SHOW);
m_pOther->ShowWindow(SW_HIDE);
m_pRole->ReadRole(m_Tab.GetCurSel());
}
else if(curPos==8)
{
m_pOther->ShowWindow(SW_SHOW);
m_pRole->ShowWindow(SW_HIDE);
m_pOther->Show();
}
}
else
{
Beep(10,20);
}
}
void CSkyRiverDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
OnLock();
*pResult = 0;
}
void CAboutDlg::OnOK()
{
// TODO: Add extra validation here
CAboutGame* gameDlg=new CAboutGame;
gameDlg->Create(CAboutGame::IDD,NULL);
gameDlg->ShowWindow(SW_SHOW);
CDialog::OnOK();
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SetButton(this,IDOK,3,IDI_ICON10,NULL,NULL,_T("游戏攻略"),NULL,TRUE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -