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:
Related
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.
I have a child form 'frmTest' and a main form 'TfrmMain'. I set the main form as parent for frmTest like this:
unit Main;
INTERFACE
USES
System.SysUtils, System.Classes, Vcl.Forms, Test, Vcl.StdCtrls, Vcl.Controls;
type
TfrmMain = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
IMPLEMENTATION {$R *.dfm}
procedure TfrmMain.Button1Click(Sender: TObject);
VAR frmTest: TChildForm;
begin
Application.CreateForm(TChildForm, frmTest);
//frmTest:= TForm1.Create(Self);
frmTest.Parent:= Self;
frmTest.Show;
frmTest.SetFocus;
end;
unit test; { THIS IS THE CHILD }
INTERFACE
USES
System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Samples.Spin;
TYPE
TChildForm = class(TForm)
Edit1: TEdit;
SpinEdit1: TSpinEdit;
private
public
end;
IMPLEMENTATION {$R *.dfm}
end.
Code as ZIP
But controls (edit box, spin edit, etc) in frmInsertImg will not accept focus from mouse but can be focused with Tab.
What am I doing wrong?
I suggest that you set BorderStyle to bsNone for the child form. I'm not sure of the exact reasons why this works, but it has the desired effect.
If you need to add a visual frame for your child form then that is best done with explicit UI for the contained of your child form.
Forms aren't really intended to be used in this way, in my opinion. You can make things mostly work, but it's not terribly robust. Putting the UI into a frame and then hosting that should lead to better behaviour.
I want load a image that will be the background of a maximized Form that stays in a dll.
The dll is called from a Vcl Form Application but have a trouble where not is possible load the background image on Form, the dll always crashes.
Thank you by you help.
===========================================================================
Executable
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)
btn1: TButton;
procedure btn1Click(Sender: TObject);
end;
var
Form2: TForm2;
implementation {$R *.dfm}
procedure LoadDLL;
type
TShowformPtr = procedure; stdcall;
var
HDLL: THandle;
Recv: TShowformPtr;
begin
HDLL := LoadLibrary('lib.dll');
if HDLL <> 0 then
begin
#Recv := GetProcAddress(HDLL, 'Recv');
if #Recv <> nil then
Recv;
end;
//FreeLibrary(HDLL);
end;
procedure TForm2.btn1Click(Sender: TObject);
begin
LoadDLL;
end;
end.
Dll
Main:
library Project2;
uses
SysUtils, Classes, Unit1, Unit2;
{$R *.res}
procedure Recv; stdcall;
begin
showform;
end;
exports
Recv;
begin
end.
Unit1 (Form):
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
img1: TImage;
pnl1: TPanel;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.WndParent:= Application.Handle;
Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST or WS_EX_TRANSPARENT;
Params.ExStyle := WS_EX_TRANSPARENT or WS_EX_TOPMOST;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
brush.Style := bsclear;
img1.Picture.LoadFromFile(IncludeTrailingBackslash(GetCurrentDir) + 'background.bmp');
SetWindowPos(Form1.handle, HWND_TOPMOST, Form1.Left, Form1.Top, Form1.Width,
Form1.Height, 0);
ShowWindow(Application.handle, SW_HIDE);
pnl1.Top := (self.Height div 2) - (pnl1.Height div 2);
pnl1.Left := (self.Width div 2) - (pnl1.Width div 2);
end;
end.
Unit2:
unit Unit2;
interface
Uses
windows,
Unit1,
SysUtils;
procedure showform;
implementation
procedure showform;
begin
Form1 := TForm1.Create(Form1);
sleep(100);
Form1.Show;
Form1.Pnl1.Visible := True;
end;
end.
Your question has a lot of problems, so I would try to answer it as best I can, considering the lack of details.
You are using forms so you are building a VCL application. You need to let the IDE assign the VCL framework to your project.
This line is terribly wrong:
Form1 := TForm1.Create(Form1);
In rare circumstances show a from own itself. I would go and say that most probably this is why your application crashes. See this for details about forms in DLLs.
If you cannot properly debug your application put a beep before that line and one after (make a delay between them).
I think your question should be rather called "how to debug a Delphi project".
What you need to do is to get the exact line on which the program crashes. This will give you an insight of why the error/crash (by the way, you never shown the exact error message) appears.
Go check HadShi (recommended) or EurekaLog (buggy) or Smartinspect (I never tried it. Price is similar to the other two). Make sure that you are running in debug mode, the Integrated debugger is on (see IDE options) and that the debug information is present in your EXE/DLL.
PS: you can still debug your app without have one of the three loggers shown above. Just configure your project properly to run in Debug mode!
To debug the DLL see the 'Run->Parameters' menu. Define there a host application that will load your DLL. If the error is the DLL, the debugger will take control and put the cursor to the line of code that generated the crash.
I don't know what the final purpose/what is that you want to achieve. Because of this I must warn you that you might need to take into consideration these questions:
Do you need to use ShareMM?
Why are you building this as a DLL? Can't the application be written as a single EXE? Or two EXEs that communicate with each other?
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');
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: