Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

Powered By :

Delphi Pages...

Delphi Components | Delphi Tips and Tricks | Delphi Official WebPage


Delphi Components
Back to top

TrayIcon : Show Icon in System Tray.
Scrolling Caption : Scroll the Form Caption.
Cool Form : Use Bitmap as the shape of your form.
Mp3 Info : Extract and Save MP3 ID Tag.
Gradient Button : Make gradient button.
Axt Flame : Make Flame very easy.
Exit Windows : Use this component to exit window.
Animated Objects : Make animations with sound.
JPEG Image : Display JPEG Image.
GIF Image : Display GIF Image.

Delphi Tips and Tricks
Back to top

Making HyperLink
Play Sound on mouse enter
How to set the screen resolution
Making transparent forms
Hide the taskbar
Moving form without caption

Making HyperLink
Add ShellApi in uses... and use this procedure to make a hyperlink :
procedure TForm1.Label1Click (Sender : TObject)
  begin
    ShellExecute (0, nil, 'http://1www.scriptmania.com', nil, nil, SW_SHOWNORMAL);
  end;
Back to Delphi Tips and Tricks

Play Sound on mouse enter
You've seen those installs that play sounds when you mouse over a button, this is all you have to do
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 Tricks

How to set the screen resolution.
Here's the code...
procedure 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

Making Transparent forms
To make a form transparent you should put these 2 lines in form's creation procedure:
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 Tricks

Hide the taskbar
If you need to hide the Windows-Taskbar for your application you need to follow this steps:
var
  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...

Back to Delphi Tips and Tricks

Moving form without caption
Follow the codes bellow...
    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


Delphi Components | Delphi Tips and Tricks | Delphi Official WebPage