Monday, December 22, 2008

Free e-book : Delphi Tutorial

Dear Del-Nux-erz, now I want to give you some free e-books tutorial about Delphi. This tutorials divide into 3 parts. This tutorials in Bahasa Indonesia.
You can download it FREE. Enjoy it.

Part I :
Introduction to Delphi
Simple Study Case
You Can Download HERE

Part II :
Study Case II – Input Processing I
You Can Download HERE

Part III:
Study Case III : Series Program
You Can Download HERE

Continue lendo...

Thursday, October 30, 2008

How to remove an application button from the taskbar in Delphi?

This is a question which each Delphi programmer ask himself at least once in his life. If you use Google or any other search engine you will easily find this solution:


1 procedure TForm1.CreateParams(var Params: TCreateParams);
2 begin
3 inherited CreateParams(Params);
4 with Params do begin
5 ExStyle := ExStyle or WS_EX_TOPMOST;
6 WndParent := GetDesktopwindow;
7 end;
8 end;

So now you definitely have a question: "If it is so easy to find a solution then why I am talking about this?" An answer is simple. I have merely encountered a situation when approach which has been shown above is not suitable and decided to share my solution of this case with you.

Well what is the intention of the problem? According to the MSDN if you add WS_EX_TOOLWINDOW to the window ExStyle then window will act like this:

WS_EX_TOOLWINDOW

Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE.

But my client asked me to remove the button from the taskbar and leave the ability to see the window in the ALT+TAB dialog. Thus I had to refuse from above method and create my own. The solution in principle is not hard. Here is the list of steps you should do if you want to achieve an appropriate behavior:

  1. Set FormStyle property of your form to fsStayOnTop (this helps us to hold our window on top of the rest windows of our application);
  2. Write next piece of code:
 1 type
2 TfrmSamples = class(TForm)
3 { ... }
4 public
5 procedure FormDeactivate(Sender: TObject);
6 { Public declarations }
7 end;
8
9 { ... }
10
11 procedure TfrmSamples.FormCreate(Sender: TObject);
12 begin
13 { force floating window to be on top }
14 Application.OnDeactivate := FormDeactivate;
15 end;
16
17 procedure TfrmSamples.FormShow(Sender: TObject);
18 begin
19 ShowWindow(Application.Handle, SW_HIDE);
20 end;
21
22 procedure TfrmSamples.FormDeactivate;
23 begin
24 Application.BringToFront;
25 end;

According to the Borland help TApplication.OnDeactivate event occurs when an application becomes inactive therefore if we want to keep our window above all other applications (windows) then this is exec place to act.

That's all! Quick and easy.

Continue lendo...

How to Patch Delphi's VCL

From Delphi
Jump to: navigation, search

To create a VCL patch all that is required is that you copy the source file (*.pas file) from the Borland RTL or VCL source folder to your application's project folder. You can then freely modify the file and it will automatically be compiled into your application.

NOTE: This technique should only be used as an interim measure. When Borland releases fixes for the VCL that address the original issue it is recommended that you remove the patch file. Make sure you remove the respective *.dcu files as well.

WARNING: When you modify RTL/VCL files in interface section, and you are using third party components without sources you won't be able to rebuild your project!

Continue lendo...