Start Button Verstecken (für einen Virtuellen desktop)

  • VB.NET

Es gibt 13 Antworten in diesem Thema. Der letzte Beitrag () ist von diylab.

    Start Button Verstecken (für einen Virtuellen desktop)

    moin com.

    ich hab nur eine kurze frage ...
    und zwar verstecke ich die taskbar und die desktop-icons via den windows api's
    code:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    2. Private Shared Function FindWindow( _
    3. ByVal lpClassName As String, _
    4. ByVal lpWindowName As String) As IntPtr
    5. End Function
    6. <DllImport("user32.dll", SetLastError:=True)> _
    7. 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 SetWindowPosFlags) As Boolean 'SetWindowPosFlags ist ein Enum (weiter unten auch nochmal hinzugefügt)
    8. End Function
    9. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    10. Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
    11. ByVal childAfter As IntPtr, _
    12. ByVal lclassName As String, _
    13. ByVal windowTitle As String) As IntPtr
    14. End Function
    15. ' Taskbar ausblenden
    16. Public Sub HideTaskbar()
    17. Dim hWnd As IntPtr
    18. hWnd = FindWindow("Shell_TrayWnd", "")
    19. SetWindowPos(hWnd, CType(0, IntPtr), 0, 0, 0, 0, SetWindowPosFlags.HideWindow)
    20. 'button
    21. Dim hWnd2 As IntPtr
    22. hWnd2 = FindWindowEx(hWnd, IntPtr.Zero, "Button", "Start")
    23. SetWindowPos(hWnd2, CType(0, IntPtr), 0, 0, 0, 0, SetWindowPosFlags.HideWindow)
    24. End Sub
    25. ' Taskbar einblenden
    26. Public Sub ShowTaskbar()
    27. Dim hWnd As IntPtr
    28. hWnd = FindWindow("Shell_TrayWnd", "")
    29. SetWindowPos(hWnd, CType(0, IntPtr), 0, 0, 0, 0, SetWindowPosFlags.ShowWindow)
    30. 'button
    31. Dim hWnd2 As IntPtr
    32. hWnd2 = FindWindowEx(hWnd, IntPtr.Zero, "Button", "Start")
    33. SetWindowPos(hWnd2, CType(0, IntPtr), 0, 0, 0, 0, SetWindowPosFlags.ShowWindow)
    34. End Sub
    35. ' Desktop-Symbole ausblenden
    36. Public Sub DesktopIconsHide()
    37. Dim hWnd As IntPtr
    38. hWnd = FindWindow(vbNullString, "Program Manager")
    39. SetWindowPos(hWnd, CType(0, IntPtr), 0, 0, 0, 0, SetWindowPosFlags.HideWindow)
    40. End Sub
    41. ' Desktop-Symbole wieder anzeigen
    42. Public Sub DesktopIconsShow()
    43. Dim hWnd As IntPtr
    44. hWnd = FindWindow(vbNullString, "Program Manager")
    45. SetWindowPos(hWnd, CType(0, IntPtr), 0, 0, 0, 0, SetWindowPosFlags.ShowWindow)
    46. End Sub
    47. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    48. If isweg Then
    49. ShowTaskbar()
    50. DesktopIconsShow()
    51. isweg = False
    52. Else
    53. HideTaskbar()
    54. DesktopIconsHide()
    55. isweg = True
    56. End If
    57. End Sub


    SetWindowPosFlags:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. <Flags()> _
    2. Private Enum SetWindowPosFlags As UInteger
    3. ''' <summary>If the calling thread and the thread that owns the window are attached to different input queues,
    4. ''' the system posts the request to the thread that owns the window. This prevents the calling thread from
    5. ''' blocking its execution while other threads process the request.</summary>
    6. ''' <remarks>SWP_ASYNCWINDOWPOS</remarks>
    7. SynchronousWindowPosition = &H4000
    8. ''' <summary>Prevents generation of the WM_SYNCPAINT message.</summary>
    9. ''' <remarks>SWP_DEFERERASE</remarks>
    10. DeferErase = &H2000
    11. ''' <summary>Draws a frame (defined in the window's class description) around the window.</summary>
    12. ''' <remarks>SWP_DRAWFRAME</remarks>
    13. DrawFrame = &H20
    14. ''' <summary>Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to
    15. ''' the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE
    16. ''' is sent only when the window's size is being changed.</summary>
    17. ''' <remarks>SWP_FRAMECHANGED</remarks>
    18. FrameChanged = &H20
    19. ''' <summary>Hides the window.</summary>
    20. ''' <remarks>SWP_HIDEWINDOW</remarks>
    21. HideWindow = &H80
    22. ''' <summary>Does not activate the window. If this flag is not set, the window is activated and moved to the
    23. ''' top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter
    24. ''' parameter).</summary>
    25. ''' <remarks>SWP_NOACTIVATE</remarks>
    26. DoNotActivate = &H10
    27. ''' <summary>Discards the entire contents of the client area. If this flag is not specified, the valid
    28. ''' contents of the client area are saved and copied back into the client area after the window is sized or
    29. ''' repositioned.</summary>
    30. ''' <remarks>SWP_NOCOPYBITS</remarks>
    31. DoNotCopyBits = &H100
    32. ''' <summary>Retains the current position (ignores X and Y parameters).</summary>
    33. ''' <remarks>SWP_NOMOVE</remarks>
    34. IgnoreMove = &H2
    35. ''' <summary>Does not change the owner window's position in the Z order.</summary>
    36. ''' <remarks>SWP_NOOWNERZORDER</remarks>
    37. DoNotChangeOwnerZOrder = &H200
    38. ''' <summary>Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to
    39. ''' the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent
    40. ''' window uncovered as a result of the window being moved. When this flag is set, the application must
    41. ''' explicitly invalidate or redraw any parts of the window and parent window that need redrawing.</summary>
    42. ''' <remarks>SWP_NOREDRAW</remarks>
    43. DoNotRedraw = &H8
    44. ''' <summary>Same as the SWP_NOOWNERZORDER flag.</summary>
    45. ''' <remarks>SWP_NOREPOSITION</remarks>
    46. DoNotReposition = &H200
    47. ''' <summary>Prevents the window from receiving the WM_WINDOWPOSCHANGING message.</summary>
    48. ''' <remarks>SWP_NOSENDCHANGING</remarks>
    49. DoNotSendChangingEvent = &H400
    50. ''' <summary>Retains the current size (ignores the cx and cy parameters).</summary>
    51. ''' <remarks>SWP_NOSIZE</remarks>
    52. IgnoreResize = &H1
    53. ''' <summary>Retains the current Z order (ignores the hWndInsertAfter parameter).</summary>
    54. ''' <remarks>SWP_NOZORDER</remarks>
    55. IgnoreZOrder = &H4
    56. ''' <summary>Displays the window.</summary>
    57. ''' <remarks>SWP_SHOWWINDOW</remarks>
    58. ShowWindow = &H40
    59. End Enum



    aber ich kriege den startbutton nicht weg,
    ich hab schon herausgefunden das man ihn wohl seit vista anders weg bekomt aber nicht wie ?(

    hoffe ihr könt mir helfen :whistling:
    Versuch mal das:

    VB.NET-Quellcode

    1. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    2. Private Shared Function FindWindow( _
    3. ByVal lpClassName As String, _
    4. ByVal lpWindowName As String) As IntPtr
    5. End Function
    6. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    7. Private Shared Function ShowWindow( _
    8. ByVal hwnd As IntPtr, _
    9. ByVal nCmdShow As Int32) As Boolean
    10. End Function
    11. Public Shared Sub TaskBar(ByVal blnValue As Boolean)
    12. Dim lngtaskbar As Long
    13. lngtaskbar = FindWindow("Shell_TrayWnd", "")
    14. If blnValue Then
    15. ShowWindow(lngtaskbar, 5)
    16. Else
    17. ShowWindow(lngtaskbar, 0)
    18. End If
    19. End Sub
    20. the c# code that should hide the orb is below:
    21. [DllImport("user32.dll")]
    22. private static extern IntPtr FindWindowEx(
    23. IntPtr parentHwnd,
    24. IntPtr childAfterHwnd,
    25. IntPtr className,
    26. string windowText);
    27. IntPtr hwndOrb = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, null);
    28. ShowWindow(hwndOrb, SW_HIDE);
    @MarcoQuinten: Waas isn das für eine Sprache bei Dir: VB# :?:
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!

    SystemUnknow schrieb:



    Moin,

    hab ich mal gemacht:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. Option Strict On
    2. Option Explicit On
    3. Public Class frmStart
    4. ' zunächst die benötigten API-Deklarationen
    5. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    6. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer
    7. Private Const GW_CHILD As Short = 5
    8. 'Verstecken
    9. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
    10. Private Const SW_HIDE As Short = 0
    11. Private Const SW_RESTORE As Short = 9
    12. 'Schließen
    13. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    14. Private Const WM_CLOSE As Integer = &H10
    15. 'Verschieben
    16. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
    17. Private Const SWP_NOSIZE As Integer = &H1
    18. Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click
    19. If MsgBox("Der Button wird erst wieder angezeigt, wenn Sie Windows neu starten!", CType(17, MsgBoxStyle), "Startbutton schließen") = MsgBoxResult.Ok Then
    20. 'Schließen
    21. '(kann erst nach Neustart wieder angezeigt werden)
    22. SendMessage(StartButtonHandle(), WM_CLOSE, 0, 0)
    23. End If
    24. End Sub
    25. Private Sub cmdHide_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdHide.Click
    26. 'Verstecken
    27. ShowWindow(StartButtonHandle(), SW_HIDE)
    28. End Sub
    29. Private Sub cmdMove_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdMove.Click
    30. 'Verschieben
    31. SetWindowPos(StartButtonHandle(), 0, 950, 0, 0, 0, SWP_NOSIZE)
    32. End Sub
    33. Private Sub cmdShow_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdShow.Click
    34. 'wieder anzeigen
    35. ShowWindow(StartButtonHandle(), SW_RESTORE)
    36. End Sub
    37. Private Function StartButtonHandle() As Integer
    38. Dim ret As Integer
    39. ret = FindWindow("shell_traywnd", "")
    40. ret = GetWindow(ret, GW_CHILD)
    41. StartButtonHandle = ret
    42. End Function
    43. End Class

    Anbei auch das compilierte Projekt.

    Geht nicht ganz wie gewünscht, der Startbutton bleibt :D ..
    OS: Windows 7 Pro 64Bit

    LG,
    Bruno
    Dateien
    • WinStartBtn.exe

      (18,43 kB, 142 mal heruntergeladen, zuletzt: )
    habs auch gemacht (bin nicht al zu schnell mit dem übersetzen)
    aber funktioniert null die taskbar ist weg die icons auf dem desktop sind weg aber die kugel bleibt

    das letzte was mir einfält wäre es einfach zu überlappen mit der desktop form ?

    PS: hab Win7 HomeEdition x86 (auf nem ranz laptop | reicht zum programieren )
    Moin Jungs - jetzt gehts!

    Das aktuelle Projekt basiert auf der Idee von Simon Baer - hier zu finden: LINK .
    Da in seinem Copyright steht: "You may use this code for whatever you want", war ich so frei und habe das Ganze nach VB.NET gewandelt und angehängt.
    Bei mir klappt es nun prima - die ganze Leiste inklusive Start-Button verschwindet und taucht auch komplett wieder auf.

    Viele Grüße, viel Spaß, viel Sonne,
    Bruno :P
    Dateien
    • TaskbarHide.exe

      (15,87 kB, 222 mal heruntergeladen, zuletzt: )
    • TaskbarHide.zip

      (11,97 kB, 242 mal heruntergeladen, zuletzt: )

    INK-Software schrieb:

    Bei Windows 8 funktioniert es bei "Classic Shell" leider nicht, aber ich nehme an da hast du auch nicht drauf geachtet.. :)

    Nö.
    Ist auch nicht "mein Programm", nur konvertiert :rolleyes: ..
    Zu ende Denken könnt ihr sicher besser, ich wollte nur ein bisschen das Thema anstoßen.

    Nachtrag zur Classic-Shell:
    Ich wusste zuerst nicht einmal was Du meinst, aber das ist ja ein inoffizielles Zusatztool für Windows8. Da kann es wohl sein, dass nicht Windows, sondern Deine Classic-Shell das Problem verursacht.
    Habe gerade unter Windows 8 getestet (Aero und Basic Styles) und da arbeitet das Teil einwandfrei.
    Bilder
    • win8_show.png

      77,16 kB, 1.283×996, 167 mal angesehen
    • win8_hide.png

      72,51 kB, 1.282×995, 176 mal angesehen

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „diylab“ ()