How to change font size of Delphi XE6 IDE - delphi

How can i change the font size of the IDE itself of Delphi XE6.
The IDE's dialogs are not using my Windows font preference, and i cannot find any option to change the font used by the IDE.
Alternatively, how do i get Delphi XE6 to honor the user's font preferences?

You can't
The font is hardcoded. You cannot change it.
Here's what I've tried
1 - Change BDS.EXE with a HEX editor
If you open up BDS.EXE in a HEX-editor, look for TextHeight and change the values from $0D (13) to something bigger, then the altered bds.exe will look exactly the same.
2 - Use EnumChildWindows to spam the Delphi IDE with WM_SETFONT messages
You can send a WM_SETFONT message to the running Delphi main window.
You have to find the window using the FindWindow API call.
From: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632642%28v=vs.85%29.aspx
wParam
A handle to the font (HFONT). If this parameter is NULL, the control uses the default system font to draw text.
lParam
The low-order word of lParam specifies whether the control should be redrawn immediately upon setting the font. If this parameter is TRUE, the control redraws itself.
Because you want Delphi to use the default font, the message is really simple.
The Delphi XE6 main window is called TAppBuilder, so you'll have to get the handle to that Window using FindWindow.
I tried this, but it did not work.
unit Unit4;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm4 = class(TForm)
FontDialog1: TFontDialog;
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
const
DelphiWindows: array [1 .. 1] of PWideChar = ('TAppBuilder');
function EnumChildProc(const hWindow: hWnd; const hFont: LParam): boolean; stdcall;
begin
SendMessage(hWindow, WM_SETFONT, hFont, 1);
Result:= True;
end;
procedure TForm4.Button1Click(Sender: TObject);
var
BDSWindow: HWND;
ChildWindow: HWnd;
Font: HFONT;
i: Integer;
begin
if FontDialog1.Execute then begin
BDSWindow:= FindWindow(DelphiWindows[1], nil);
Font:= FontDialog1.Font.Handle;
EnumChildWindows(BDSWindow, #EnumChildProc, Font);
ShowMessage('Done');
end;
end;
end.
I have not tried the default font, because the Delphi font and the default font are the same on my system. And I don't want to change the default font.
Doing this changed 2 dropdown_boxes on my Delphi. Not a very good showing.
I posted this as an answer in the hope that you can get to a solution from here.

The best way to do that is using Delphi IDE Theme Editor, it's very simple. Try in Delphi IDE Theme Editor, preview:

Related

Is AtomicCmpExchange() broken?

If you make a new multi-device application project, set Project > Option > Compiling > Optimization : True, and then copy the code below to unit1.pas:
unit Unit1;
interface
uses
System.SysUtils,
FMX.Forms,
FMX.StdCtrls,
System.Classes,
FMX.Types,
FMX.Controls,
FMX.Controls.Presentation;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
FKey: integer;
public
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
FKey := 2;
var LCompareKey: integer := 2;
AtomicCmpExchange(FKey{target}, LCompareKey{NewValue}, LCompareKey{Comparand});
if FKey <> LCompareKey then raise Exception.Create('Error 2');
TThread.queue(nil,
procedure
begin
if LCompareKey <> FKey
then raise Exception.Create('Error 3');
end);
end;
end.
Why does this code crash on Win32 on if FKey <> LCompareKey then raise Exception.Create('Error 2');?
I'm using Delphi 10.4 Sydney Update 3. I didn't yet try in Delphi 11 Alexandria, so I don't know if it's working in that version.
Is there any workaround except deactivating the optimization?
Another question - is it really safe to activate the optimization?
Yes, codegen for AtomicCmpExchange is broken on Win32 compiler when optimization is turned on.
Problem happens in combination with anonymous method variable capture that happens in TThread.Queue call. Without variable capture, assembly code for AtomicCmpExchange is properly generated.
Workaround for the issue is using TInterlocked.CompareExchange.
...
var LCompareKey: integer := 2;
TInterlocked.CompareExchange(FKey{target}, LCompareKey{NewValue}, LCompareKey{Comparand});
if FKey <> LCompareKey then raise Exception.Create('Error 2');
...
TInterlocked.CompareExchange function still uses AtomicCmpExchange, but at place of call it works with captured variables through parameters instead of directly and generated code is correct in those situations.
class function TInterlocked.CompareExchange(var Target: Integer; Value, Comparand: Integer): Integer;
begin
Result := AtomicCmpExchange(Target, Value, Comparand);
end;
Another, less optimal solution would be turning off optimization around broken method Button1Click with {$O-} compiler directive and then turning it back on with {$O+}
Since AtomicCmpExchange is Delphi intrinsic function, its code is directly generated by compiler when it is called and bad codegen only affects that procedure, not general code - in other words anonymous method capture is working correctly in other code (unless there are other, bugs in compiler, unrelated to this particular one).
In other places in RTL where AtomicCmpExchange is used, there is no code where variable capture is involved, so RTL, VCL and FMX code is not affected by this issue and optimization can be turned on in application.
Note: There may be other optimization bugs in compiler that we don't know about.

TaskDialog not working in my Delphi Program

I am using Delphi 10.4. This is a Windows VCL Application.
I wanted to convert all my ShowMessage, MessageDlg and MessageBox calls to TaskDialogs in my program. When I tried to do that, I couldn't get TaskDialog to display anything.
So what I did was create a new minimal VCL application, simply added a button and a TaskDialog to it:
This was my code:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
TaskDialog1: TTaskDialog;
procedure MyMessageBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; 
var
Form1: TForm1;
implementation
procedure TForm1.MyMessageBox;
begin
Form1.TaskDialog1.Caption := 'My Application';
Form1.TaskDialog1.Title := 'Hello World!';
Form1.TaskDialog1.Text := 'I am a TTaskDialog, that is, a wrapper for the Task Dialog introduced ' +
'in the Microsoft Windows Vista operating system. Am I not adorable?';
Form1.TaskDialog1.CommonButtons := [tcbClose];
Form1.TaskDialog1.Execute;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MyMessageBox;
end;
{$R *.dfm}
begin
Application.Run;
end.
That worked fine. When running it and pressing Button1, I get:
So now I go to my application. I add a button to my main form, and set the MyMessageBox procedure to this:
procedure TLogoAppForm.MyMessageBox;
begin
ShowMessage('ShowMessage ......................................');
Application.MessageBox('Application.MessageBox ...........................', 'Error', 0);
MessageDlg('MessageDlg ................................', mtWarning, [mbOk], 0);
LogoAppForm.TaskDialog1.Caption := 'My Application';
LogoAppForm.TaskDialog1.Title := 'Hello World!';
LogoAppForm.TaskDialog1.Text := 'I am a TTaskDialog, that is, a wrapper for the Task Dialog introduced ' +
'in the Microsoft Windows Vista operating system. Am I not adorable?';
LogoAppForm.TaskDialog1.CommonButtons := [tcbClose];
LogoAppForm.TaskDialog1.Execute;
end;
Pressing the button in my application correctly brings up each of the ShowMessage, MessageBox and MessageDlg windows in sequence, but after closing the MessageDlg window, nothing at all appears for the TaskDialog.
Does anyone know what might be causing TaskDialog to not work in my application and how I might fix this?
You must enable runtime themes for the VCL TTaskDialog to work. Go to Project/Options/Application/Manifest to do so.

Event is not getting fired

I am trying to use the WebWorkerStarted and WebWorkerFinished from TWebbrowser however the events just don't get fired at all.
How can I get these events working? I want to see which worker threads are getting launched from TWebbrowser.
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls, SHDocVw;
type
TForm2 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1WebWorkerFinsihed(ASender: TObject; dwUniqueID: Cardinal);
procedure WebBrowser1WebWorkerStarted(ASender: TObject; dwUniqueID: Cardinal; const bstrWorkerLabel: WideString);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('www.stackoverflow.com');
end;
procedure TForm2.WebBrowser1WebWorkerFinsihed(ASender: TObject; dwUniqueID: Cardinal);
begin
// does not fire
end;
procedure TForm2.WebBrowser1WebWorkerStarted(ASender: TObject; dwUniqueID: Cardinal; const bstrWorkerLabel: WideString);
begin
// does not fire
end;
end.
As documented here :
By default, TWebBrowser uses IE7 Standards mode even if the run-time environment installed the latest IE (for example, IE11).
WebWorkers were introduced in IE10 so you must have IE running in a more current mode. At least two registry keys need to be set (more if supporting both 32/64 bit):
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
{\Wow6432Node}
\SOFTWARE
\Microsoft
\Internet Explorer
\Main
\FeatureControl
\FEATURE_BEHAVIORS
{NEW DWORD -> 'YourApplication.exe'
{ VALUE -> 1
Also (for example, IE11 mode)
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
{\Wow6432Node}
\SOFTWARE
\Microsoft
\Internet Explorer
\Main
\FeatureControl
\FEATURE_BROWSER_EMULATION
{NEW DWORD -> 'YourApplication.exe'
{ VALUE -> 0x2AF8
This will cause the internet explorer instance wraped by TWebBrowser to run in IE11 mode, supporting WebWorkers, etc. You should probably do some sort of sanity check against the installed version of IE before setting this value. More information about valid entries can be found on MSDN.
This still does not raise any WebWorker events for me when navigating to StackOverflow (are you sure it uses them?). As a verification test, this WebWorkers demo page does raise a OnWebWorkerStarted event :
WebBrowser1.Navigate('https://whatwg.org/demos/workers/primes/page.html');

godex ez2250i delphi cant print

I have a label printer GoDex EZ2250i and i found some samples with delphi but none seems to works for me i try to compile with couple of dll's and the program doesnt even launch does anyone have experience on printing with this printer with delphi? thanks in advance, also the OS should be supported Windows7 and Windows 8.
the code that i tried:
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
TestLib = 'Ezio64.dll'; // tried with Ezio32.dll same result
procedure openport(port:PChar); stdcall; external TestLib ;
procedure setup(a, b, c, d, e, f:Integer); stdcall; external TestLib;
procedure sendcommand(command:PChar); stdcall; external TestLib;
procedure intloadimage(filename, image_name, image_type:PChar); stdcall; external TestLib;
procedure extloadimage(filename, image_name, image_type:PChar); stdcall; external TestLib;
procedure ecTextOut(x:Integer; y:Integer; b:Integer; c:PChar; d:PChar); stdcall; external TestLib;
procedure closeport; stdcall; external TestLib;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
openport('0'); // 0-> LPT1; 1-> COM1; 2->COM2
setup(30, 7, 2, 1, 0, 0);
sendcommand('W70');
sendcommand('^P1');
sendcommand('^L');
sendcommand('AC,20,60,1,1,1,0,TEST');
ecTextOut(20, 10, 34, 'Ariel', 'Windows font - Ariel');
sendcommand('E');
closeport();
end;
end.
The program doesn't even launch.
This is symptomatic of a loader failure. For some reason, under the Delphi debugger, loader failures are not reported.
A loader failure typically occurs when:
A dependent DLL cannot be found, or,
A dependent DLL is found, but cannot be loaded, or,
A dependent DLL is loaded, but the imported functions cannot be found within.
To get more diagnostics run the executable outside of the debugger. Quite possibly you are trying to load 64 bit DLLs into your 32 bit process.
If diagnosis proves tricky, go back to the documentation for the library. Make sure you have installed all pre-requisites. Another common failure mode is a missing C++ runtime.
As a last resort, use Dependency Walker. Use the 32 bit version, and execute you program under Profile mode. This will pin-point the dependency failure.

Delphi: Alternative to JEDI Desktop Alert (balloon)

Is there a good analogue/equivalent to JEDI Desktop Alert (a kind of a balloon in the right bottom corner of a desktop)?
Balloon hint cannot be showed like a stack (a new hint is on the top of others), but JEDI Desktop Alert can do it.
May be some one knows, why does a show event of that component fire twice instead of once? :)
Thank your for suggestions!
This might be a bit late, but below is a basic example of showing 5 stacked alert windows on top of each other in bottom right corner, using Jedi Desktop Alert.
unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
JvDesktopAlert;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure AddAlert(title, text: String; stack: TjvDesktopAlertStack);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.AddAlert(title, text: String; stack: TjvDesktopAlertStack);
Begin
with TJvDesktopAlert.Create(self) do
Begin
AutoFree := true;
AlertStack := stack;
HeaderText := title;
MessageText := text;
Execute(self.Handle);
End;
End;
procedure TForm1.Button1Click(Sender: TObject);
var
stack: TjvDesktopAlertStack;
begin
stack := TJvDesktopAlertStack.Create(self);
try
AddAlert('title1', 'message1', stack);
AddAlert('title2', 'message2', stack);
AddAlert('title3', 'message3', stack);
AddAlert('title4', 'message4', stack);
AddAlert('title5', 'message5', stack);
finally
stack.Free;
end;
end;
end.
TMS Software has TAdvAlertWindow, an "Outlook 2003, 2007 style alert window".
It's a commercial component, available separately or as part of the TMS Component Pack.
Update: The above image was taken from TMS website. As Andreas has pointed the font is not antialiased (it's a bitmapped font, probably MS Sans Serif). I've tested the trial version of the component and setting the font to Tahoma works as expected:

Resources