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
}
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).
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;
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;
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.
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;
ALIGN FORM TO WORKSPACE
// ******************************************************************
// ALIGN FORM TO WORKSPACE
// Category : Forms
// Author : DelphiABC.com
// Author Email : delphiabc@delphiabc.com
// Author Web : http://www.delphiabc.com/Tips.asp
// Tips Website : Delphi ABC
// Tips Website URL: http://www.delphiabc.com/Tips.asp
// ******************************************************************
procedure TForm1.FormCreate(Sender: TObject);
var
NewRect: Trect;
begin
{See SystemParametersInfo in the Win32.hlp file for other options}
SystemParametersInfo(SPI_GETWORKAREA, 0, Pointer(@NewRect), 0);
Top := NewRect.Top;
Left := NewRect.Left;
Height := NewRect.Bottom – NewRect.Top + 1;
Width := NewRect.Right – NewRect.Left + 1;
end;
ADJUST THE WINDOW FORM TO A CANVAS
// ******************************************************************
// ADJUST THE WINDOW FORM TO A CANVAS
// Category : Forms
// Author : Iman Biglari
// Author Email : ibiglari@yahoo.de
// Author Web :
// Tips Website : Swiss Delphi Center
// Tips Website URL: http://www.swissdelphicenter.ch
// ******************************************************************
{When youu need a form like a ttree or something else what do you do? Windows
just has the CreateRoundRectRegion() function that just cuts the edges of your
nice form. If you want to do something else, you need to completely draw your
region in a HDC (TCanvas) while Windows looks on your hand to learn it. After this,
you can set the new region to your form using the ‘SetWindowRgn()’ function.
And how to do this? Here you will find a simple example that just gives some text
and sets the region like it. Expand it by your mind! }
var
Form1: TForm1;
HRgn: THandle;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
s: String;
begin
DeleteObject(HRgn);
s:=InputBox(‘Region Text’,'Please enter some text to set to the region’,'CoolRgn’);
BeginPath(Canvas.Handle);
with Canvas do
begin
Font.Name := ‘Comic Sans MS’; Font.Size := 64; Font.Style := [fsBold];
TextOut(0, 0, s);
end;
EndPath(Canvas.Handle);
HRgn := PathToRegion(Canvas.Handle);
SetWindowRgn(Handle, HRgn, True);
button1.Visible := False;
Color := clRed;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DeleteObject(HRgn);
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
ReleaseCapture;
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
end;
end;
ADD SEVERAL FORMS TO TASKBAR/TASK MANAGER
// ******************************************************************
// ADD SEVERAL FORMS TO TASKBAR/TASK MANAGER
// Category : Forms
// Author : Mike Skholnik
// Author Email : smexport@scalabium.com
// Author Web : http://www.scalabium.com
// Tips Website : Swiss Delphi Center
// Tips Website URL: http://www.swissdelphicenter.ch
// ******************************************************************
{
By default, when you create the application in Delphi, in Windows Task Manager will be
included a main form handle only. If you want to add the additional form, you must
override the CreateParams procedure:
}
{….}
type
TForm2 = class(TForm)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
{….}
implementation
{….}
procedure TForm2.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle or WS_Ex_AppWindow;
end;
// To show a Form in the taskbar anytime:
SetWindowLong(FromX.Handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
-
Archives
- November 2007 (8)
- October 2007 (32)
-
Categories
-
RSS
Entries RSS
Comments RSS