赞
踩
内容参考于:易道云信息技术研究院VIP课
上一个内容:项目需求与需求拆解-CSDN博客
码云地址(游戏窗口化助手 分支):https://gitee.com/dye_your_fingers/sro_-ex.git
码云版本号:e512d44da1b7e6a8726b1be03b1956c6378e0833
代码下载地址,在 SRO_EX 目录下,文件名为:SRO_Ex-游戏窗口化助手的UI设计.zip
链接:https://pan.baidu.com/s/1W-JpUcGOWbSJmMdmtMzYZg
提取码:q9n5
--来自百度网盘超级会员V4的分享
HOOK引擎,文件名为:黑兔sdk.zip
链接:https://pan.baidu.com/s/1IB-Zs6hi3yU8LC2f-8hIEw
提取码:78h8
--来自百度网盘超级会员V4的分享
以 实现物品使用策略的功能-CSDN博客 它的代码为基础进行修改
新加Dialog:
控件:
静态文本的属性:其余静态文本都是这样
进度条的属性:其余进度条都是这样
给它新加的类:
CUI.cpp文件的修改:修改了 UIShow函数
- // CUI.cpp: 实现文件
- //
-
- #include "pch.h"
- #include "htdMfcDll.h"
- #include "CUI.h"
- #include "afxdialogex.h"
- #include "extern_all.h"
-
-
- // CUI 对话框
-
- IMPLEMENT_DYNAMIC(CUI, CDialogEx)
-
- CUI::CUI(CWnd* pParent /*=nullptr*/)
- : CDialogEx(IDD_MAIN, pParent)
- {
-
- }
-
- CUI::~CUI()
- {
- }
-
- void CUI::DoDataExchange(CDataExchange* pDX)
- {
- CDialogEx::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_TAB1, mTab);
- }
-
- BOOL CUI::OnInitDialog()
- {
- CDialogEx::OnInitDialog();
-
- InstallPage(new CUIWnd_0(), IDD_PAGE_0, L"角色", TRUE);
- InstallPage(new CUIWnd_1(), IDD_PAGE_1, L"物品");
-
- SetBackgroundColor(0xFFFFFFFF);
-
- //PageINJ.Init(wAppPath);
- //PageRAN.SetAppPath(wAppPath);
-
- return TRUE;
- }
-
- bool CUI::InstallPage(CDialogEx* wnd, int IDD_WND, CString&& _Name, BOOL IsShow)
- {
-
- if (CurPage >= MAX_PAGE_MAIN) return false;
- Pages[CurPage] = wnd;
- Pages[CurPage]->Create(IDD_WND, this);
- //Pages[CurPage]->SetParent(this);
- Pages[CurPage]->ShowWindow(IsShow);
-
- CRect rect;
- mTab.GetClientRect(&rect);
- rect.top += 26;
- rect.left = 0;
- rect.bottom -= 5;
- rect.right -= 5;
- Pages[CurPage]->MoveWindow(&rect);
- mTab.InsertItem(CurPage, _Name);
-
- CurPage++;
- return true;
- }
-
- BEGIN_MESSAGE_MAP(CUI, CDialogEx)
- ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CUI::OnTcnSelchangeTab1)
- ON_WM_CLOSE()
- END_MESSAGE_MAP()
-
-
- // CUI 消息处理程序
-
-
- void CUI::OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: 在此添加控件通知处理程序代码
- *pResult = 0;
- int n = mTab.GetCurSel();
- for (int i = 0; i < CurPage; i++)
- {
- Pages[i]->ShowWindow(i == n);
- }
- }
-
- void CUI::UIShow()
- {
- auto hwndClient = ::FindWindow(L"CLIENT", L"SRO_CLIENT");
- // ::SetParent(this->m_hWnd, hwndClient);
- this->ShowWindow(ShowUI = !ShowUI);
- // 把焦点还给游戏
- ::SetFocus(hwndClient);
-
- _ui_helper->ShowWindow(TRUE);
- }
-
-
- void CUI::OnClose()
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- UIShow();
- // CDialogEx::OnClose();
- }
htdMfcDll.cpp文件的修改:修改了 InitInstance函数,新加 _ui_helper变量
- // htdMfcDll.cpp: 定义 DLL 的初始化例程。
- //
-
- #include "pch.h"
- #include "framework.h"
- #include "htdMfcDll.h"
- #include "extern_all.h"
-
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
-
- // #define WNDHOOK
-
- #pragma data_seg("_hdata")
- int client = 0;
- #pragma data_seg()
- #pragma comment(linker, "/SECTION:_hdata,RWS")
-
- BEGIN_MESSAGE_MAP(ChtdMfcDllApp, CWinApp)
- END_MESSAGE_MAP()
-
- CUI* _ui;
- CHelperUI* _ui_helper;
- // ChtdMfcDllApp 构造
-
- ChtdMfcDllApp::ChtdMfcDllApp()
- {
-
- }
-
- ChtdMfcDllApp theApp;
- ChtdMfcDllApp* PtheApp;
-
- HHOOK keyHook;
- LRESULT CALLBACK KeyCallBack(int nCode, WPARAM w, LPARAM l);
-
- BOOL ChtdMfcDllApp::InitInstance()
- {
- CWinApp::InitInstance();
- protect.CheckMult();
- game_ex.InitInterface();// 初始化游戏扩展接口
- client++;
- ui_helper.Create(IDD_MAIN);
- ui_helper_windowed.Create(IDD_HELPER);
- _ui = &ui_helper;
- _ui_helper = &ui_helper_windowed;
- return TRUE;
- }
htdMfcDll.h文件的修改:新加 ui_helper_windowed变量
- // htdMfcDll.h: htdMfcDll DLL 的主标头文件
- //
-
- #pragma once
-
- #ifndef __AFXWIN_H__
- #error "在包含此文件之前包含 'pch.h' 以生成 PCH"
- #endif
-
- #include "resource.h" // 主符号
- #include "CUI.h"
- #include "GameProtect.h"
- #include "GameEx.h"
- #include "GameBase.h"
- #include "CHelperUI.h"
-
- // ChtdMfcDllApp
- // 有关此类实现的信息,请参阅 htdMfcDll.cpp
- //
-
- class ChtdMfcDllApp : public CWinApp
- {
- public:
- ChtdMfcDllApp();
-
- // 重写
- public:
- virtual BOOL InitInstance();
- DECLARE_MESSAGE_MAP()
- protected:
- GameProtect protect;
- GameEx game_ex;
- GameBase game_base;
- CUI ui_helper;
- CHelperUI ui_helper_windowed;
- };
extern_all.h文件的修改:新加_ui_helper变量
- #pragma once
- #include "GameBase.h"
- #include "CUI.h"
- #include "CHelperUI.h"
-
- extern CHelperUI* _ui_helper;
- extern CUI* _ui;
- extern GameBase* _pgamebase;
CHelperUI.cpp文件的内容:
- // CHelperUI.cpp: 实现文件
- //
-
- #include "pch.h"
- #include "CHelperUI.h"
- #include "afxdialogex.h"
-
-
- // CHelperUI 对话框
-
- IMPLEMENT_DYNAMIC(CHelperUI, CDialogEx)
-
- CHelperUI::CHelperUI(CWnd* pParent /*=nullptr*/)
- : CDialogEx(IDD_HELPER, pParent)
- {
-
- }
-
- CHelperUI::~CHelperUI()
- {
- }
-
- BOOL CHelperUI::OnInitDialog()
- {
- CDialogEx::OnInitDialog();
- this->SetBackgroundColor(RGB(255, 255, 255));
- HPBar.SetBkColor(RGB(0 ,0, 0));
- MPBar.SetBkColor(RGB(0 ,0, 0));
- RageBar.SetBkColor(RGB(0 ,0, 0));
- ExBar.SetBkColor(RGB(0 ,0, 0));
-
-
- HPBar.SetBarColor(RGB(255 ,0, 0));
- MPBar.SetBarColor(RGB(0x0, 0x0, 0x99));
- RageBar.SetBarColor(RGB(0x66, 0x0, 0x66));
- ExBar.SetBarColor(RGB(0x00, 0xFF, 0xCC));
- HPBar.SetPos(50);
- MPBar.SetPos(50);
- RageBar.SetPos(50);
- ExBar.SetPos(50);
- return TRUE;
- }
-
- void CHelperUI::DoDataExchange(CDataExchange* pDX)
- {
- CDialogEx::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_PRO_HP, HPBar);
- DDX_Control(pDX, IDC_PRO_MP, MPBar);
- DDX_Control(pDX, IDC_PRO_RAGE, RageBar);
- DDX_Control(pDX, IDC_PRO_RAGE2, ExBar);
- }
-
-
- BEGIN_MESSAGE_MAP(CHelperUI, CDialogEx)
- ON_BN_CLICKED(IDOK, &CHelperUI::OnBnClickedOk)
- END_MESSAGE_MAP()
-
-
- // CHelperUI 消息处理程序
-
-
- void CHelperUI::OnBnClickedOk()
- {
- // TODO: 在此添加控件通知处理程序代码
- CDialogEx::OnOK();
- }
CHelperUI.h文件的内容:
- #pragma once
- #include "afxdialogex.h"
- #include "resource.h"
-
- // CHelperUI 对话框
-
- class CHelperUI : public CDialogEx
- {
- DECLARE_DYNAMIC(CHelperUI)
-
- public:
- CHelperUI(CWnd* pParent = nullptr); // 标准构造函数
- virtual ~CHelperUI();
-
- // 对话框数据
- #ifdef AFX_DESIGN_TIME
- enum { IDD = IDD_HELPER };
- #endif
-
- protected:
- virtual BOOL OnInitDialog();
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
-
- DECLARE_MESSAGE_MAP()
- public:
- afx_msg void OnBnClickedOk();
- // 血量条
- CProgressCtrl HPBar;
- // 魔法条
- CProgressCtrl MPBar;
- // 怒气条
- CProgressCtrl RageBar;
- // 升级经验值条
- CProgressCtrl ExBar;
- };
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。