Pages: 1 2 3 4 5 6 7 8 9 10 11
Author Topic: Window Styler, Web Browser, and Embed Program  (862,413 Views)
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #105 Posted on: September 29, 2014, 12:39:47 AM
Robert I tried your code and it threw errors. Are you sure what you provided is correct? The only thing I changed was I replaced the child window arg to use the handle to the child window, which I take is what I was supposed to do.
Offline (Unknown gender) lonewolff
Guest


Email
Reply #106 Posted on: September 30, 2014, 02:28:20 AM
TKG - found another oddity also. Probably to do with playing around with the windows. But, have you noticed this?

QuotePowered by GameMaker:Studio

window_set_caption() won't override the free advertising either (like it does in newly created projects).

Are you actually working for YYG?  :D

Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Reply #107 Posted on: September 30, 2014, 02:32:38 AM
Quote from: lonewolff on September 30, 2014, 02:28:20 AM
TKG - found another oddity also. Probably to do with playing around with the windows. But, have you noticed this?

QuotePowered by GameMaker:Studio

window_set_caption() won't override the free advertising either (like it does in newly created projects).

Are you actually working for YYG?  :D

I would actually not be surprised LOL!
Offline (Unknown gender) lonewolff
Guest


Email
Reply #108 Posted on: September 30, 2014, 02:37:14 AM
See, he was 'the mole' all along. Throwing slander at me to take focus off himself  ;)
Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Reply #109 Posted on: September 30, 2014, 02:39:22 AM
Quote from: lonewolff on September 30, 2014, 02:37:14 AM
See, he was 'the mole' all along. Throwing slander at me to take focus off himself  ;)

LMAO!

So once GMS 2 comes out next year he'll have to make it up to you, at least now we know someone on the inside :P
Offline (Unknown gender) lonewolff
Guest


Email
Reply #110 Posted on: September 30, 2014, 02:46:23 AM
Quote from: Darkstar2 on September 30, 2014, 02:39:22 AM
Quote from: lonewolff on September 30, 2014, 02:37:14 AM
See, he was 'the mole' all along. Throwing slander at me to take focus off himself  ;)

LMAO!

So once GMS 2 comes out next year he'll have to make it up to you, at least now we know someone on the inside :P

As long as I get a free copy :)
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #111 Posted on: September 30, 2014, 03:10:13 AM
Quote from: TKGRobert I tried your code and it threw errors. Are you sure what you provided is correct? The only thing I changed was I replaced the child window arg to use the handle to the child window, which I take is what I was supposed to do.

I'd have to see the output TKG.
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #112 Posted on: September 30, 2014, 03:28:01 AM
That caption is due to the first room's creation code. I assume no one will actually use that example room other than to see the extension actually works. But people can just delete that room and modify the object to suit their needs and place it in a room they created themselves without the caption. The ENIGMA version does the same thing "Powered by ENIGMA" I did that to show it works in both game engines with the screenshots. ;)

@Christopher Robin I'll do it first thing I wake up tom it's midnight AGAIN...
Offline (Unknown gender) lonewolff
Guest


Email
Reply #113 Posted on: September 30, 2014, 03:35:31 AM
Ah got ya :)

I thought it might be GM:S being a turd.
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #114 Posted on: September 30, 2014, 03:43:01 AM
Maybe it was, or maybe I'm being a turd.
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #115 Posted on: September 30, 2014, 05:58:19 PM
Quote from: Robert B Colton on September 30, 2014, 03:10:13 AM
Quote from: TKGRobert I tried your code and it threw errors. Are you sure what you provided is correct? The only thing I changed was I replaced the child window arg to use the handle to the child window, which I take is what I was supposed to do.

I'd have to see the output TKG.

At this point I'm afriad to mess with the code because I don't want to break anything due to window focus which isn't really that big of a deal if you ask me. I will fix it, I just have more pressing things to do for now. Thanks for the help! :D
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #116 Posted on: October 02, 2014, 05:45:20 PM
I discovered all this time BrowserDestroy() wasn't working and it was never working to begin with. I only tested destroying the browser at game end which is stupid because when the game ends all child windows are closed automatically.Meaning if anyone wanted to close the browser at any point before the game ends, the window (until now) would still be there!

BrowserDestroy() is now fixed in the most recent Marketplace update, and from the same link in the OP. :D
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #117 Posted on: October 02, 2014, 07:00:17 PM
Sorry for taking so long Bob, I have the code and error message at the ready.

Code:
#include "main.h"
#define DLL extern "C" _declspec(dllexport)
HANDLE handle=NULL;
HWND apphwnd;
HWND game;
HWND childhwnd;
RECT rect;

long LRESULT CALLBACK DllChildWndProc (HWND hWndParameter, UINT message,WPARAM wParam, LPARAM lParam)
{
  switch (message) {
    case WM_CREATE:
      return 0;
  }
  return DefWindowProc(hWndParameter, message, wParam, lParam);
}

void MergeChildWithParent(HWND childWindowhWnd) {
  SetWindowLong(childWindowhWnd, GWL_WNDPROC, DllChildWndProc);
}

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;
}


Error:
s\HostExe\main.cpp|9|error: expected initializer before 'DllChildWndProc'|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|


Note: apart from fixing that error I'm aware I'll still have more to do but one thing at a time I guess.
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #118 Posted on: October 02, 2014, 07:52:29 PM
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?
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #119 Posted on: October 02, 2014, 09:45:55 PM
Oh you fixed it? I was going to say that I don't know where that long came from but get rid of it. If that fixes it then yes, you are headed in the right direction!  (Y)

Now you can attach your child control when you create it to that message loop and intercept focus events.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646283%28v=vs.85%29.aspx

Just like we do for our main window in ENIGMA.
https://github.com/enigma-dev/enigma-dev/blob/master/ENIGMAsystem/SHELL/Platforms/Win32/WINDOWScallback.cpp#L99
Pages: 1 2 3 4 5 6 7 8 9 10 11