Internet Explorer - Automation

Hi I created a own little HTML - help system for a form. Now I ran into the following problem: If I call this help and the IE isn’t open already all works fine. The IE- window jumps in front of all other windows. But then - if a IE is already open (e.g. MBSUG [;)]) a new IE window appears but only in the task menu [:(]. How can I enforce the IE by automation to jump always in front? bye André

Hi Andre, There’s a Windows API function “ShellExecute” which allows you to pass an additional parameter specifying the window mode of the application you want to start. “Window mode” means e.g. focused or not, minimized/maximized/default etc. Unfortunately, the CREATE and SHELL functions in C/AL do not support this parameter. You can, however, create your own little COM DLL or OCX which does nothing but simply start IE with the appropriate window mode parameter. Another way might be to call some IE automation function (e.g. SetVisible) that brings the application to the top - if such a function exists… PS: We should reconsider our “private forum” we talked about recently [:o)]

Hi Heinz

quote:


Originally posted by xorph
… PS: We should reconsider our “private forum” we talked about recently [:o)] …


That was my first thought too as I saw who has answered [:D]!

quote:


… You can, however, create your own little COM DLL or OCX which does nothing but simply start IE with the appropriate window mode parameter. …


Isn’t this to much for a simple ‘Come to top’ - order?

quote:


Another way might be to call some IE automation function (e.g. SetVisible) that brings the application to the top - if such a function exists…


With one of these functions it works if the the new IE window is the first (current) IE window. See my code below: CLEAR("IE Help"); IF CREATE("IE Help",TRUE)THEN; //Other IE should still alive "IE Help".MenuBar(FALSE); "IE Help".AddressBar(FALSE); "IE Help".Navigate(MyFullPath); "IE Help".Left(550); "IE Help".Top(70); "IE Help".Width(450); "IE Help".Visible(TRUE); I tried to use “IE Help”.FullScreen (PopUp- modus SIC!) but the second IE windows doesn’t come to the top in this case [:(]. bye André

quote:


Originally posted by Andre DDB
Isn’t this to much for a simple ‘Come to top’ - order?


Not at all! In VB, this will take about 5 minutes (seriously). All you need to do is create a COM-DLL project, write a “Public Sub xxx” which executes the program launch using all required parameters (filename etc.), and compile it to a DLL. That’s it… (yes, VB rules! [8D]) The disadvantage, of course, is the requirement that the DLL be installed on all client computers.

quote:


With one of these functions it works if the the new IE window is the first (current) IE window.


I don’t get the exact meaning of “…the new is the first…”. You mean, if you reuse the running instance, it works?

quote:


Originally posted by xorph
[ …

quote:


With one of these functions it works if the the new IE window is the first (current) IE window.


I don’t get the exact meaning of “…the new is the first…”. You mean, if you reuse the running instance, it works?


This means: If no other IE window is already open hence the now current one is the first IE instance on the system. Then the jump to the top works (from within Navision). bye André

Erm… silly me [:I] This is what you wrote in your first posting. Well, the only thing I found was the SetForegroundWindow function in the Windows API. It accepts a window handle - which you can retrieve from the IE automation object - as only parameter, and brings the specified window to the top of the window stack. The full documentation can be found on MSDN - a google search brought this as the very first match. Since you can not call API functions from C/AL directly (or can you?), this means “back to OCX”… [B)]

Addendum: If I understand the MSDN docs correctly, it is now (>= W2K) system policy that an application can not make itself the top-level window.

quote:


Originally posted by xorph
Addendum: If I understand the MSDN docs correctly, it is now (>= W2K) system policy that an application can not make itself the top-level window.


…M$ doesn’t allow other applications to go to the top. Mhmm [}:)].

Hi Heinz I got a solution. It cost me a nightshift to browse all automation servers [xx(](1. create a variable / 2. browse all methods / properties). I found a lot of interesting things (e.g. Shell.ShutDownWindows)[}:)] I can do it with Excel [8D]. They way is like the following: - create and show my IE window (IE- Automation) - count all current IE -windows (IEShell - Automation) - if there is more than one IE -window then send keys Alt + Tab to select the last opened window (Excel -Automation) I know SendKey is not always a good choice - but in my case it works perfect. Here is the code: Name DataType Subtype Length IE Help Automation 'Microsoft Internet Controls'.InternetExplorer MyIEShell Automation 'Microsoft Internet Controls'.ShellWindows MyXL Automation 'Microsoft Excel 9.0 Object Library'.Application IECount Integer CLEAR("IE Help"); IF CREATE("IE Help",TRUE)THEN; "IE Help".MenuBar(FALSE); "IE Help".AddressBar(FALSE); "IE Help".Navigate(MyFullPath); "IE Help".Left(550); "IE Help".Top(70); "IE Help".Width(450); "IE Help".Visible(TRUE); CLEAR(MyIEShell); IF CREATE(MyIEShell,TRUE)THEN; IECount:= MyIEShell.Count; IF IECount > 1 THEN BEGIN CLEAR(MyXL); IF CREATE(MyXL,TRUE)THEN; MyXL.SendKeys('%{TAB}'); END; btw. I found a CD play ocx on my home computer. @Nils: If you read this I didn’t forget you [;)]. bye André

Hi Andre! Cool solution! [8D] Reminds me a bit of scratching your left ear with your right hand while doing situps with your left leg straight up [:D][:o)] But seriously: Amazing solution. Truly amazing. And - fascinating how Windows forces you to invent new and unconventional ways to get things done. [:0]

quote:


Originally posted by xorph
Hi Andre! Cool solution! [8D] Reminds me a bit of scratching your left ear with your right hand while doing situps with your left leg straight up [:D][:o)] But seriously: Amazing solution. Truly amazing. And - fascinating how Windows forces you to invent new and unconventional ways to get things done. [:0]


YEP. And I love this game [:D]! There is (almost) always a way to solve a problem. And there is ‘golden’ rule for me: “If almost nothing works - Excel(incl. VBA) will do the job!” [8D] bye André