IWebBrowserDisp ole2 interface cannot open IE window to front of the screen - delphi

With Windows 7/8, this very nice ole2 interface IWebBrowserDisp is no more working properly, for some reason it now opens the IExplorer Window behind the actual currently running delphi application, not to the front of the screen as it used to be work earlier.
This makes the application to fail as user cannot see the opening web page without manually switching to Iexplorer and locating the correct window.
The code that I use to launch the link is:
WB : TEmbeddedWB;
wb.Navigate(URL,x,x,x,x);
This problem does not exist in older Windows or while I use my Delphi IDE ( I use Delphi4 and run it as ADMIN).

Related

Adobe PDF Reader Plugin in TWEBBROWSER on new PC

according to PDF in TWEbbrowser I tried to run an selfprogrammed Delphi Prg which displays the PDF in a TWEBBROWSER component fine. But on 2 new PCs, where I just installed the Adobe DC PDF Reader I only see a gray window - no PDF anymore. How to fix this? I can see the PDF in IE. I Have Delphi Berlin.
Thanks for help
The reason why PFD isn't correctly shown in TWebBrowser is the fact that by default TWebBrowser is opening web pages in Compatibility mode. This means that the web pages are opened in Interent Explorer 7 mode wihtout any extensions. And in order for you to be able to open PDF in Internet explorer it is done so in Acrobar Reader Web Extension.
In order to make TWebBrowser open web pages in compatibility mode for newest IE version you need to Opt in to the browser emulation feature using the documented registry key
NOTE: You need to opt in to the browser emulation on every computer where your program is used.
Or you could switch to the use of TEdgeBrowser instead as Robson Benedito suggested in his answer.
TWebBrowser component, when in Windows, navigates using the old Internet Explorer (not Microsoft Edge).
To ensure that it works you should open Microsoft Internet explorer and try to open this document in the machine that is showing the problem.
If it doesn't open you should fix it inside IE before open in you Delphi app. If it does, it could be an incompatibility with this Adobe plugin and the engine provided/used by TWebBrowser. In this case you can switch to TEdgeBrowser component that provides you the ability to have you own browser (with Chromnium) even if the Microsoft Edge is not installed (http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TEdgeBrowser_Component_and_Changes_to_the_TWebBrowser_Component).
With TEdgeBrowser you can open PDF directly without using plugin (even those installed in Windows).
Using TWebBrowser can also lead you to others problems with others PCs depending on the Internet Explorer (like proxy/javascript/plugins/etc).

Make Delphi application start on a specific desktop

Is there a way to force a Delphi application to always start on a particular desktop in Windows 10? I'm using multiple desktops, and sometimes switch between them when waiting for the application to compile. This has the effect that when it's finished compiling, the application is launched on the currently active desktop, i.e. not necessarily the "main" one where the IDE is placed.
It would be nice if there was a way to force Delphi to always use the main desktop when launching applications. Or if that's not possible in the IDE, could I at least force the application itself to always use the main desktop?
Note that I'm not talking about multiple monitors, but multiple Windows 10 Desktops.

Windows Application Driver handle windows explorer window

I'm trying to automate a windows desktop application and everything is fine until in one of the steps in my application, I have to click on a "Browse" buttom that opens a windows explorer window to select an image and load it.
The thing is that I do not know how to make WinAppDriver focus in this new window, to be able to select the image and load it.
This is a part of the desktop application, and when sending click on Browse:
You probably need winappdriver to change its current handle to the one from the new explorer window. I'm not sure about the Python syntax, but in C# you do it like this:
driver.SwitchTo().Window(Driver.WindowHandles.Last());
The Last() function just selects the most recent added windowHandle.
Make sure you keep your previous window handle around, so you can switch back once the explorer window closes.
Also take a look at these posts. Its about webdriver but the functions are similar:
webdriver C#
webdruver java

Delphi OpenPictureDialog behave different on different app

I'm using Delphi 10.1 on Windows 10
When I run the OpenPictureDialog.Execute command
on some app it's open File Explorer with a preview area and on others without.
I have exactly the same properties on both cases.
What can cause the difference?
Thanks Sorin
function GetOpenFileName; external commdlg32 name 'GetOpenFileNameA';
function GetOpenFileNameA; external commdlg32 name 'GetOpenFileNameA';
function GetOpenFileNameW; external commdlg32 name 'GetOpenFileNameW';
In older versions on Delphi it used a Windows API function in comdlg32.dll to open a file. I would think it is the same in newer versions. What you see in terms of preview etc. is down to Windows settings.
The dialog shows to the user will be consistent with other file open dialogs they see on their system.

Delphi - Embed an external application within a tpanel or form

I tried to embed external app, not only notepad but also mstsc (remote desktop), within a tpanel in my delphi application.
With CreateProcess i run application and with Windows.SetParent i embed first app window.
I get problems with next windows opened by then external app (for instance file-open window in notepad or next login window and main window in remote desktop).
Timing a call to enumwindows for the external process is a solution, but enumwindows list every window of the process (also popup & controls).
Is there a way identify only process' windows (forms) to be relocated, or a way to embed the process once for all within the panel?
Thanks

Resources