Results 1 to 7 of 7

Thread: Changing Text in Start Button

  1. #1

    Thread Starter
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Changing Text in Start Button

    Here is the code to change the text in the start button:

    Code:
    Option Strict Off
    Public Class Form1
        Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
                (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
        Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
        (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
        Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" _
        (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
    
        Private Const WM_SETTEXT = &HC
        Private Const WM_GETTEXT = &HD
    
        Public Sub ChangeStartButtonText(ByVal str As String)
            Try
                Dim StartButton As Integer
                Dim StartButtonText As Integer
                Dim Caption As String
                StartButton = FindWindow("Shell_TrayWnd", vbNullString)
                StartButtonText = FindWindowEx(StartButton, 0&, "button", vbNullString)
                Caption = Mid(str, 1, 5)
                SendMessageSTRING(StartButtonText, WM_SETTEXT, 256, Caption)
            Catch ex As Exception
            End Try
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ChangeStartButtonText(TextBox1.Text)
        End Sub
    End Class
    WARNING! If you set the text to more than 5 characters it will be cut off.

    If you like this code please rate it and leave feedback.
    Thanks!
    Last edited by cameron2; Apr 7th, 2008 at 07:35 AM.
    If this post helped you, please click the rate button to say thank you! Remember to mark the thread as resolved too.
    Autoclicker, Hide Taskbar, Sounds on internal speaker, Changing Start Button Text (with code)

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,284

    Re: Changing Text in Start Button

    When the computer is turned off / reset, does windows retain the new word or does it get set back to 'Start'?

  3. #3

    Thread Starter
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Re: Changing Text in Start Button

    Aha i knew someone would ask that, but the answer is no unfortunately it will get set back to start but if you want i could make something that retains the word until you change it.
    If this post helped you, please click the rate button to say thank you! Remember to mark the thread as resolved too.
    Autoclicker, Hide Taskbar, Sounds on internal speaker, Changing Start Button Text (with code)

  4. #4

    Thread Starter
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Re: Changing Text in Start Button

    Solution: Everytime the start button is changed write the text to a file and then on form load make it change the start button text to the text from the file.
    Make your program create a registry key here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    As your programs directory.

    Example:
    Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim startvar As String
            If IO.File.Exists("C:\text.txt") Then
                startvar = IO.File.ReadAllText("C:\text.txt")
                SetStartCaption(startvar)
    'write to the registry here, cant be bothered working out how to if someone can it'll be greatly appreciated
            End If
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ChangeStartButtonText(TextBox1.Text)
    IO.File.WriteAllText("C:\text.txt", TextBox1.Text)
        End Sub
    Last edited by cameron2; Apr 7th, 2008 at 06:39 PM.
    If this post helped you, please click the rate button to say thank you! Remember to mark the thread as resolved too.
    Autoclicker, Hide Taskbar, Sounds on internal speaker, Changing Start Button Text (with code)

  5. #5
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Changing Text in Start Button

    Nice code thanks mate

  6. #6
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Changing Text in Start Button

    But automatically the name is resetting after certain mins.

  7. #7
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Changing Text in Start Button

    For anyone that is just looking to do this for fun rather than wanting the VB code for it, you can follow this guide: http://www.theeldergeek.com/change_t...rt_button1.htm
    It does not get reset when you restart your PC or anything and I did it once and used the system for months without any issues.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width