Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Delphi Tutorial - Change Your Start Button Caption


5 replies to this topic

#1 bureX

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 318 posts

Posted 15 February 2005 - 12:02 AM

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:

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:

Posted Image

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

Piece of cake!

#2 lordofthecynics

    Member [Level 2]

  • Kontributors
  • PipPipPipPipPip
  • 79 posts
  • Location:Lancaster, CA
  • Interests:Moo.

Posted 15 February 2005 - 07:50 AM

bureX, on Feb 14 2005, 04:02 PM, said:

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:

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:

Posted Image

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

Piece of cake!

View Post



What is Delphi, where can I get it, and what is the point of changing the start button name?

#3 bureX

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 318 posts

Posted 15 February 2005 - 02:45 PM

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.

#4 lordofthecynics

    Member [Level 2]

  • Kontributors
  • PipPipPipPipPip
  • 79 posts
  • Location:Lancaster, CA
  • Interests:Moo.

Posted 19 February 2005 - 01:52 AM

bureX, on Feb 15 2005, 06:45 AM, said:

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.

View Post

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.

#5 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 01 May 2008 - 10:59 AM

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

#6 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 06 February 2010 - 09:41 AM

sndkey32Delphi Tutorial - Change Your Start Button Caption

How can I input a text in a focused windows,as a notepad when I press button F5,help me please.I just want to make a program ,that with pressing a button F5,delphi program input a text

for example in a chat program like DC++.It will be very helpfull for a chat command .Thank you!

-question by Niki




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users