THE VANNI'S TIPS & TRICKS PAGE


Click here to e-mail me

 

bersaglio.gif (5157 byte) In this page you can find several tips & tricks made by myself.
Tips are divided by Begginer Tips or Advanced Tips

This page was created by Brutto Vanni








This are tips dedicated to people who haven't experince with Delphi 2.0.

Several of these questions were made from people who coded with Visual Basic.


1. What is the easiest way to change the control menu of a form based application?

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure WmSysCommand(var Msg: TWmSysCommand); message WM_SYSCOMMAND;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var hSysMenu: hMenu;
begin
  hSysMenu := GetSystemMenu(handle, False);

  AppendMenu(hSysMenu, MF_SEPARATOR, 0, '');
  AppendMenu(hSysMenu, MF_STRING, $200, 'Always on Top');
end;

procedure TForm1.WmSysCommand(var Msg: TWmSysCommand);
begin
  inherited ;

  If Msg.CmdType = $200 Then Begin
    ShowMessage('Always on top pressed');
  End;
end;

end.







This are tips dedicated to people that know how to use Delphi.



1. There's a project that show how to rotate a text!!!

If you're looking for a way of how to rotate a text eith this project you will learn how to manipolate TFont Object for this usefull function!



2. Here you find a project that link in his exe wave files!

Yes, with resource usage you can include in an application executable all file that you need and load them directly into memory! This project use a .res file compiled with BRCC32.EXE (Borland Recource Compiler, look into your bin Delphi dir). Also text file are linked! Enjoy IT!



3. How to make a Control Panel applet?

Solution: DOWNLOAD THIS SAMPLE!!!!
It's very easy to understand, i think that this project will solve yours problem ;-)



4. How to include in a Status Bar a Progress Bar?

Solution: DOWNLOAD THIS SAMPLE!!!!



5. What about drawing disable bitmap?

This was a problem that involved me recently, luckly i've found this proc in TExplorerButton component (see in DSP). I trust that the author doesn't angry :-))

procedure DrawDisabledBitmap(Canvas: TCanvas; x, y: Integer; bmp: TBitmap);
(* This code come from
* TExplorerButton component version 2.4
* (c)1996 Fabrice Deville
* fdev@tornado.be
* http://www.tornado.be/~fdev/
*)
var MonoBmp: TBitmap;
begin
  MonoBmp := TBitmap.Create;
  try
    MonoBmp.Assign(bmp);
    MonoBmp.Canvas.Brush.Color := clBlack;
    MonoBmp.Monochrome := True;
    Canvas.Brush.Color := clBtnHighlight;
    SetTextColor(Canvas.Handle, clBlack);
    SetBkColor(Canvas.Handle, clWhite);
    BitBlt(Canvas.Handle, x+1, y+1, bmp.Width, bmp.Height,
    MonoBmp.Canvas.Handle, 0, 0, $00E20746);
    Canvas.Brush.Color := clBtnShadow;
    SetTextColor(Canvas.Handle, clBlack);
    SetBkColor(Canvas.Handle, clWhite);
    BitBlt(Canvas.Handle, x, y, bmp.Width, bmp.Height,
           MonoBmp.Canvas.Handle, 0, 0, $00E20746);
  finally
    MonoBmp.Free;
  end
end;



6. The easyst way to make cool Menu (like Office '97) ?

The easyst way? Use my component!
Click here to download TAdvMenu.
Click here to see the TAdvMenu page.



7. Can i popup start menu with code?

Sure! Try this code...

procedure TForm1.Button1Click(Sender: TObject);
var hwnd,
    hwndchild: Integer;
begin
  // Get the taskbar handle
  hwnd:= FindWindowEx(0, 0, 'Shell_TrayWnd', '');
  // Get the Start button handle
  hwndChild:= FindWindowEx(hwnd, 0, 'button', '');
  // Just to test i press the button ;-)
  SendMessage(hwndChild, WM_LBUTTONDOWN, 0, 0);
end;



8. How to check if Delphi is running?

if ((FindWindow('TApplication', 'Delphi 3') <> 0) and (FindWindow('TPropertyInspector', nil) <> 0)) then //...



9. What about getting the IP number of an Internet connection?

Try the following sample!!!!