INDODELPHI

Blog’s Tutorial Delphi – Reference from Onez Delphi Explorer

ADD A BUTTON TO THE INTERNET EXPLORER TOOLBAR

// ******************************************************************
// ADD A BUTTON TO THE INTERNET EXPLORER TOOLBAR
// Category        : Browsers
// Author          : Dave
// Author Email    :
// Author Web      :
// Tips Website    : Swiss Delphi Center
// Tips Website URL: http://www.swissdelphicenter.ch
// ******************************************************************

{
This is a simple little example that allows you to add a button
to Internet Explorer 3.0 or above
Values:
ButtonText := The text you want to be displayed at the bottom of the button
MenuText := The tools option at the top of IE will now contain
a reference to your program.
MenuStatusbar := Script option we are not using this object. (Ignore)
CLSID := Your classID. I won`t explain it because its complex.
That it has to unique. You can use GUIDTOSTRING
To create a new CLSID with the unit ActiveX.

Default Visible := Display it.
Exec := Your program path to execute.
Hoticon := (Mouse Over Event) ImageIndex in shell32.dll i’ve picked 4
Icon := I’ve selected to display shell32.dll image 4.
}

procedure CreateExplorerButton(Path: string);
const
Tagit = ‘\{10954C80-4F0F-11d3-B17C-00C0DFE39736}\’;
var
Reg: TRegistry;
Path1: string;
Merge: string;
begin
Path := ‘c:\your_program_path’;
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
Path1 := ‘Software\Microsoft\Internet Explorer\Extensions’;
Merge := Path1 + Tagit;
OpenKey(Merge, True);
WriteString(‘ButtonText’, ‘ButtonText’);
WriteString(‘MenuText’, ‘Tools Menu Item’);
WriteString(‘MenuStatusBar’, ‘Run Script’);
WriteString(‘ClSid’, ‘{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}’);
WriteString(‘Default Visible’, ‘Yes’);
WriteString(‘Exec’, Path + ‘\ProgramName.exe’);
WriteString(‘HotIcon’, ‘,4′);
WriteString(‘Icon’, ‘,4′);
end
finally
Reg.CloseKey;
Reg.Free;
end;
end;

October 28, 2007 Posted by maulaku | Browser | | No Comments Yet

EXECUTE A PROGRAM AND HAVE MY CODE WAIT UNTIL IT IS FINISHED

// ******************************************************************
// EXECUTE A PROGRAM AND HAVE MY CODE WAIT UNTIL IT IS FINISHED
// Category        : Task
// Author          : Gustav Evertsson
// Author Email    :
// Author Web      :
// Tips Website    : DelphiTips.com
// Tips Website URL: http://www.delphitips.com
// ******************************************************************

uses Wintypes,WinProcs,Toolhelp,Classes,Forms;

Function WinExecAndWait(Path : string; Visibility : word) : word;
var
InstanceID : THandle;
PathLen : integer;
begin
// inplace conversion of a String to a PChar
PathLen := Length(Path);
Move(Path[1],Path[0],PathLen);
Path[PathLen] := #0;
// Try to run the application
InstanceID := WinExec(@Path,Visibility);
if InstanceID < 32 then    // a value less than 32 indicates an Exec error
WinExecAndWait := InstanceID
else
begin
Repeat
Application.ProcessMessages;
until Application.Terminated or (GetModuleUsage(InstanceID) = 0);
WinExecAndWait := 32;
end;
end;

October 28, 2007 Posted by maulaku | Application - Task | | No Comments Yet

CHANGE MDI PARENT BACKGROUND

// ******************************************************************
// CHANGE MDI PARENT BACKGROUND
// Category        : MDI
// Author          : Greatis Software
// Author Email    :
// Author Web      : www.greatissoftware.com
// Tips Website    : Greatis Software
// Tips Website URL: http://www.greatis.com/delphi/tips.html
// ******************************************************************

{
The decision consists in interception of the WM_ERASEBKGND, WM_VSCROLL and
WM_HSCROLL messages and is carried out draw of area with the DrawImage procedure
or InvalidateRect procedure.
In procedure CreateWnd is used SetWindowLong procedure for installation of new
procedure of a window.
Don’t forget to remove line
Application.CreateForm(TForm2, Form2) from project file and line
var Form2: TForm2 from unit2.pas file.
}

type
TForm1 = class(TForm)
//  …
private
{ Private declarations }
public
procedure ClientWndProc(var Message: TMessage);
procedure DrawImage;
{ Public declarations }
protected
procedure CreateWnd; override;
end;

var
Form1: TForm1;
NewClient, OldClient: TFarProc;
MyDC: hDC;

implementation

uses unit2;

{$R *.DFM}

procedure TForm1.CreateWnd;
begin
inherited CreateWnd;
NewClient:=MakeObjectInstance(ClientWndProc);
OldClient:=Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(NewClient));
end;

procedure TForm1.DrawImage;
{ This procedure tiles the image on the form’s client area }
var
i, j: Integer;
WndRect, ImageRect: TRect;
Rows, Cols: Integer;
begin
GetWindowRect(ClientHandle, WndRect);
ImageRect:=Image1.ClientRect;
Rows:=WndRect.Bottom div ImageRect.Bottom;
Cols:=WndRect.Right div ImageRect.Right;
with Image1 do
for i:=0 to Rows+1 do
for j:=0 to Cols+1  do
BitBlt(MyDC,j*Picture.Width,i*Picture.Height,Picture.Width,
Picture.Height,Picture.Bitmap.Canvas.Handle,0,0,SRCCOPY);
end;

procedure TForm1.ClientWndProc(var Message: TMessage);
begin
case Message.Msg of
WM_ERASEBKGND:
begin
CallWindowProc(
OldClient,
ClientHandle,
Message.Msg,
Message.wParam,
Message.lParam);
MyDC:=TWMEraseBkGnd(Message).DC;
DrawImage;
Message.Result:=1;
end;
WM_VSCROLL,WM_HSCROLL:
begin
Message.Result:=
CallWindowProc(
OldClient,
ClientHandle,
Message.Msg,
Message.wParam,
Message.lParam);
InvalidateRect(ClientHandle,nil,True);
end;
else
Message.Result:=
CallWindowProc(
OldClient,
ClientHandle,
Message.Msg,
Message.wParam,
Message.lParam);
end;
end;

October 28, 2007 Posted by maulaku | Application - MDI | | No Comments Yet

COLOR AND TIMING OF HINTS

// ******************************************************************
// COLOR AND TIMING OF HINTS
// Category        : Hint/ToolTip
// Author          : Studiebureau Festraets
// Author Email    :
// Author Web      : http://www.festra.com/eng/index.html
// Tips Website    : Delphi Land
// Tips Website URL: http://www.festra.com/eng/index.html
// ******************************************************************

{
In the OnCreate (or in the OnShow) event handler of the main form of the
application, write this code:
}

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.HintColor := clAqua; // or another color
Application.HintPause := 250;    // 250 mSec before hint is shown
Application.HintHidePause:=3000; // hint disappears after 3 secs
end;

October 28, 2007 Posted by maulaku | Application - Hint / Tool Tips | | No Comments Yet

ATTACH YOUR FORM TO ANOTHER APPLICATION

// ******************************************************************
// ATTACH YOUR FORM TO ANOTHER APPLICATION
// Category        : Forms
// Author          : Peter Morris
// Author Email    : pete@stuckindoors.com
// Author Web      : http://www.delphicollection.com/public/Tips/PeterMorris/tips
// Tips Website    : Delphi Collection Tips
// Tips Website URL: http://www.delphicollection.com/public/Tips/
// ******************************************************************

{
You just have to override the CreateParams procedure of the desired form. There
you set params.WndParent to the handle of the window you want to attach your
form to.
}

{…} = class(TForm)
{…}
protected
procedure CreateParams( var params: TCreateParams ); override;
{…}

procedure TForm2.Createparams(var params: TCreateParams);
var
aHWnd : HWND;
begin
inherited;
{somehow obtain a valid handle; might be:}
ahWnd := GetForegroundWindow;
{and now:}
params.WndParent := ahWnd;
end;

{
Bogdan Grigorescu – BogdanG@romwest.ro
BG Remote Programming Group
}

October 28, 2007 Posted by maulaku | Application - Form | | No Comments Yet

ASSIGN TFORM.ICON AT RUN TIME

// ******************************************************************
// ASSIGN TFORM.ICON AT RUN TIME
// Category        : Forms
// Author          : DelphiFAQ.com
// Author Email    : tips@delphifaq.com
// Author Web      : http://www.delphifaq.com
// Tips Website    : Delphi FAQ
// Tips Website URL: http://www.delphifaq.com
// ******************************************************************

{
ImageEdit is not good. Try to get Borland’s Resource Workshop or paint with
paintbrush and use a freeware converter to convert from BMP to ICO, write a
little resource script (*.rc) refering to the ICO file and compile it to *.res
with BRCC.EXE (comes with Delphi).
}

// Use {$R xxx.res} to include it. Then you may use the API function

HICON LoadIcon(
HINSTANCE  hInstance, // handle of application instance
LPCTSTR  lpIconName  // icon-name string or icon resource identifier
);

// Take this handle (HICON) with the message WM_SETICON to assign it to your form:

SendMessage (Form1.Handle, WM_SETICON, false, iconhandle);

// Note: 3rd parameter = icon size (true -> large icon; false -> small icon).

October 28, 2007 Posted by maulaku | Application - Form | | No Comments Yet

APPLICATION.TITLE

// ******************************************************************
// APPLICATION.TITLE
// Category : Forms
// Author : Rachel and Tracy
// Author Email : tracy@specialady.com
// Author Web : http://www.specialady.com/TandR/index.html
// Tips Website : Rachel and Tracy Delphi Tips
// Tips Website URL: http://www.specialady.com/TandR/index.html
// ******************************************************************

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.Title := ‘My Program’;
end;

October 25, 2007 Posted by maulaku | Application - Form | | No Comments Yet

APPLICATION.MINIMIZE

// ******************************************************************
// APPLICATION.MINIMIZE
// Category : Forms
// Author : Rachel and Tracy
// Author Email : tracy@specialady.com
// Author Web : http://www.specialady.com/TandR/index.html
// Tips Website : Rachel and Tracy Delphi Tips
// Tips Website URL: http://www.specialady.com/TandR/index.html
// ******************************************************************

// (Minimize the Form to the TaskBar)

procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Minimize;
end;

October 25, 2007 Posted by maulaku | Application - Form | | No Comments Yet

ANOTHER TIP FOR GRADIENT FILLS ON FORMS

// ******************************************************************
// ANOTHER TIP FOR GRADIENT FILLS ON FORMS
// Category        : Forms
// Author          : Robert Allison
// Author Email    : robertallison@home.com
// Author Web      :
// Tips Website    : Delphi Pages
// Tips Website URL: http://www.delphipages.com
// ******************************************************************

// in delphi 3 just add chart to uses and then on form’s onpaint event add this…

GradientFill(Canvas, ClientRect, clblack, clBlue, False);

// This will work for delphi 3…but it doesn’t work for Delphi 4.

October 25, 2007 Posted by maulaku | Application - Form | | No Comments Yet

ANIMATE A FORM

// ******************************************************************
// ANIMATE A FORM
// Category        : Forms
// Author          : Andreas Mascher
// Author Email    : andreas@maschers.de
// Author Web      : http://www.maschers.de
// Tips Website    : Swiss Delphi Center
// Tips Website URL: http://www.swissdelphicenter.ch
// ******************************************************************

// Very simple but nice method to animate your form!

var
ani : integer,

form1.width := 372;
ani := 372;
repeat
ani := ani + 1;
form1.width := ani;
until ani >= 656;

October 25, 2007 Posted by maulaku | Application - Form | | No Comments Yet