none
Taskbar RRS feed

  • Question

  • Good...

    What I want to do is to move the windows taskbar to the UPPER part by pressing a button1, LOWER by pressing a button2, LEFT by pressing a button3 or RIGHT when pressing a button4.

    first of all, Thanks.
    Thursday, May 25, 2017 9:13 PM

All replies

  • You need to change a registry setting.  The one to set is 

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3

    but when you look at it you will have to do some research to find out what to change.

    Found a link that says it knows (you'll have to try it).

    https://www.tenforums.com/tutorials/57280-change-taskbar-location-screen-windows-10-a.html#option3


    Lloyd Sheen


    • Edited by sqlguy Friday, May 26, 2017 12:28 PM
    Thursday, May 25, 2017 9:49 PM
  • Is it possible to do this operation by code?
    Thursday, May 25, 2017 10:27 PM
  • Hi JenCarlos,

    Yes, it's possible.
    But the data value is binary (REG_BINARY) and we need to the value before write code. I recommend you to move the taskbar to the upper/lower, left/right and record each value in Regedit.
        

        

    There exist many articles which teach how to make code for reading/writing registry in VB.NET.
    One of them:  Windows Registry In VB.NET
    ______________
    Ashidacchi
    Friday, May 26, 2017 12:50 AM
  • Hi Jencarlos,

    You can move the Taskbar programmatically, but only to the preset fixed positions it allows (i.e. Bottom, Left, Right, Top).

    I find one example that you can refer to, this code is in C# but with every converter can be converted it to VB.

    https://bytes.com/topic/c-sharp/answers/247701-moving-windows-takbar

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 26, 2017 2:25 AM
    Moderator
  • On Windows 10, for example to move it on left :

    SendMessage(FindWindow("Shell_TrayWnd", ""), &H400 + 458, 6, 0)

    Friday, May 26, 2017 9:46 AM
  • On Windows 10, for example to move it on left :

    SendMessage(FindWindow("Shell_TrayWnd", ""), &H400 + 458, 6, 0)


    Please don't post Win32 functions as though they were .Net methods.  This only frustrates people when they cannot find SendMessage or FindWindow functions.  If you are going to share a Win32 based solution, please call attention to that and include the proper function imports.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Friday, May 26, 2017 1:36 PM
    Moderator
  • Is it possible to do this operation by code?

    Keep in mind that modifying the registry at runtime may trigger certain system protection software.  In general it is best to stay out of the registry these days.  You should definitely try to perform this via API calls, even if it means using unmanaged Win32 API calls as Castorix31 has alluded to.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Friday, May 26, 2017 1:42 PM
    Moderator
  • Please don't post Win32 functions as though they were .Net methods.  This only frustrates people when they cannot find SendMessage or FindWindow functions.  If you are going to share a Win32 based solution, please call attention to that and include the proper function imports.

     I usually post the declarations with DllImport, but I  thought it was not neccessary for those very classic APIs

    <DllImport("User32.dll", EntryPoint:="SendMessageW", SetLastError:=True)>
        Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer
        End Function <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr End Function


    • Edited by Castorix31 Friday, May 26, 2017 2:16 PM
    Friday, May 26, 2017 2:16 PM
  • Please don't post Win32 functions as though they were .Net methods.  This only frustrates people when they cannot find SendMessage or FindWindow functions.  If you are going to share a Win32 based solution, please call attention to that and include the proper function imports.

     I usually post the declarations with DllImport, but I  thought it was not neccessary for those very classic APIs

    <DllImport("User32.dll", EntryPoint:="SendMessageW", SetLastError:=True)>
        Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer
        End Function <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr End Function


    Thank you for adding the imports.

    There are many .Net developers who have never touched unmanaged code, particularly those who are picking up VB.Net as their first language, so it's always best to call attention to solutions which require unmanaged API calls.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Friday, May 26, 2017 2:43 PM
    Moderator
  • Please don't post Win32 functions as though they were .Net methods.  This only frustrates people when they cannot find SendMessage or FindWindow functions.  If you are going to share a Win32 based solution, please call attention to that and include the proper function imports.

     I usually post the declarations with DllImport, but I  thought it was not neccessary for those very classic APIs

    <DllImport("User32.dll", EntryPoint:="SendMessageW", SetLastError:=True)>
        Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer
        End Function <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr End Function



    Yeah. And if one has nothing better to do a one form working example with a picture is good too!

    Then we all learn something from you. And its good practice.

    :)

    Friday, May 26, 2017 2:50 PM
  •  After some researching and a bit of experimenting,  there does not appear to be any of these methods that works on all systems.  I have used the SHAppBarMessage function that Cherry Bu linked to which i know worked on windows XP but,  it appears that it does not work for Vista,  Win 7,  and probably newer OS`s.  I have also tried to use other methods to just move the taskbar window itself,  such as what Castorix31 showed and none of them work on windows 7,  not even if i run it as an administrator.  Last,  i also thought about trying the registry settings but,  it appears that i do not have the registry key that sqlguy has shown here and on other websites too.

     I used a registry tracker app to find any registry key values that have changed after moving the taskbar manually and the one that changes on my system is completely different than the others i have seen posted which i don`t have on my windows 7.

     In short,  there is not a one size fits all for this task.  Therefore,  unless you are only targeting one system which one of these methods happens to work on,  this is not something that can be done reliably.

     Probably the most reliable way i can think of would be to find the screen bounds of the taskbar window and simulate the mouse movements to move the taskbar to the edge you want.  Even that would be somewhat unpredictable.

     

    If you say it can`t be done then i`ll try it

    • Proposed as answer by sedo11 Thursday, June 8, 2017 2:49 AM
    Friday, May 26, 2017 5:32 PM
  • Thanks you
    Monday, May 29, 2017 7:33 PM
  • Hi Jencarlos,

    Please remember to close your threads by marking helpful posts as answer, it is very beneficial to other communities who faced the same issue.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 13, 2017 5:57 AM
    Moderator