Sign in to follow this  
Followers 0
JohnOne

SetParent

17 posts in this topic

#1 ·  Posted (edited)

I'm having an issue trying to set an IE window's parent similar as in >this post, I thought it would be pretty simple to be honest but the IE window does not appear to be set as child to my GUI.

I get no errors either, can anyone spot my mistake?

//Create an Internet Explorer kiosk window
    //hWnd is my gui
    HINSTANCE IEKIOSK = ShellExecuteA(hWnd, "open",
        "C:\\progra~1\\intern~1\\iexplore.exe",
        "-k http://www.google.com",
        "",
        SW_SHOW);

    HWND IEWIN = NULL;

    do{IEWIN = FindWindowA("IEFrame", "http://www.google.com/ - Google - Windows Internet Explorer");
    Sleep(100);
    }while(! IEWIN);
    Beep(700,100);
    
    if(! SetParent(IEWIN,hWnd)){
        MessageBoxA(NULL, "Funtion failure", "Error", MB_OK);
    };
        
    MoveWindow(IEWIN,0,0,400,300,true);

 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

Do you want it in autoit? if so, try this :

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <WinAPI.au3>

Opt("WinTitleMatchMode", 2)

;Create an Internet Explorer kiosk window
ShellExecute("C:\\progra~1\\intern~1\\iexplore.exe", "-k http://www.google.com")

Local $hIEWIN = 0

Do
    $hIEWIN = WinGetHandle("[CLASS:IEFrame;TITLE: - Google - Windows Internet Explorer]")
    Sleep(100)
Until $hIEWIN > 0

Beep(700, 100)

Local $hGUI = GUICreate("MyGUI")
GUISetState(@SW_SHOW, $hGUI)

If _WinAPI_SetParent($hIEWIN, $hGUI) = 0 Then
    MsgBox($MB_OK, "Funtion failure", "Error")
EndIf

;~ WinMove($hIEWIN, 0, 0, 400, 300)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)
WEnd
Edit: Added indents.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks FireFox, but my problem is that, when I convert that code to C++ it does not work.

Or perhaps more specifically, the IE window does not pseudo embed into the window I create in c++ (hWnd).

The _WinAPI_SetParent() is basically just a DllCall to C++ Setparent and my expectations were that it would do exactly the same as what it does in AutoIt.

It seems very odd that it does not.

EDIT:

I have used a few different ways of starting IE, including CoCreateInstance, CreateProcess, ShellExecuteEx and simply retrieving the handle of an already running IE window. All without success.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Can you send me your project in a packed file?


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here is project

http://www.filedropper.com/ieembed

EDIT: not quite a few minutes, but had a pop in from a pal in the middle, so I had to stop cause he was mocking me for being a big daft science cowboy.

EDIT2: I could not be bothered to put a button in so I just shamefully recycled the exit from file menu to run the function  :> 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

The ShellExecute fails and it avoids the MessageBox to be displayed, I can see that with breakpoints.

You can't get a partial title with the FindWindow function, you will need to use the EnumWindows function and check the titles (which I can't get to work).

I have tested directly with the handle of the IE kiosk window and the rest of the script is OK.

I don't code in C++, I will be glad if someone points out what's wrong :

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
void myFunc1(HWND);

void Embed(){
    /*
    HINSTANCE IEKIOSK = ShellExecute(
            hWnd, 
            L"open", 
            L"C:\\Progra~1\Intern~1\\iexplore.exe",
            L"-k http://www.google.com/",
            L"",
            SW_SHOW);
    //??does not work
    if (!IEKIOSK) {
        MessageBox(NULL, L"Function ShellExecute Failed", L"Boooooo!", MB_OK);
        exit(0);
    }
    */
    EnumWindows(EnumWindowsProc, NULL);
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
    LPTSTR title = (LPTSTR)""; LPTSTR class_name = (LPTSTR)"";

    GetClassName(hwnd, class_name, sizeof(class_name));
    GetWindowText(hwnd, title, sizeof(title));

    printf("%d", lstrcmpi(class_name, (LPTSTR)"IEFrame")); //??access violation

    //if(lstrcmpi(class_name, (LPTSTR)"IEFrame") && lstrcmpi(title, (LPTSTR)"Google - Windows Internet Explorer")) {
    if((int)hwnd==0x002003D8) { //handle of the IE kiosk wnd
        myFunc1(hwnd);
        return FALSE;
    }

    return TRUE;
}

void myFunc1(HWND wnd) {
    Beep(700,150);

    if (!SetParent(wnd, hWnd)){
        MessageBox(NULL, L"Function Setparent Failed", L"Boooooo!", MB_OK);
    }

    MoveWindow(wnd, 0, 0, 400, 400, TRUE);
}
Br, FireFox.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Sorry, I already had a normal IE window open just for testing and Findwindow was working fine to get window handle.

The Shellexecute was not working because I left out an escaping backslash in the path somehow.

Are you saying that the IE window embeds into the created window for you?


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Are you saying that the IE window embeds into the created window for you?

Yes. Try without the MoveWindow function.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Well, I edited a few lines in the IEEMBED file. I don't know if it affects the rest of the program.

Try it: http://www.mediafire.com/download/rlcnzm4dv7apqwk/IEEMBED.zip

1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I removed the local declaration of hWnd in the InitInstance function, otherwise it overrides? the global one which is then not set.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

You're welcome :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

FireFox. Thank you kindly. Your code works, but I can not immediately see what you have changed other than where you call the function.

Can you give an explanation if you have the time?

Last week I'm also having the same problem. In this answer useful for me.I will  try  to  use the same method the error is to be clear.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0