Dlg3.cpp
资源名称:WarH_2.10.rar [点击查看]
上传用户:tree100901
上传日期:2016-07-12
资源大小:182k
文件大小:4k
源码类别:
外挂编程
开发平台:
Visual C++
- // Dlg3.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "WarH.h"
- #include "Register.h"
- #include "Dlg3.h"
- // CDlg3 对话框
- IMPLEMENT_DYNAMIC(CDlg3, CDialog)
- CDlg3::CDlg3(CWnd* pParent /*=NULL*/)
- : CDialog(CDlg3::IDD, pParent)
- , m_nW(0)
- , m_nH(0)
- , m_nBit(0)
- , m_nHz(0)
- {
- }
- CDlg3::~CDlg3()
- {
- }
- void CDlg3::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_W, m_nW);
- DDV_MinMaxUInt(pDX, m_nW, 800, 2000);
- DDX_Text(pDX, IDC_H, m_nH);
- DDV_MinMaxUInt(pDX, m_nH, 600, 2000);
- DDX_Text(pDX, IDC_BIT, m_nBit);
- DDV_MinMaxUInt(pDX, m_nBit, 8, 64);
- DDX_Text(pDX, IDC_HZ, m_nHz);
- DDV_MinMaxUInt(pDX, m_nHz, 60, 75);
- }
- BEGIN_MESSAGE_MAP(CDlg3, CDialog)
- ON_WM_CTLCOLOR()
- ON_WM_SHOWWINDOW()
- ON_BN_CLICKED(IDC_SETREFRES, &CDlg3::OnBnClickedSetrefres)
- ON_BN_CLICKED(IDC_SETNAME, &CDlg3::OnBnClickedSetname)
- END_MESSAGE_MAP()
- // CDlg3 消息处理程序
- HBRUSH CDlg3::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: 在此更改 DC 的任何属性
- int nID = pWnd->GetDlgCtrlID();
- switch (nID)
- {
- case IDC_STATIC:
- case IDC_W:
- case IDC_H:
- case IDC_BIT:
- case IDC_HZ:
- case IDC_NAME:
- pDC->SetTextColor(RGB(255, 0, 0));
- break;
- case IDC_STATIC1:
- case IDC_STATIC2:
- case IDC_STATIC3:
- pDC->SetTextColor(RGB(0, 0, 255));
- break;
- }
- // TODO: 如果默认的不是所需画笔,则返回另一个画笔
- return hbr;
- }
- void CDlg3::OnInitNameEdit()
- {
- char mbuf[255];
- wchar_t wbuf[255];
- memset(mbuf, 0, sizeof(mbuf));
- memset(wbuf, 0, sizeof(wbuf));
- HKEY hNameKey = NULL;
- if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\Blizzard Entertainment\Warcraft III\String"),
- 0, KEY_WRITE|KEY_READ, &hNameKey) == ERROR_SUCCESS)
- {
- DWORD dwType = 0;
- DWORD dwCount = 0;
- if (RegQueryValueEx(hNameKey, _T("userlocal"), NULL, &dwType,NULL, &dwCount) == ERROR_SUCCESS)
- {
- if (dwCount <= 32)
- {
- if (RegQueryValueExA(hNameKey, "userlocal", NULL, &dwType,(LPBYTE)mbuf, &dwCount) == ERROR_SUCCESS)
- {
- MultiByteToWideChar(CP_UTF8, 0, mbuf, dwCount, wbuf, dwCount);
- ::SetDlgItemText(m_hWnd, IDC_NAME, wbuf);
- }
- }
- }
- }
- if (hNameKey != NULL)
- RegCloseKey(hNameKey);
- }
- void CDlg3::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- CDialog::OnShowWindow(bShow, nStatus);
- // TODO: 在此处添加消息处理程序代码
- CRegister reg;
- reg.OpenKeyEx(HKEY_CURRENT_USER, _T("Software\Blizzard Entertainment\Warcraft III\Video"));
- reg.QueryValueExA("reswidth", (LPBYTE)&m_nW, 4);
- reg.QueryValueExA("resheight", (LPBYTE)&m_nH, 4);
- reg.QueryValueExA("colordepth", (LPBYTE)&m_nBit, 4);
- reg.QueryValueExA("refreshrate", (LPBYTE)&m_nHz, 4);
- OnInitNameEdit();
- UpdateData(0);
- }
- void CDlg3::OnBnClickedSetrefres()
- {
- // TODO: 在此添加控件通知处理程序代码
- UpdateData(1);
- BOOL bResult = TRUE;
- CRegister reg;
- bResult = bResult && reg.OpenKeyEx(HKEY_CURRENT_USER, _T("Software\Blizzard Entertainment\Warcraft III\Video"));
- bResult = bResult && reg.SetValueExExA("reswidth",REG_DWORD, (LPBYTE)&m_nW, sizeof(m_nW));
- bResult = bResult && reg.SetValueExExA("resheight", REG_DWORD, (LPBYTE)&m_nH, sizeof(m_nH));
- bResult = bResult && reg.SetValueExExA("colordepth", REG_DWORD, (LPBYTE)&m_nBit, sizeof(m_nBit));
- bResult = bResult && reg.SetValueExExA("refreshrate", REG_DWORD, (LPBYTE)&m_nHz, sizeof(m_nHz));
- if (bResult)
- {
- int w = GetSystemMetrics(SM_CXSCREEN);
- int h = GetSystemMetrics(SM_CYSCREEN);
- CString s;
- s.Format(_T(" 修改成功!进魔兽看看吧:)nn最佳设置:n 解析度: %d x %d x %d bitn 刷新率: %dHz"), w, h, 32, 75);
- MessageBox(s, _T("消息:"), MB_OK);
- }
- }
- void CDlg3::OnBnClickedSetname()
- {
- // TODO: 在此添加控件通知处理程序代码
- wchar_t buf[255];
- char mbuf[255];
- memset(mbuf, 0, sizeof(mbuf));
- GetDlgItemText(IDC_NAME, buf, wcslen(buf));
- WideCharToMultiByte(CP_UTF8, 0, buf, wcslen(buf), mbuf, wcslen(buf) * 3, NULL, NULL);
- HKEY hNameKey = NULL;
- if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\Blizzard Entertainment\Warcraft III\String"),
- 0, KEY_WRITE|KEY_READ, &hNameKey) == ERROR_SUCCESS)
- {
- if (RegSetValueExA(hNameKey, "userlocal", NULL, REG_SZ,
- (LPBYTE)mbuf, strlen(mbuf)) == ERROR_SUCCESS)
- {
- MessageBox(_T("改名成功!进魔兽--局域网看看吧:)"), _T("消息:"), MB_OK);
- }
- }
- if (hNameKey != NULL)
- RegCloseKey(hNameKey);
- }