Why I can't display some site with TWebBrowser - firemonkey

I use Delphi Rio (Windows Desktop App) and need to display in a TWebBrowser some webpages.
I ran into a problem with this WooCommerce site, https://merletdance.com/eshop.
When I ask for this one, I can't pass the cookies dialog. I understand it's in relation with JScript and/or JQuery, but is there a way to bypass or better (some parameters of TwebBrowser) ?
[Edit] Works with Delphi 11 (Alexandria) using Edge

Found a solution, even if for my users with heterogeneous park it's not a cure-all: Embarcadero's documentation on TWebBrowser hints to edit the registry:
Supporting JavaScript Integration on Windows Platform
On Windows target platforms (WIN32 and WIN64), TWebBrowser may incorrectly display some Web pages if a Web site uses JavaScript dialog boxes, panels, and other elements for various purposes.
To work around this issue, your application should display Web pages in the IE11 edge mode using the FEATURE_BROWSER_EMULATION feature of Internet Explorer.
Open the Registry Editor.
Open the following key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
On the Edit menu, point to New, and then click DWORD (32-bit) Value.
Set the name of this new entry to your executable file name, such as MyApps.exe.
Select the newly created entry, and on the Edit menu, click Modify.
In the Edit dialog box that opens, do the following:
In the Value data text box, enter 11011
Under Base, select Decimal
Click OK to save your changes
You can also cause your application to make the above described changes when the application starts. For example, in your project, the FormCreate event handler can call the following TForm1.SetPermissions method:
procedure TForm1.FormCreate(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
SetPermissions;
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
procedure TForm1.SetPermissions;
const
cHomePath = 'SOFTWARE';
cFeatureBrowserEmulation =
'Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\';
cIE11 = 11001;
var
Reg: TRegIniFile;
sKey: string;
begin
sKey := ExtractFileName(ParamStr(0));
Reg := TRegIniFile.Create(cHomePath);
try
if Reg.OpenKey(cFeatureBrowserEmulation, True) and
not(TRegistry(Reg).KeyExists(sKey) and (TRegistry(Reg).ReadInteger(sKey)
= cIE11)) then
TRegistry(Reg).WriteInteger(sKey, cIE11);
finally
Reg.Free;
end;
end;
{$ENDIF}
Note: You should make these appropriate changes to the registry before starting the application. After you start your application for the first time, close it, and then start again.

Related

Inno Setup window preview in taskbar

All of the programs and opened files have a preview when you hover the mouse on their icons inside the taskbar.
But for Inno Setup made installers it seems there is no preview. Any fix or trick to solve this issue?
Though some game installers with custom design (which use Inno Setup) have a preview in the taskbar. For example:
http://fs2.filegir.com/cuttlas/setup.exe
I believe it's because the taskbar button is linked to an invisible internal window of Inno Setup and not to the visible wizard window. That also explains how it is possible that the taskbar button has a different title than the wizard window. Note that those always match for the windows, where the preview works.
Nothing you can do about it without modifying code of Inno Setup itself.
The link you have posted in not the standard Inno Setup. Note the "5.5.1*.ee2**"* in their log file. They have probably modified Inno Setup significantly. Note how, when (in Windows 10) you hover mouse over their preview window, the wizard window stays visible (and other windows blur). While with standard Inno Setup, all windows blur, including the wizard. This is because their taskbar button in linked to the wizard window. While in standard Inno Setup, it's not.
I have found a great library to solve this:
https://mega.co.nz/#F!RcQkhSxI!_ZsnpdapAeoVVWEgVw2iMQ
using WinTB v2.0 you can easily turn on the preview on the Taskbar:
#include "WinTB.iss"
[Setup]
AppName=Wintb.dll example
AppVersion=2.0
DefaultDirName={pf}\Wintb.dll example
DefaultGroupName=Wintb.dll example
OutputDir=.
[files]
Source: wintb.dll; Flags: dontcopy;
[code]
procedure InitializeWizard();
begin
ExtractTemporaryFile('wintb.dll');
Win7TaskBar11();
end;
without any external plugin or dll, it can be solved by this trick:
[Code]
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongW#user32.dll stdcall';
function GetWindowLong(Wnd: HWnd; Index: Integer): Longint; external 'GetWindowLongA#user32.dll stdcall';
Function GetWindow (HWND: Longint; uCmd: cardinal): Longint;external 'GetWindow#user32.dll stdcall';
procedure InitializeWizard();
begin
SetWindowLong(WizardForm.Handle, -8,GetWindowLong(GetWindow(WizardForm.Handle, 4),-8));
end;

Delphi Firemonkey does not display fonts correctly

I'm building cross-platform desktop app with additional font (Abilene). On startup I check is the font installed and if it is not, I install it and use it. For Mac everything seems to be fine, but Windows version (and the IDE!!) does not display the font correctly. Here is the font installation procedure:
procedure InstallFont;
const
REG_NT = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts';
var
Reg: TRegistry;
res: Boolean;
installName,FileName: UnicodeString;
begin
Reg := TRegistry.Create(KEY_ALL_ACCESS);
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
res := Reg.OpenKey(REG_NT, False);
if not Res then Exit;
installName := 'Abilene Regular (TrueType)';
FileName:=ExtractFilePath(ParamCount(0)+'\Abilene.ttf';
Reg.WriteString(installName, FileName);
Reg.CloseKey;
finally
Reg.Free;
end;
AddFontResourceW(PWideChar(FileName));
SendMessage(HWND_BROADCAST, WM_FONTCHANGE,0,0);
end;
After installing the font it is displayed as shortcut in the Control panel, but all other programs can use it. Even Delphi can, but with VCL, not FMX applications (see attached pictures). I've attached pictures from the IDE. In the runtime it's the same.
Is there anything that must be done additionally for the font installation especially for FMX apps? Or this is just a bug which must be reported to Embarcaderro QC?
Edit: Adding some details: If I install the font by downloading it, clicking with the right mouse button and choose 'Install' then everything is OK. If I install it by my proc then the font is visible and usable for the whole world except the Delphi FMX. Delphi VCL can use it also. To test this I install ed the font with my proc in my %APPDATA% folder. Word, Excel, Delphi VCL can use it. Delphi FMX cannot.
Edit2: Added SendMessage(HWND_BROADCAST, WM_FONTCHANGE,0,0). No change.
Edit3: In the Font dialog the font is displayed correctly (image 3)
Obviously this is some sort of bug, because I've found a workaround: if I first copy the font to %windir%\Fonts folder then everything is OK. Even if I made a subfolder of the \windows\fonts folder and copy the font in it everything is fine also.
Why Firemonkey does not want to display fonts outside that folder I have no idea. And, as I said, this is for Windows only. Mac OS is OK (I use ~/Library/Fonts).

How to solve TPrintDialog not saving settings?

I'm using TPrintDialog in an application, before printing, I prompt the user with the dialog, the user changes whatever settings s/he wants and then clicks OK.
The trouble is, when the application is closed and relaunched, the page size is not the same as previously selected(Letter) but set to A4 -- is this a windows issue? this happens on Windows XP SP3(32bit), on Windows 7 Ultimate(64bit) the reverse happens, by default, page size "Letter" is selected and if the user selects A4 and closes the application, relaunch, "Letter" is selected.
The OS does nothing to persist printer settings for applications, it only keeps default settings. Likewise, the VCL shows no effort on this regard. The first time a printer is needed after the application is launched, it retrieves the default settings for that particular printer. So you need to implement your way of saving and applying settings.
Here's some simple code that would set the paper type to 'Letter' before showing the print dialog:
var
Device: array[0..540] of Char;
Driver, Port: array[0..1] of Char;
DevMode: THandle;
PDevMode: PDeviceMode;
begin
Printer.GetPrinter(Device, Driver, Port, DevMode);
PDevMode := GlobalLock(DevMode);
PDevMode.dmPaperSize := DMPAPER_LETTER;
Printer.SetPrinter(Device, Driver, Port, DevMode);
GlobalUnlock(DevMode);
PrintDialog1.Execute();
end;
Similarly you can get the paper type or other settings from a DeviceMode structure and save them to registry f.i. while closing the application for later use.

How to tell if a Windows folder has content-indexing enabled?

I am looking for a Windows API that I can call from Delphi 2010 which will allow my application to determine if a specific folder has content-indexing enabled. In other words whether there is a tick in the checkbox named 'Allow files in this folder to have contents indexed in addition to file properties' which is in the Advanced Attributes page of the Property dialog when you right-click the folder. I cannot find much about this on MSDN, but maybe I am not looking in the right places.
function IsFolderIndexed(const folderName: string): boolean;
begin
Result := (GetFileAttributes(folderName) AND $2000) = 0;
end;
Ref: http://msdn.microsoft.com/en-us/library/ee332330(VS.85).aspx

Vista focus issue when invoking Microsoft Word spell check from Oracle Forms

Friends,
In testing our Oracle Forms application on Vista I have found a interesting "challenge".
The application can invoke the Microsoft Word spell checker to perform a spell check on a field. When invoked, the user is shown the standard Microsoft Word spell checker dialog window. Word itself is invisble to the user.
The Spell Checker is invoked from Forms using Automation and the method used is based on the metalink note: 295449.1 How To Integrate The MS Word Spell Checker With Forms Using WebUtil.
This has worked well when invoked using Windows XP and Office 2003.
However when this same (unchanged) functionality is run on Vista, the Microsoft Word Spell Checker dialog window appears behind the browser window so to the user it appears that nothing has happened and the functionality isn't working(There is no indication on the Vista taskbar that spell checker has been invoked)
The problem occurs on Vista with Office 2007 and Office 2003. I can see that the problem is caused by Vista because if I use the same url used to launch the Forms application on WindowsXP, the Microsoft Word Spell Checker dialog window appears as expected, which is in front.
Within Vista I have tried setting the compatability mode for Office to Windows XP SP2 but the problem remains.
I have also tried explicitly setting ACTIVATE (as you can see from the sample code below) but without success.
Has anyone else run in to this? Any help or pointers to where others have experienced this problem would be gratefully received!
My environment details are:
Environment Details
Oracle Forms: 10.1.2.3
JRE: Sun JRE 1.6.0_14
Database: 10.2.0.3
Vista: Business Edition with Service Pack 1
Office: 2003 or 2007
The code (which needs to go in a client side Oracle) used to invoke the spell checker is:
PROCEDURE SPELL_CHECK (ITEM_NAME IN VARCHAR2) IS
MY_APPLICATION CLIENT_OLE2.OBJ_TYPE;
MY_DOCUMENTS CLIENT_OLE2.OBJ_TYPE;
MY_DOCUMENT CLIENT_OLE2.OBJ_TYPE;
MY_SELECTION CLIENT_OLE2.OBJ_TYPE;
GET_SPELL CLIENT_OLE2.OBJ_TYPE;
MY_SPELL CLIENT_OLE2.OBJ_TYPE;
ARGS CLIENT_OLE2.LIST_TYPE;
SPELL_CHECKED VARCHAR2(4000);
ORIG_TEXT VARCHAR2(4000);
BEGIN
ORIG_TEXT := ITEM_NAME;
-- CREATE WORD.APPLICATION OBJECT
MY_APPLICATION := CLIENT_OLE2.CREATE_OBJ('WORD.APPLICATION');
--CLIENT_OLE2.SET_PROPERTY(MY_APPLICATION, 'VISIBLE', FALSE);
CLIENT_OLE2.SET_PROPERTY(MY_APPLICATION, 'VISIBLE', TRUE);
--CLIENT_OLE2.INVOKE(MY_APPLICATION, 'ACTIVATE');
-- GET HANDLE FOR DOCUMENTS COLLECTION
MY_DOCUMENTS := CLIENT_OLE2.GET_OBJ_PROPERTY(MY_APPLICATION, 'DOCUMENTS');
-- ADD A NEW DOCUMENT TO THE DOCUMENTS COLLECTION
MY_DOCUMENT := CLIENT_OLE2.INVOKE_OBJ(MY_DOCUMENTS, 'ADD');
-- GET HANDLE FOR SELECTION OBJECT
MY_SELECTION := CLIENT_OLE2.GET_OBJ_PROPERTY(MY_APPLICATION, 'SELECTION');
-- INSERT THE TEXT FIELD INTO DOCUMENT
CLIENT_OLE2.SET_PROPERTY(MY_SELECTION, 'TEXT', ORIG_TEXT);
-- GET HANDLE FOR ACTIVE DOCUMENT
GET_SPELL := CLIENT_OLE2.GET_OBJ_PROPERTY(MY_APPLICATION, 'ACTIVEDOCUMENT');
-- INVOKE SPELL CHECKER
CLIENT_OLE2.INVOKE(GET_SPELL, 'CHECKSPELLING');
CLIENT_OLE2.INVOKE(MY_APPLICATION, 'ACTIVATE');
-- Added to handle a cancel request.
CLIENT_OLE2.INVOKE(MY_SELECTION,'WholeStory');
CLIENT_OLE2.INVOKE(MY_SELECTION,'Copy');
-- GET CHECKED TEXT FROM DOCUMENT
SPELL_CHECKED := CLIENT_OLE2.GET_CHAR_PROPERTY(MY_SELECTION, 'TEXT');
-- REFORMAT RETURN TEXT TO DISPLAY CORRECTLY IN FORMS
SPELL_CHECKED := substr(replace(SPELL_CHECKED,chr(13),chr(10)), 1, length(SPELL_CHECKED));
-- COPY NEW TEXT IN THE FORM
COPY(SPELL_CHECKED,ITEM_NAME);
-- CLOSE THE DOCUMENT WITHOUT SAVING
ARGS := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(ARGS, 0);
CLIENT_OLE2.INVOKE(MY_DOCUMENT, 'CLOSE',ARGS);
CLIENT_OLE2.DESTROY_ARGLIST(ARGS);
-- RELEASE THE OLE OBJECTS
CLIENT_OLE2.RELEASE_OBJ(MY_SELECTION);
CLIENT_OLE2.RELEASE_OBJ(GET_SPELL);
CLIENT_OLE2.RELEASE_OBJ(MY_DOCUMENT);
CLIENT_OLE2.RELEASE_OBJ(MY_DOCUMENTS);
CLIENT_OLE2.INVOKE(MY_APPLICATION, 'QUIT');
CLIENT_OLE2.RELEASE_OBJ(MY_APPLICATION);
END;
EDIT: 10/08/2009
This link http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23085081.html details the same problem (but this time instead of oracle forms controlling word, it's ms access) Unfortunately I can't see the answer(if there is one that is!)
EDIT: 12/08/2009
All the link to expert-exchange states is that this is a vista problem - like I didn't know that!
Looks like this can't be solved using Automation\OLE alone, this thread notes there is a problem with the activate method within OLE\Automation and Vista.
The way round it is to call the windows api to manipulate the windows.

Resources