vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Mails senden, abrufen und decodieren - ganz easy ;-)  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Fortgeschrittene
Re: eigene windows-symbolleiste erstellen 
Autor: ModeratorDaveS (Moderator)
Datum: 28.12.04 12:19

Also, hier ist eine schnelle "Übersetzung". Ich würde sagen die ganze AppBar Funktionalität ist nicht implementiert...
Option Explicit On 
 
Public Class AppBar
 
    ' API Deklarationen
    Private Declare Function SHAppBarMessage Lib "shell32.dll" _
      (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As Integer
 
    Private Declare Function SetWindowPos Lib "user32" _
      (ByVal hWnd As IntPtr, 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
 
 
    <Runtime.InteropServices.StructLayout( _
      Runtime.InteropServices.LayoutKind.Sequential, pack:=4)> _
    Private Structure RECT
        Public Left As Integer
        Public Top As Integer
        Public Right As Integer
        Public Bottom As Integer
    End Structure
 
    <Runtime.InteropServices.StructLayout( _
      Runtime.InteropServices.LayoutKind.Sequential, pack:=4)> _
    Private Structure APPBARDATA
        Public cbSize As Integer
        Public hWnd As Integer
        Public uCallbackMessage As Integer
        Public uEdge As Integer
        Public rc As RECT
        Public lParam As Integer
    End Structure
 
    ' Konstanten für die API
    Private Const HWND_TOPMOST = -1
 
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_SHOWWINDOW = &H40
 
    Private Const ABM_NEW = &H0
    Private Const ABM_REMOVE = &H1
    Private Const ABM_SETPOS = &H3
    Private Const ABM_GETTASKBARPOS = &H5
 
    Public Const ABE_LEFT = &H0
    Public Const ABE_TOP = &H1
    Public Const ABE_RIGHT = &H2
    Public Const ABE_BOTTOM = &H3
 
    ' Enum der Docking Positionen
    Public Enum AppBarPos
        BarLeft = 0
        BarTop = 1
        BarRight = 2
        BarBottom = 3
    End Enum
 
    ' Anwendungsvariablen
    Private appBarForm As Form
    Private bDocked As Boolean
    Private lBorder As Integer
 
    ' AppBar Informationen
    Private APD As APPBARDATA
 
    Private lDockMode As Integer
 
    ' Application-Bar erstellen und ausrichten
 
    Public Sub New(ByVal AppForm As Form, ByVal Position As AppBarPos)
 
        Dim WTBPos As APPBARDATA
        Dim lTop, lBottom As Integer
        Dim lLeft, lRight As Integer
        Dim lWidth, lHeight As Integer
 
        appBarForm = AppForm
 
        ' minimale Höhe oder Breite der Bar in Pixel
        Dim lMinSize As Integer
 
        APD.cbSize = 36
        WTBPos.cbSize = 36
        lDockMode = Position
        bDocked = True
 
        ' Neue AppBar anlegen
        Dim res As Integer = SHAppBarMessage(ABM_NEW, APD)
 
        ' Je nach Position die Variablen füllen
        Select Case lDockMode
            Case ABE_LEFT
                lMinSize = appBarForm.Width
                lLeft = 0
                lTop = 0
                lRight = lMinSize + lBorder
                lBottom = Screen.GetBounds(appBarForm).Height
                lWidth = lMinSize
                lHeight = Screen.GetBounds(appBarForm).Height
 
            Case ABE_TOP
                lMinSize = appBarForm.Height
                lLeft = 0
                lTop = 0
                lRight = Screen.GetBounds(appBarForm).Width
                lBottom = lMinSize + lBorder
                lWidth = Screen.GetBounds(appBarForm).Width
                lHeight = lMinSize
 
            Case ABE_RIGHT
                lMinSize = appBarForm.Width
                lLeft = Screen.GetBounds(appBarForm).Width - lMinSize - lBorder
                lTop = 0
                lRight = Screen.GetBounds(appBarForm).Width
                lBottom = lMinSize + lBorder
                lWidth = lMinSize
                lHeight = Screen.GetBounds(appBarForm).Height
 
            Case ABE_BOTTOM
                lMinSize = appBarForm.Height
                lLeft = 0
                lTop = Screen.GetBounds(appBarForm).Height - lMinSize - lBorder
                lRight = Screen.GetBounds(appBarForm).Width
                lBottom = Screen.GetBounds(appBarForm).Height
                lWidth = Screen.GetBounds(appBarForm).Width
                lHeight = lBottom - lTop
        End Select
 
        '--------------------------------------------------
        'Nun noch die Windows Taskbar berücksichtigen
        res = SHAppBarMessage(ABM_GETTASKBARPOS, WTBPos)
 
        With WTBPos
            '------------------------------------------------
            ' Taskbar unten
            If .uEdge = ABE_BOTTOM And lDockMode = ABE_BOTTOM Then
                lTop = .rc.Top - lMinSize - lBorder
                lBottom = .rc.Bottom
            ElseIf .uEdge = ABE_BOTTOM And _
              (lDockMode = ABE_LEFT Or lDockMode = ABE_RIGHT) Then
                lHeight = .rc.Top
 
                '------------------------------------------------
                ' Taskbar oben
            ElseIf .uEdge = ABE_TOP And lDockMode = ABE_TOP Then
                lTop = .rc.Bottom
                lBottom = lTop + lMinSize
            ElseIf .uEdge = ABE_TOP And _
              (lDockMode = ABE_LEFT Or lDockMode = ABE_RIGHT) Then
                lTop = .rc.Bottom
                lHeight = Screen.GetBounds(appBarForm).Height - .rc.Bottom
 
                '------------------------------------------------
                ' Taskbar links
            ElseIf .uEdge = ABE_LEFT And lDockMode = ABE_LEFT Then
                lLeft = .rc.Right
            ElseIf .uEdge = ABE_LEFT And _
              (lDockMode = ABE_TOP Or lDockMode = ABE_BOTTOM) Then
                lLeft = .rc.Right
                lWidth = Screen.GetBounds(appBarForm).Width - .rc.Right
 
                '------------------------------------------------
                ' Taskbar rechts
            ElseIf .uEdge = ABE_RIGHT And lDockMode = ABE_RIGHT Then
                lLeft = .rc.Left - lMinSize
            ElseIf .uEdge = ABE_RIGHT And _
              (lDockMode = ABE_TOP Or lDockMode = ABE_BOTTOM) Then
                lWidth = .rc.Left
            End If
        End With
 
        ' AppData Objekt für die ApplicationBar füllen
        With APD
            .uEdge = lDockMode
            .rc.Top = lTop
            .rc.Left = lLeft
            .rc.Right = lRight
            .rc.Bottom = lBottom
        End With
 
        ' AppBar mit den neuen Werten füllen
        res = SHAppBarMessage(ABM_SETPOS, APD)
 
        ' Nun das Form an die Position der AppBar bringen
        Application.DoEvents()
        With appBarForm
            .Show()
            Call SetWindowPos(.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW)
            .Top = lTop
            .Left = lLeft
            .Width = lWidth
            .Height = lHeight
        End With
    End Sub
 
    ' ApplicationBar entfernen
    Public Sub UnloadAppBar()
        If bDocked Then
            Dim res As Integer = SHAppBarMessage(ABM_REMOVE, APD)
            bDocked = False
        End If
    End Sub
 
End Class
Public Class frmAppBar
    Inherits System.Windows.Forms.Form
 
#Region " Windows Form Designer generated code "
 
    Public Sub New()
        MyBase.New()
 
        'This call is required by the Windows Form Designer.
        InitializeComponent()
 
        'Add any initialization after the InitializeComponent() call
 
    End Sub
 
    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
 
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
 
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(16, 24)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(64, 64)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(16, 104)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(64, 64)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "Button2"
        '
        'frmAppBar
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(104, 273)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Name = "frmAppBar"
        Me.Text = "frmAppBar"
        Me.ResumeLayout(False)
 
    End Sub
 
#End Region
 
    Private Shared bar As AppBar
 
    Public Shared Sub Main()
        Dim frm As New frmAppBar
        bar = New AppBar(frm, AppBar.AppBarPos.BarLeft)
        Application.Run(frm)
    End Sub
 
    Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
        bar.UnloadAppBar()
    End Sub
End Class

________
Alle Angaben ohne Gewähr. Keine Haftung für Vorschläge, Tipps oder sonstige Hilfe, falls es schiefgeht, nur Zeit verschwendet oder man sonst nicht zufrieden ist

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
eigene windows-symbolleiste erstellen2.123Hubertus23.12.04 17:06
Re: eigene windows-symbolleiste erstellen1.252ModeratorDaveS24.12.04 11:51
Re: eigene windows-symbolleiste erstellen1.224Hubertus24.12.04 12:02
Re: eigene windows-symbolleiste erstellen1.178ModeratorDaveS24.12.04 12:22
Re: eigene windows-symbolleiste erstellen1.461Hubertus24.12.04 13:12
Re: eigene windows-symbolleiste erstellen1.146ModeratorDaveS24.12.04 13:28
Re: eigene windows-symbolleiste erstellen1.117Hubertus24.12.04 14:31
Re: eigene windows-symbolleiste erstellen3.059ModeratorDaveS28.12.04 12:19
Re: eigene windows-symbolleiste erstellen1.244Hubertus28.12.04 13:00
Re: eigene windows-symbolleiste erstellen1.287Hubertus30.12.04 12:49

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel