myleseven
asked on
How to make Internet Connection dialog stay on top
Hi there I have built an Internet surfing program.
I have a button in my program that when I click it it will load up the internet connection dialog box.
However I have discovered that if I then click on my form, the dialog box will 'dissapear' behind the form.
Is there anyway that I can keep it on top even if I click on my form?
I notived that the same thing happens for IE...
regards
Myles :)
I have a button in my program that when I click it it will load up the internet connection dialog box.
However I have discovered that if I then click on my form, the dialog box will 'dissapear' behind the form.
Is there anyway that I can keep it on top even if I click on my form?
I notived that the same thing happens for IE...
regards
Myles :)
Do you know handle of this connection dialog? If yes, you may use this:
SetWindowLong(wnd, gwl_exstyle, GetWindowLong(wnd, gwl_exstyle) or ws_ex_topmost)
SetWindowLong(wnd, gwl_exstyle, GetWindowLong(wnd, gwl_exstyle) or ws_ex_topmost)
ASKER
Hi guys,
To show the dialog all I do is naviagate to my Browser... This seems to be quite a good universal method for loading up the Internet Dialog box...(by the way I am using TembeddedWB) Here is my code:
procedure tForm1.GoNow();
begin
inherited;
// Hook the embedded browser control
FWebSelfPopup:=TWebSelfPop up.CreateH ook(theBro wser);
// Post message to our handle - the message handler will perform the
// actual navigation. This is recommended by MS to ensure that the IE control
// is in a loaded state and able to handle the call.
PostMessage(Handle, WM_NAVIGATE, 0, 0);
end;
I quite like the idea of getting the handle and using the SetWindowLong, I will have a go to see if I can make this work...
cheers
Myles :)
To show the dialog all I do is naviagate to my Browser... This seems to be quite a good universal method for loading up the Internet Dialog box...(by the way I am using TembeddedWB) Here is my code:
procedure tForm1.GoNow();
begin
inherited;
// Hook the embedded browser control
FWebSelfPopup:=TWebSelfPop
// Post message to our handle - the message handler will perform the
// actual navigation. This is recommended by MS to ensure that the IE control
// is in a loaded state and able to handle the call.
PostMessage(Handle, WM_NAVIGATE, 0, 0);
end;
I quite like the idea of getting the handle and using the SetWindowLong, I will have a go to see if I can make this work...
cheers
Myles :)
ASKER
whoops I left this part out...
procedure TForm1.WMNavigate(var Msg: TMessage);
var ovURL: OleVariant;
begin
// Set the url
ovURL := edURL.Text;
// Perform the navigation
theBrowser.Navigate2(ovURL );
end;
procedure TForm1.WMNavigate(var Msg: TMessage);
var ovURL: OleVariant;
begin
// Set the url
ovURL := edURL.Text;
// Perform the navigation
theBrowser.Navigate2(ovURL
end;
ASKER
Actually I have no idea how to get the handle of theInternet Connection Dialog box...
Do you have any suggestions?
Myles:)
Do you have any suggestions?
Myles:)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Zhaawz,
I have found a way to get the handle of the Internet Dialog box. THe problem is that it depends on the Title at the top of the box and I am not sure how universal this is.
Here is the code that I am using... It would be great to hear what you think...
procedure TForm1.btnConnectToNetClic k(Sender: TObject);
//Purpose: To connect to the internet
var
wnd : HWND;
begin
wnd := 0;
ShellExecute(Handle, 'open', 'http://delphi.about.com',nil,nil, SW_SHOWNORMAL);
Pause(1); //to give the Internet Connection Box time to display
wnd := FindWindowByTitle('Dial-up Connection');
{if wnd = 0 then wnd := FindWindowByTitle('Try another Title');
if wnd = 0 then wnd := FindWindowByTitle('Try another Title');
if wnd = 0 then wnd := FindWindowByTitle('Try another Title'); }
SetWindowPos(wnd, HWND_TOPMOST, Left,Top, Width,Height, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
SetWindowLong(wnd, GWL_USERDATA, 0);
end;
function TForm1.FindWindowByTitle(W indowTitle : string): Hwnd;
var
NextHandle: Hwnd;
NextTitle: array[0..260] of char;
begin
//ListBox1.Clear;
//ListBox1.Items.Add('Look ing for: ' + WindowTitle);
// Get the first window
NextHandle := GetWindow(Application.Hand le, GW_HWNDFIRST);
while NextHandle > 0 do
begin
// retrieve its text
GetWindowText(NextHandle, NextTitle, 255);
// if nextTitle <> '' then ListBox1.Items.Add(nextTit le);
if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
begin
Result := NextHandle;
Exit;
end
else
// Get the next window
NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
end;
Result := 0;
end;
// pause for Secs seconds, but allow the application to respond to windows messages.
Procedure TForm1.Pause(Secs : Integer);
var
i : Integer;
begin
for i := 1 to Secs * 10 do begin
Sleep(100); // sleep for 1/10 seconds
Application.ProcessMessage s;
end;
end;
I have found a way to get the handle of the Internet Dialog box. THe problem is that it depends on the Title at the top of the box and I am not sure how universal this is.
Here is the code that I am using... It would be great to hear what you think...
procedure TForm1.btnConnectToNetClic
//Purpose: To connect to the internet
var
wnd : HWND;
begin
wnd := 0;
ShellExecute(Handle, 'open', 'http://delphi.about.com',nil,nil, SW_SHOWNORMAL);
Pause(1); //to give the Internet Connection Box time to display
wnd := FindWindowByTitle('Dial-up
{if wnd = 0 then wnd := FindWindowByTitle('Try another Title');
if wnd = 0 then wnd := FindWindowByTitle('Try another Title');
if wnd = 0 then wnd := FindWindowByTitle('Try another Title'); }
SetWindowPos(wnd, HWND_TOPMOST, Left,Top, Width,Height, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
SetWindowLong(wnd, GWL_USERDATA, 0);
end;
function TForm1.FindWindowByTitle(W
var
NextHandle: Hwnd;
NextTitle: array[0..260] of char;
begin
//ListBox1.Clear;
//ListBox1.Items.Add('Look
// Get the first window
NextHandle := GetWindow(Application.Hand
while NextHandle > 0 do
begin
// retrieve its text
GetWindowText(NextHandle, NextTitle, 255);
// if nextTitle <> '' then ListBox1.Items.Add(nextTit
if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
begin
Result := NextHandle;
Exit;
end
else
// Get the next window
NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
end;
Result := 0;
end;
// pause for Secs seconds, but allow the application to respond to windows messages.
Procedure TForm1.Pause(Secs : Integer);
var
i : Integer;
begin
for i := 1 to Secs * 10 do begin
Sleep(100); // sleep for 1/10 seconds
Application.ProcessMessage
end;
end;
ASKER
Well I couldn't have gotten this far without your help Zaaawz so I will give you the points, thanks heaps
:)
Myles
:)
Myles
What is the code are you using for show the dialog?