How prevent href title attribute show over transparent Form? - delphi

I have these two code that makes a Form transparent.
Form1.AlphaBlend := True;
SetWindowLong(Form1.Handle, GWL_EXSTYLE, GetWindowLong(Form1.Handle,GWL_EXSTYLE) or WS_EX_TRANSPARENT or WS_EX_LAYERED);
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
// AlphaBlend := True;
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST or WS_EX_TRANSPARENT;
Params.ExStyle := WS_EX_TRANSPARENT or WS_EX_TOPMOST;
end;
When mouse is over a link with a title attribute, this appear over transparent Form. How prevent this behavior?

Related

Delphi 5 transparency breaks child draw

I have a control in Delphi 5 like this (following this post: https://tips.delphidabbler.com/tips/74.html):
type
TTransparentGroupbox = class(TGroupBox)
protected
procedure CreateParams(var params: TCreateParams); override;
procedure WMEraseBkGnd(var msg: TWMEraseBkGnd); message WM_ERASEBKGND;
end;
.....
procedure TTransparentGroupbox.CreateParams(var params: TCreateParams);
begin
inherited CreateParams(params);
params.ExStyle := params.ExStyle or WS_EX_TRANSPARENT;
end;
procedure TTransparentGroupbox.WMEraseBkGnd(var msg: TWMEraseBkGnd);
begin
SetBkMode(msg.DC, TRANSPARENT);
msg.result := 1;
end;
But I have trouble when it is redrawn. The portion not blurred should be listbox on such a TTransparentGroupbox, but it is not entirely redrawn, as if the background mode would have been propagated to the children but they are repainted on the TWinControl level. I have tried to set it back to OPAQUE at the only point I could override, but with no success:
procedure TTransparentGroupbox.PaintWindow(DC: HDC);
begin
SetBkMode(DC, OPAQUE);
inherited;
end;
The annoying part is, that I have other TTransparentGroupbox instances, with other TListBox instances that do not behave in this way.
The second problem I have is that whenever the visibility of a child control is changed to false, it is not "erased".

Delphi resizable bsDialog Form?

How can I make a Form (ShowModal) with BorderStyle bsDialog. but one that could still be resized and have the close button (without the Icon,Minimize, Maximize)?
I do not need it to show the size grip.
Here is my solution which seems to work OK:
type
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
private
protected
procedure CreateWnd; override;
procedure CreateParams(var Params: TCreateParams); override;
public
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
procedure TForm2.FormCreate(Sender: TObject);
begin
BorderIcons := [biSystemMenu];
BorderStyle := bsSizeable;
AutoScroll := False;
end;
procedure TForm2.CreateWnd;
begin
inherited;
SendMessage(Handle, WM_SETICON, 1, 0);
end;
procedure TForm2.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
end;
IMO, This cant be done with bsDialog but the above feels and looks just like a "bsDialog" which could be resized.
Set the BorderStyle to bsSizeToolWin.

How to pull a MDI child window out of the main form?

I want to create a MDI application with it's own task bar so the user can have fast access to the child windows he/she wants to bring to front. Then I had the idea that an user who works with two or more monitors could drag on of the child windows from inside the main form of my application into outside of it, into another monitor for example.
How can it be done?
Maybe this example MDI client form code serves inspiration:
unit Unit3;
interface
uses
Windows, Messages, Controls, Forms;
type
TForm3 = class(TForm)
private
FSizing: Boolean;
procedure WMNCMouseLeave(var Message: TMessage);
message WM_NCMOUSELEAVE;
procedure WMWindowPosChanged(var Message: TWMWindowPosChanged);
message WM_WINDOWPOSCHANGED;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure Resize; override;
end;
implementation
{$R *.dfm}
{ TForm3 }
var
FDragging: Boolean = False;
procedure TForm3.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if FormStyle = fsNormal then
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW
else
Params.ExStyle := Params.ExStyle and not WS_EX_APPWINDOW;
end;
procedure TForm3.Resize;
begin
inherited Resize;
FSizing := True;
end;
procedure TForm3.WMNCMouseLeave(var Message: TMessage);
begin
inherited;
FDragging := False;
end;
procedure TForm3.WMWindowPosChanged(var Message: TWMWindowPosChanged);
var
P: TPoint;
F: TCustomForm;
R: TRect;
begin
inherited;
if not FDragging and not FSizing and not (fsShowing in FormState) and
(WindowState = wsNormal) then
begin
F := Application.MainForm;
P := F.ScreenToClient(Mouse.CursorPos);
R := F.ClientRect;
InflateRect(R, -5, -5);
if not PtInRect(R, P) and (FormStyle = fsMDIChild) then
begin
FDragging := True;
FormStyle := fsNormal;
Top := Top + F.Top;
Left := Left + F.Left;
end
else if PtInRect(R, P) and (FormStyle = fsNormal) then
begin
FDragging := True;
FormStyle := fsMDIChild;
end;
end;
FSizing := False;
end;
end.

How to remove the title bar from a form

Does anyone know how to create a Delphi form without a title bar? I have seen some some links/tips but its not exactly what I want and I couldn't do it myself.
This is what I am trying to achieve:
First, set BorderStyle to bsNone at design-time. Then declare the procedure CreateParams like so:
type
TForm1 = class(TForm)
private
protected
procedure CreateParams(var Params: TCreateParams); override; // ADD THIS LINE!
{ Private declarations }
public
{ Public declarations }
end;
and implement it like
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_THICKFRAME;
end;
Set BorderStyle to bsNone in Object Inspector
For better border style, you can add the WS_BORDER flag.
Like this:
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_BORDER or WS_THICKFRAME;
end;
Note than a soft line is drawn inside the border frame.

Right to left text in delphi trayicon BaloonHint

Is there a way to align text right in the delphi trayicon BaloonHint?
You would need to use your own hint window
type
TRTLHint = class(THintWindow)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
procedure TRTLHint.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle or WS_EX_LAYOUTRTL;
end;
You can then use this TRTLHint in this way.

Resources