hi all,
i have a program that change the look of the taskbar. But i have a problem, i want to set the start button position to the middle of the taskbar but can't find any code to do this. I know that its possible because there are some programs that do this. i hope you guys can help me out thanks already :)

killerbeat

Dani AI

Generated

A short, practical follow‑up that ties together the tips already posted by and and explains the pitfalls that make this fragile across Windows versions.

Summary and approach

  • The Win32 route (locate the taskbar, enumerate its child windows, then reposition the Start‑button window with SetWindowPos/MoveWindow) is the straightforward technique on older Windows. Use an enumeration callback so the code does not rely on one hard‑coded child index or a single class name. EnumChildWindows + GetWindowRect are the right primitives for discovery; SetWindowPos is the supported way to move a window once its handle is known. (learn.microsoft.com)

Practical algorithm (what to implement)

  1. Find the taskbar/top‑level shell window and enumerate children (EnumChildWindows). Inspect each child’s class name, window text and screen rectangle (GetClassName/GetWindowRect) and pick the candidate based on heuristics (size, proximity to the left edge, visible/interactive). (learn.microsoft.com)
  2. Compute the target X position (taskbar center or whatever offset) in screen coordinates, then call SetWindowPos with SWP_NOSIZE and appropriate flags to move the button. (learn.microsoft.com)
  3. Reapply the logic when Explorer restarts: handle the shell’s broadcasted TaskbarCreated notification (RegisterWindowMessage("TaskbarCreated")) and run the finder/move routine again. Without this the change will be lost if Explorer crashes or restarts. (learn.microsoft.com)

Cautions and alternatives

  • This is brittle. The Start control and taskbar internals have changed over Windows releases; code that works on XP may fail on Vista/7/10/11. Relying on internal class names or exact layout is not supported and can break with updates. For tasks that must work across versions, consider a supported UI approach (custom toolbar/shell replacement) or use a third‑party product that targets the specific OS. (devblogs.microsoft.com)
  • Moving windows owned by another process can be blocked by UIPI; elevated privileges or UIAccess signing/installation rules may be required. Test on every target OS and account for autohide, vertical taskbars and DPI scaling. (learn.microsoft.com)

Minimal VB.NET enumeration pattern (illustrates the discovery + move step) was used here only as a concept; adapt carefully and test on the intended Windows versions.

Recommended Answers

All 11 Replies

hi all,
i have a program that change the look of the taskbar. But i have a problem, i want to set the start button position to the middle of the taskbar but can't find any code to do this. I know that its possible because there are some programs that do this. i hope you guys can help me out thanks already :)

killerbeat

Hello,
An (Windows) Executable file (*.exe) has a know place, where are stored some pictures. This way you can change some pictures in it. But changing the "core" layout would need to change the code. I doubt there are applications, that can do it (1), you should try an alternative to Windows Explorer which provide the way to modiby the look and feel.

Hello,
An (Windows) Executable file (*.exe) has a know place, where are stored some pictures. This way you can change some pictures in it. But changing the "core" layout would need to change the code. I doubt there are applications, that can do it (1), you should try an alternative to Windows Explorer which provide the way to modiby the look and feel.

seten, i now it's possible please look at this program:

(this program is coded in vb ) i only have no idea how to do it :(

Hi

I hope you are familiar with Win32API.

use MoveWindow() or SetWindowPos() API to move start menu

Hi

I hope you are familiar with Win32API.

use MoveWindow() or SetWindowPos() API to move start menu

selvaganapathy, i am not really familiar with the win 32API can you tell me some more about it?

Please read the MSDN reference for MoveWindow() API

http://msdn.microsoft.com/en-us/library/ms633534%28VS.85%29.aspx

SetWindowPos() API
http://msdn.microsoft.com/en-us/library/ms633545%28VS.85%29.aspx

Example

1. Draw three Buttons ( Button1, Button2, Button3 )
then try this

Imports System.Runtime.InteropServices

Public Class Form1

    Shared ReadOnly SWP_NOSIZE As UInt32 = Convert.ToUInt32(&H1)    'Ignore Width and Height

    <DllImport("user32.dll")> _
    Public Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Boolean) As Boolean
    End Function

    <DllImport("user32.dll", SetLastError:=True)> _
    Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As UInt32) As Boolean
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Move the Button3 to 0, 0 and Keep Same Width
        MoveWindow(Button3.Handle, 0, 0, Button3.Width, Button3.Height, True)
        'Move the Button2 to 100, 100
        SetWindowPos(Button2.Handle, IntPtr.Zero, 100, 100, 0, 0, SWP_NOSIZE)
    End Sub
End Class

Please read the MSDN reference for MoveWindow() API

http://msdn.microsoft.com/en-us/library/ms633534%28VS.85%29.aspx

SetWindowPos() API
http://msdn.microsoft.com/en-us/library/ms633545%28VS.85%29.aspx

Example

1. Draw three Buttons ( Button1, Button2, Button3 )
then try this

Imports System.Runtime.InteropServices

Public Class Form1

    Shared ReadOnly SWP_NOSIZE As UInt32 = Convert.ToUInt32(&H1)    'Ignore Width and Height

    <DllImport("user32.dll")> _
    Public Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Boolean) As Boolean
    End Function

    <DllImport("user32.dll", SetLastError:=True)> _
    Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As UInt32) As Boolean
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Move the Button3 to 0, 0 and Keep Same Width
        MoveWindow(Button3.Handle, 0, 0, Button3.Width, Button3.Height, True)
        'Move the Button2 to 100, 100
        SetWindowPos(Button2.Handle, IntPtr.Zero, 100, 100, 0, 0, SWP_NOSIZE)
    End Sub
End Class

tnx selvaganapathy, but how can i find the start button window and move it ? with the code you gave me you can move 2 buttons but how do you do this with windows

but i thought already you have the code...

no problem, google it you will find the code

or

See this discussion http://bytes.com/topic/visual-basic-net/answers/366425-how-hide-start-button

now i am realy lost :icon_confused: how do find the start button and move it ? i think this part of the code i have to change please help

'Move the Button3 to 0, 0 and Keep Same Width
        MoveWindow(Button3.Handle, 0, 0, Button3.Width, Button3.Height, True)
        'Move the Button2 to 100, 100
        SetWindowPos(Button2.Handle, IntPtr.Zero, 100, 100, 0, 0, SWP_NOSIZE)

Full Code that u want, Try it

Imports System.Runtime.InteropServices
Public Class Form1

    <DllImport("user32.dll")> _
    Public Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Boolean) As Boolean
    End Function

    <DllImport("user32.dll", SetLastError:=True)> _
    Public Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As UInt32) As Boolean
    End Function

    <DllImport("user32.dll")> _
    Public Shared Function FindWindowEx(ByVal hWnd As IntPtr, ByVal hWndChild As IntPtr, ByVal lpszClassName As String, ByVal lpszWindow As String) As IntPtr
    End Function

    <DllImport("user32.dll")> _
    Public Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Int32) As Int32
    End Function
    Public Shared ReadOnly SWP_NOSIZE As UInt32 = Convert.ToUInt32(&H1)    'Ignore Width and Height

    Private m_hWndStart As IntPtr
    Private m_hWndTaskBar As IntPtr

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        m_hWndTaskBar = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", vbNullString)
        m_hWndStart = FindWindowEx(m_hWndTaskBar, IntPtr.Zero, "BUTTON", vbNullString)

        'Move the Start Menu to 100, 0
        SetWindowPos(m_hWndStart, IntPtr.Zero, 100, 0, 0, 0, SWP_NOSIZE)
    End Sub

End Class

Full Code that u want, Try it

Imports System.Runtime.InteropServices
Public Class Form1

    <DllImport("user32.dll")> _
    Public Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Boolean) As Boolean
    End Function

    <DllImport("user32.dll", SetLastError:=True)> _
    Public Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As UInt32) As Boolean
    End Function

    <DllImport("user32.dll")> _
    Public Shared Function FindWindowEx(ByVal hWnd As IntPtr, ByVal hWndChild As IntPtr, ByVal lpszClassName As String, ByVal lpszWindow As String) As IntPtr
    End Function

    <DllImport("user32.dll")> _
    Public Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Int32) As Int32
    End Function
    Public Shared ReadOnly SWP_NOSIZE As UInt32 = Convert.ToUInt32(&H1)    'Ignore Width and Height

    Private m_hWndStart As IntPtr
    Private m_hWndTaskBar As IntPtr

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        m_hWndTaskBar = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", vbNullString)
        m_hWndStart = FindWindowEx(m_hWndTaskBar, IntPtr.Zero, "BUTTON", vbNullString)

        'Move the Start Menu to 100, 0
        SetWindowPos(m_hWndStart, IntPtr.Zero, 100, 0, 0, 0, SWP_NOSIZE)
    End Sub

End Class

thank you so much this was where i was searching for :D i have only question can you move the start button and start menu seperatly?

i dont know how to separate start button and start menu or separately move each one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.