|
@@ -64,6 +64,7 @@ BEGIN_MESSAGE_MAP(CGameAssistDlg, CDialog)
|
|
|
ON_WM_QUERYDRAGICON()
|
|
|
//}}AFX_MSG_MAP
|
|
|
ON_BN_CLICKED(BTN_OPENGAME, &CGameAssistDlg::OnBnClickedOpengame)
|
|
|
+ ON_BN_CLICKED(IDC_BUTTON2, &CGameAssistDlg::OnBnClickedButton2)
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
@@ -156,7 +157,8 @@ HCURSOR CGameAssistDlg::OnQueryDragIcon()
|
|
|
void CGameAssistDlg::OnBnClickedOpengame()
|
|
|
{
|
|
|
#if 1 // 获取游戏标题;
|
|
|
- HWND hProWnd = GAssist::GetProHwnd(GAssist::FindProcess(_T("Game.exe")));
|
|
|
+ DWORD dwPid = GAssist::FindProcess(_T("Game.exe"));
|
|
|
+ HWND hProWnd = GAssist::GetProHwnd(dwPid);
|
|
|
//HWND hProWnd = GAssist::GetProHwnd(5824);
|
|
|
TCHAR szWinText[MAX_PATH] = {0};
|
|
|
::GetWindowText(hProWnd, szWinText, MAX_PATH);
|
|
@@ -164,7 +166,7 @@ void CGameAssistDlg::OnBnClickedOpengame()
|
|
|
RECT rc = {0,0,500,500};
|
|
|
HBITMAP hb = GAssist::CopyDC2Bitmap(hProWnd, &rc);
|
|
|
GAssist::SaveBitmap(hb, "D:\\1.bmp");
|
|
|
- //GAssist::SaveHwndToBmpFile(hProWnd, "D:\\2.bmp");
|
|
|
+ GAssist::SaveHwndToBmpFile(hProWnd, "D:\\2.bmp");
|
|
|
return;
|
|
|
#endif
|
|
|
|
|
@@ -296,3 +298,99 @@ void CGameAssistDlg::OnBnClickedOpengame()
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+void CGameAssistDlg::OnBnClickedButton2()
|
|
|
+{
|
|
|
+ // TODO: 在此添加控件通知处理程序代码
|
|
|
+ //创建DirectDraw
|
|
|
+ if (FAILED(DirectDrawCreate(NULL, &ddraw1, NULL)))
|
|
|
+ {
|
|
|
+ TRACE(/ "Couldn/'t create DirectDraw object.//n/");
|
|
|
+ }
|
|
|
+ if (FAILED(ddraw1->QueryInterface(IID_IDirectDraw2, (LPVOID*)&ddraw2)))
|
|
|
+ {
|
|
|
+ TRACE(/ "Couldn/'t query the interface.//n/");
|
|
|
+ }
|
|
|
+ if (ddraw2)
|
|
|
+ {
|
|
|
+ ddraw2->SetCooperativeLevel(GetSafeHwnd(), DDSCL_NORMAL);
|
|
|
+ }
|
|
|
+ if (ddraw1)
|
|
|
+ {
|
|
|
+ ddraw1->Release();
|
|
|
+ ddraw1 = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建主表面
|
|
|
+ HRESULT r;
|
|
|
+
|
|
|
+ DDSURFACEDESC desc;
|
|
|
+ desc.dwSize = sizeof(desc);
|
|
|
+ desc.dwFlags = DDSD_CAPS;
|
|
|
+ desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
|
|
+ r = ddraw2->CreateSurface(&desc, &primsurf, 0);
|
|
|
+ if (r != DD_OK)
|
|
|
+ {
|
|
|
+ AfxMessageBox(/ "Create DirectX Surface failed//n /");
|
|
|
+ PostMessage(WM_CLOSE);
|
|
|
+ }
|
|
|
+ r = ddraw2->CreateClipper(0, &clipper, 0);
|
|
|
+ if (r != DD_OK)
|
|
|
+ {
|
|
|
+ AfxMessageBox(/ "CreateClipper() fialed//n /");
|
|
|
+ PostMessage(WM_CLOSE);
|
|
|
+ }
|
|
|
+ r = clipper->SetHWnd(0, GetSafeHwnd());
|
|
|
+ if (r != DD_OK)
|
|
|
+ {
|
|
|
+ AfxMessageBox(/ "SetHWnd() failed//n /");
|
|
|
+ PostMessage(WM_CLOSE);
|
|
|
+ }
|
|
|
+ r = primsurf->SetClipper(clipper);
|
|
|
+ if (r != DD_OK)
|
|
|
+ {
|
|
|
+ AfxMessageBox(/ "SetClipper() fialed//n /");
|
|
|
+ PostMessage(WM_CLOSE);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建后台表面
|
|
|
+ ZeroMemory(&desc, sizeof(desc));
|
|
|
+ desc.dwSize = sizeof(desc);
|
|
|
+ desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
|
|
|
+ desc.dwWidth = ::GetSystemMetrics(SM_CXSCREEN);
|
|
|
+ desc.dwHeight = ::GetSystemMetrics(SM_CYSCREEN);
|
|
|
+ desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
|
|
|
+
|
|
|
+ r = ddraw2->CreateSurface(&desc, &backsurf, 0);
|
|
|
+ //收集图象参数
|
|
|
+ DDSURFACEDESC ddsd;
|
|
|
+
|
|
|
+ ZeroMemory(&ddsd, sizeof(ddsd));
|
|
|
+ ddsd.dwSize = sizeof(ddsd);
|
|
|
+ backsurf->GetSurfaceDesc(&ddsd);
|
|
|
+ BitCount = ddsd.ddpfPixelFormat.dwRGBBitCount;
|
|
|
+ lPitch = ddsd.lPitch;
|
|
|
+ dwWidth = ddsd.dwWidth;
|
|
|
+ dwHeight = ddsd.dwHeight;
|
|
|
+ dwRBitMask = ddsd.ddpfPixelFormat.dwRBitMask;
|
|
|
+ dwGBitMask = ddsd.ddpfPixelFormat.dwGBitMask;
|
|
|
+ dwBBitMask = ddsd.ddpfPixelFormat.dwBBitMask;
|
|
|
+ //确定16Bit色时的修正(16Bit色时有两种显示格式565和555)
|
|
|
+ RMove = 8;//这里先假定为565格式
|
|
|
+ GMove = 3;
|
|
|
+ BMove = 3;
|
|
|
+ if (BitCount == 16)
|
|
|
+ {
|
|
|
+ if (dwGBitMask == 992)
|
|
|
+ {
|
|
|
+ //555格式
|
|
|
+ RMove = 7;
|
|
|
+ GMove = 2;
|
|
|
+ }
|
|
|
+ if (dwGBitMask == 1984)
|
|
|
+ //555格式
|
|
|
+ BMove = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|