🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6165

Re: Opening up Web Browsers inside my App

#6165
From: Gav
Date: Tue, 07 Jun 2005 11:45
90 lines
4198 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:42a4855c$1@newsgroups.borland.com...

> The code I gave you is a standalone function, and needs to be used as 
> such.
> It sounds like you probably put the code inside your ITimageClick() code
> directly, which you cannot do.  It should be more like this instead:

Thanks, I thought I had tried it as below but must have misplaced it 
inside/outside a {or } somewhere.

I am no longer getting error messages, however, the last trick to the puzzle 
is eluding me still, I thought I just
had to use SetParent to a Form or Tab and that the Browser would open up 
inside that form, but it is not
happening.

My code is as yours below with the additions below your  " // use info.hWnd 
as needed..."


>
>    struct MyInfo
>    {
>        DWORD dwProcessId;
>        HWND hWnd;
>    };
>
>    BOOL CALLBACK FindBrowser(HWND hwnd, LPARAM lParam)
>    {
>        MyInfo *info = reinterpret_cast<MyInfo*>(lParam);
>        DWORD dwProcessId = 0;
>        ::GetWindowThreadProcessId(hwnd, &dwProcessId);
>        if( dwProcessId == info->dwProcessId )
>        {
>            info->hWnd = hwnd;
>            return FALSE;
>        }
>        return TRUE;
>    }
>
>    void __fastcall TMDIChild1::ITimageClick(TObject *Sender)
>    {
>        char DefaultBrowser[MAX_PATH+1] = {0};
>        MDIChild2->GetDefaultBrowser(DefaultBrowser);
>
>        STARTUPINFO si = {sizeof(STARTUPINFO), 0};
>        PROCESS_INFORMATION pi = {0};
>
>        AnsiString CmdLine = (AnsiQuotedStr(DefaultBrowser, '"') + " " +
> AnsiQuotedStr("http://www.minitutorials.com", '"'));
>        if( ::CreateProcess(NULL, CmdLine.c_str(), NULL, NULL, FALSE, 0,
> NULL, NULL, &si, &pi) )
>        {
>            ::CloseHandle(pi.hThread);
>            ::CloseHandle(pi.hProcess);
>
>            MyInfo info = {pi.dwProcessId, NULL};
>            ::EnumWindows((WNDENUMPROC)FindBrowser,
> reinterpret_cast<LPARAM>(&info));
>            if( info.hWnd != NULL )
>                // use info.hWnd as needed...
                 ::SetParent ( info.hWnd, Form4->Handle );
                Form4->Show();

>        }
>    }

What happens is when the ITImageClick button is pressed, the DefaultBrowser 
is found and executed
with the chosen URL no problems, but it is still doing this externally and 
not in the Form4 (or tabbed page)
as I would like.

Having checked , the result of the if( info.hWnd != NULL ) statement is NULL 
because the code inside it
does not get executed. In addition, placing the code outside the if 
statement makes Form4 appear as it should
but the Browser is still not appearing there but externally as usual.

Is there something else I have missed?

Having never used window properties and SetParent much I have been 
frantically researching it all and
trying different things but have not yet seen where I am going wrong.

Thanks

Gav...
Technical Details
Message-ID: <42a588ed@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!gail.ripco.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <422926aa$1@newsgroups.borland.com> <422c31bd$1@newsgroups.borland.com> <422c515c@newsgroups.borland.com> <422c5d8e$1@newsgroups.borland.com> <42a2f6aa$1@newsgroups.borland.com> <42a3910a$1@newsgroups.borland.com> <42a44aa2$1@newsgroups.borland.com> <42a4855c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,91b603800ded4d32
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Gav" <brightoncomputers@brightontown.com.au>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <422926aa$1@newsgroups.borland.com> <422c31bd$1@newsgroups.borland.com> <422c515c@newsgroups.borland.com> <422c5d8e$1@newsgroups.borland.com> <42a2f6aa$1@newsgroups.borland.com> <42a3910a$1@newsgroups.borland.com> <42a44aa2$1@newsgroups.borland.com> <42a4855c$1@newsgroups.borland.com>
Subject: Re: Opening up Web Browsers inside my App
Date: Tue, 7 Jun 2005 19:45:49 +0800
Lines: 92
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 203.121.204.130
Message-ID: <42a588ed@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1118144749 203.121.204.130 (7 Jun 2005 04:45:49 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!gail.ripco.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail