procedure TForm1.Label1Click (Sender : TObject)
begin
ShellExecute (0, nil, 'http://1www.scriptmania.com', nil, nil, SW_SHOWNORMAL);
end;
Back to Delphi Tips and Tricks
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, MMSystem;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure WndProc(var Message : TMessage); override;
public
{ Public declarations }
end;
var
Form1: TForm1;
FSoundFile : String;
implementation
{$R *.DFM}
procedure TForm1.WndProc(var Message : TMessage);
begin
if Message.LParam = Longint(Button1) then
begin
if (Message.Msg = CM_MOUSELEAVE) then
sndPlaySound(nil, snd_Async or snd_NoDefault);
if (Message.Msg = CM_MOUSEENTER) then
sndPlaySound(pchar(FSoundFile), snd_Async or snd_NoDefault);
end;
inherited WndProc(Message);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FSoundFile := 'C:\Windows\Media\Ding.wav';
end;
end.
Back to Delphi Tips and Tricksprocedure SetRes(XRes, YRes: DWord); var lpDevMode : TDeviceMode; begin EnumDisplaySettings(nil, 0, lpDevMode); lpDevMode.dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT; lpDevMode.dmPelsWidth:=XRes; lpDevMode.dmPelsHeight:=YRes; ChangeDisplaySettings(lpDevMode, 0); end;Back to Delphi Tips and Tricks
procedure TForm1.FormCreate(Sender: TObject); begin Form1.Brush.Style:=bsClear; Form1.BorderStyle:=bsNone; end;If you use only that you will notice that the form is transparent but if you put something over it, it will not clear its own background and traces of that object will be left on the form. To solve that you need to make sure that the transparent form's Paint procedure (WM_PAINT) will be called last. To do that you need to override the TWinControl (TForm's ancestor) CreateParams procedure and set the Form's extended style (ExStyle) to WS_EX_TRANSPARENT. Here's the full code for making a form transparent:
type
TForm1 = class(TForm)
procedure CreateParams(var Params:TCreateParams); override;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.CreateParams(var Params:TCreateParams);
Begin
inherited CreateParams(Params);
Params.ExStyle:=WS_EX_TRANSPARENT;
End;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Brush.Style:=bsClear;
Form1.BorderStyle:=bsNone;
end;
Back to Delphi Tips and Tricksvar wndClass: Array[0..50] of Char; wndHandle: THandle;1. We need the TaskBar-class:
StrPCopy(@wndClass[0], 'Shell_TrayWnd')2. We need the TaskBar-handle:
wndHandle := FindWindow(@wndClass[0], nil)3. Now we can simply show/hide the Taskbar:
Show: ShowWindow(wndHandle, SW_SHOW) Hide: ShowWindow(wndHandle, SW_HIDE)That's all...
type
TForm1 = class (TForm)
private
{ Private Declarations }
public
{ Public Declarations }
procedure WMNCHitTest (var M: TWMNCHitTest);
message wm_NCHitTest;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCHitTest (var M: TWMNCHitTest);
begin
inherited;
if M.Result = htClient then
M.Result := htCaption;
end;
end.
Back to Delphi Tips and Tricks