Z order problems

W

Walter Briscoe

I run Excel 2003, Windows Vista and Internet Explorer 8.

I have a macro which quietly drives Internet Explorer.
When the macro has been waiting for a long time for a response from IE,
it does IE.Visible = True so the user can see what is happening and
displays a message for a short time with
Set sh = CreateObject("wscript.shell")
sh.Popup "Internet Explorer wait > 5 seconds", 3, "Temp message"
The z order <http://en.wikipedia.org/wiki/Z_order> is set
spreadsheet < popup < ie. i.e. spreadsheet under popup under ie.
(MsgBox behaves in the same way as sh.Popup.)
How do I make it,
spreadsheet < ie < popup.

More serious is that the taskbar z order seems to be set
taskbar < spreadsheet.
I have "Auto-hide the taskbar" set and struggle to see the taskbar.
How do I display the window names and their z-order positions?
How do I control the z-order across applications?
 
W

Walter Briscoe

In message <[email protected]> of Tue, 4 May 2010
17:17:05 in microsoft.public.excel.programming, Walter Briscoe
I run Excel 2003, Windows Vista and Internet Explorer 8.

I have a macro which quietly drives Internet Explorer.
When the macro has been waiting for a long time for a response from IE,
it does IE.Visible = True so the user can see what is happening and
displays a message for a short time with
Set sh = CreateObject("wscript.shell")
sh.Popup "Internet Explorer wait > 5 seconds", 3, "Temp message"
The z order <http://en.wikipedia.org/wiki/Z_order> is set
spreadsheet < popup < ie. i.e. spreadsheet under popup under ie.
(MsgBox behaves in the same way as sh.Popup.)
How do I make it,
spreadsheet < ie < popup.

More serious is that the taskbar z order seems to be set
taskbar < spreadsheet.
I have "Auto-hide the taskbar" set and struggle to see the taskbar.
How do I display the window names and their z-order positions?
How do I control the z-order across applications?

Nobody had anything to say on this.
I have not snipped above as I assume most readers will have scrapped it.

I have done some work which has NOT been successful.
I thought I would report it for reference.

With this simplified code:

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

IE.Visible makes an Internet Explorer window visible and GIVES IT FOCUS.

I tried code like this:

Private Declare Function SetWindowPos Lib "user32.dll" _
(ByVal hWND As Long, ByRef hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Boolean

Const HWND_NOTOPMOST = -2

Dim response As Boolean
response = SetWindowPos(IE.hWND, HWND_NOTOPMOST, _
IE.Left, IE.Top, IE.Width, IE.Height, 0)

response is false; HWND_NOTOPMOST is ineffective; window geography is
controlled. I showed that with Left = Top = Width = Height = 0.

I tried
Private Declare Function GetLastError Lib "kernel32" () As Long
Dim e As Long
e = GetLastError ' Gets variable not declared.

I googled and was advised to use err.LastDllError rather than
GetLastError.
err.LastDllError was 0 and thus undiagnostic.

On SetWindowPos, I did not understand some words in
<http://msdn.microsoft.com/en-us/library/ms633545(v=vs.85).aspx>:
"As part of the Vista re-architecture, all services were moved off the
interactive desktop into Session 0. hwnd and window manager operations
are only effective inside a session and cross-session attempts to
manipulate the hwnd will fail. For more information, see The Windows
Vista Developer Story: Application Compatibility Cookbook."
I followed the link but found no light.

I could think of no method of restoring focus to the window with focus
before setting IE.Visible = True and have again given up. I understand
that Microsoft tries to prevent arbitrary applications taking focus.
I suppose I might try 'CreateObject("Excel.Application")' ;)

I can place and size the Excel and IE windows so they do not overlap to
avoid the problem when it matters to me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top