Вопрос

I have been searching this for few hours, but without proper results. What I want to do, is make an external window to topmost, over my form1. So my form1 is topmost, but when default browser is opened via shellexecute, it should stay on top, until closed.

My code is:

   Dim r As Long
   r = ShellExecute(0, "open", "http://www.google.com", 0, 0, 1)

And when "google.com" is opened, the default browser should stay on top, until closed as I mentioned earlier.

Is there any decent solution available? If so, I would appreciate if anybody could tell me how to do it.

Это было полезно?

Другие советы

have a look at the SetWindowPos API

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

If both your window, and the browser window are top most. then you can put code in your application's activation event so that:

SetWindowPos(browserHandle, Me.hwnd, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);

for getting the browser handle you need to use ShellExecuteEx instead of ShellExecute. That will give you an hProcess. Using that you EnumWindows() and see which windows have that GetWindowThreadProcessID(). Then you store those windows in a list, and iterate over them calling the SetWindowPos api so that they go behind your form's handle.

If your form is an MDI parent, you can consider making the browser an MDI Child as any window can become an MDI child.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top