Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Delphi Tutorial - Change Your Start Button Caption
bureX
post Feb 15 2005, 12:02 AM
Post #1


Super Member
*********

Group: Members
Posts: 318
Joined: 5-January 05
Member No.: 3,136



How to change your start button caption using Delphi!

(By the way, the start button will be renamed back to "start" after you restart your computer)

Here we go!

1. Create a new project in Delphi

2. Add a Button and an Edit box to your form, place them where you want.

3. Double click the button to enter the code editor so we can type code for our OnClick event.

4. The code for the OnClick event of our button should look like this:

CODE

procedure TForm1.Button1Click(Sender: TObject);
var Handle1,Handle2:hwnd;
begin
Handle1:=FindWindow('Shell_TrayWnd',nil); //get the handle of the taskbar
Handle2:=FindWindowEx(Handle1,0,'Button',nil); //get the handle of the start button from the taskbar
SetWindowText(Handle2,PAnsiChar(Edit1.Text)); //set the text
SendMessage(Handle2,Messages.WM_MOUSEMOVE,0,0); //used to refresh the caption of the start button
end;


5. Alright, run the program (F9) and enjoy!

The finished program should look something like this:

user posted image

Just type a new caption in the text box and click on the button.

Piece of cake!
Go to the top of the page
 
+Quote Post
lordofthecynics
post Feb 15 2005, 07:50 AM
Post #2


Member [Level 2]
*****

Group: Members
Posts: 83
Joined: 11-February 05
From: Lancaster, CA
Member No.: 3,696



QUOTE(bureX @ Feb 14 2005, 04:02 PM)
How to change your start button caption using Delphi!

(By the way, the start button will be renamed back to "start" after you restart your computer)

Here we go!

1. Create a new project in Delphi

2. Add a Button and an Edit box to your form, place them where you want.

3. Double click the button to enter the code editor so we can type code for our OnClick event.

4. The code for the OnClick event of our button should look like this:

CODE

procedure TForm1.Button1Click(Sender: TObject);
var Handle1,Handle2:hwnd;
begin
Handle1:=FindWindow('Shell_TrayWnd',nil); //get the handle of the taskbar
Handle2:=FindWindowEx(Handle1,0,'Button',nil); //get the handle of the start button from the taskbar
SetWindowText(Handle2,PAnsiChar(Edit1.Text)); //set the text
SendMessage(Handle2,Messages.WM_MOUSEMOVE,0,0); //used to refresh the caption of the start button
end;


5. Alright, run the program (F9) and enjoy!

The finished program should look something like this:

user posted image

Just type a new caption in the text box and click on the button.

Piece of cake!
*




What is Delphi, where can I get it, and what is the point of changing the start button name?
Go to the top of the page
 
+Quote Post
bureX
post Feb 15 2005, 02:45 PM
Post #3


Super Member
*********

Group: Members
Posts: 318
Joined: 5-January 05
Member No.: 3,136



Delphi is a programming environment that uses Object Pascal as it's main language.

You can get a trial version at www.borland.com.

The point?
This tutorial shows the power of handles. Using Delphi, you can quickly gain a handle of any window/subwindow and resize it, change it's caption, make it transparent, move it around...

Changing the start button caption is just an example of using handles. With handles, you can give your program the ability to react on any system event that you have gained a handle over. For example, if a user presses a key combination ALT+F1, your program will know about it and react the way you want it to. You can also get a device handle, and let your program be notified if a user connects/disconnects an USB device, etc.
Go to the top of the page
 
+Quote Post
lordofthecynics
post Feb 19 2005, 01:52 AM
Post #4


Member [Level 2]
*****

Group: Members
Posts: 83
Joined: 11-February 05
From: Lancaster, CA
Member No.: 3,696



QUOTE(bureX @ Feb 15 2005, 06:45 AM)
Delphi is a programming environment that uses Object Pascal as it's main language.

You can get a trial version at www.borland.com.

The point?
This tutorial shows the power of handles. Using Delphi, you can quickly gain a handle of any window/subwindow and resize it, change it's caption, make it transparent, move it around...

Changing the start button caption is just an example of using handles. With handles, you can give your program the ability to react on any system event that you have gained a handle over. For example, if a user presses a key combination ALT+F1, your program will know about it and react the way you want it to. You can also get a device handle, and let your program be notified if a user connects/disconnects an USB device, etc.
*


Oh, ok. I'm not too familiar with programming languages. I had a hard time with JavaScript and CSS as it was, though HTML is somewhat easy for me.
Go to the top of the page
 
+Quote Post
Trap FeedBacker
post May 1 2008, 10:59 AM
Post #5


Guest Feedbacks
***************

Group: Members
Posts: 2,360
Joined: 21-September 07
Member No.: 50,369



Dynamic debugging
Delphi Tutorial - Change Your Start Button Caption

Using Delphi 7-2007, I would like to know if there is a way to get dynamically the name of the current unite and function/procedure.

Example: Including the name of the unit and function/procedure where an exception raised.

This can be very helpful to locate post production bugs.


-question by Sale AHMAD
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Delphi(1)
  2. Simple Parsing Functions(0)
  3. Formating Your Form "textarea" And "submit" Button(0)
  4. Button Rotations!(0)
  5. Download Files Off Esnips.com(0)


 



- Lo-Fi Version Time is now: 12th May 2008 - 06:48 AM