 Location: Virginia Beach Joined: Jan 2013
Posts: 1178
|
Okay scratch what I said in the above post, it will compile fine now..
#include "main.h" #define DLL extern "C" _declspec(dllexport) HANDLE handle=NULL; HWND apphwnd; HWND game; HWND childhwnd; RECT rect;
LRESULT CALLBACK DllChildWndProc (HWND hWndParameter, UINT message,WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: return 0; break; } return DefWindowProc(hWndParameter, message, wParam, lParam); }
void MergeChildWithParent(HWND childWindowhWnd, UINT message,WPARAM wParam, LPARAM lParam){ SetWindowLong(childWindowhWnd, GWL_WNDPROC, DllChildWndProc(childWindowhWnd,message,wParam,lParam)); }
int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param) { DWORD pID; DWORD TpID = GetWindowThreadProcessId(hwnd, &pID); if (TpID == (DWORD)param) { apphwnd=hwnd; return false; } return true; }
HANDLE StartProcess(LPCTSTR program,LPCTSTR args) {
HANDLE hProcess = NULL; PROCESS_INFORMATION processInfo; STARTUPINFO startupInfo; ::ZeroMemory(&startupInfo,sizeof(startupInfo)); startupInfo.cb=sizeof(startupInfo); if(::CreateProcess(program,(LPTSTR)args, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo)) { WaitForInputIdle(processInfo.hProcess,INFINITE); ::EnumWindows(&EnumWindowsProc,processInfo.dwThreadId); hProcess=processInfo.hProcess; } return hProcess; }
DLL double HostingStartEmbed(double WindowHandle,char *Exe,char *Title,char *Class) { if (handle!=NULL) { TerminateProcess(handle,0); handle=NULL; }
game=FindWindow("YYGameMakerYY",NULL);
if ((HWND)(DWORD)WindowHandle!=NULL) { childhwnd=FindWindow(Class,Title); GetClientRect((HWND)(DWORD)WindowHandle,&rect); handle=StartProcess(Exe,"");
if (childhwnd==NULL) { if(apphwnd!=NULL) { ::SetParent(apphwnd,(HWND)(DWORD)WindowHandle); SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE); ::MoveWindow(apphwnd,rect.left,rect.top,rect.right,rect.bottom, true); } } else { ::SetParent(childhwnd,(HWND)(DWORD)WindowHandle); SetWindowLong(childhwnd, GWL_STYLE, WS_VISIBLE); ::MoveWindow(childhwnd,rect.left,rect.top,rect.right,rect.bottom, true); } } else { childhwnd=FindWindow(Class,Title); GetClientRect(game,&rect); handle=StartProcess(Exe,"");
if (childhwnd==NULL) { if(apphwnd!=NULL) { ::SetParent(apphwnd,game); SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE); SetWindowLong(apphwnd, GWL_EXSTYLE, WS_EX_APPWINDOW|WS_EX_TOOLWINDOW);
::MoveWindow(apphwnd,rect.left,rect.top,rect.right,rect.bottom, true); } } else { ::SetParent(childhwnd,game); SetWindowLong(childhwnd, GWL_STYLE, WS_VISIBLE); ::MoveWindow(childhwnd,rect.left,rect.top,rect.right,rect.bottom, true); } }
return 0; }
DLL double HostingEndEmbed() { if (handle!=NULL) { TerminateProcess(handle,0); handle=NULL; } return 0; }
DLL double HostingSetRectangle(double Left,double Top,double Right,double Bottom) { if (childhwnd==NULL) { if (apphwnd!=NULL) { ::MoveWindow(apphwnd,Left,Top,Right,Bottom,true); } } else { ::MoveWindow(childhwnd,Left,Top,Right,Bottom,true); } return 0; }
But I have no idea what to do next. Or.. Is there still something wrong with what I have right now?
|