| |

Suche Visual-Basic CodeMS kann das, und wir können das schon längst! | |  | Autor: Tolwyn | Datum: 29.08.01 18:09 |
| .... Naja seit etwa 10 Minuten
Das geht mit der netten API Funktion "SHAppBarMessage" der Shell32Lib.
Damit kann eine Application Bar erstellt werden, die alles hat was man braucht.
Vorbereitung:
1. Den unten aufgeführten Code in ein Neues Modul kopieren.
2. Ein Form anlegen mit dem Namen „frmAppBar“.
3. Auf diesem Form in der linken oberen Ecke ein Steuerelement plazieren, welches die Mindesthöhe bzw. –breite der AppBar vorgibt.
4. Einen Button in der linken oberen Ecke des Forms plazieren, welcher die Funktion „UnloadAppBar“ aufruft. (WICHTIG!!!)
5. Das Startobjekt des Projektes auf "Sub Main" stellen.
6. Mit F5 starten und schauen was passiert...
Option Explicit
' API Deklarationen
Private Declare Function SHAppBarMessage Lib "Shell32.dll" (ByVal _
dwMessage As Long, pData As APPBARDATA) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd _
As Long, ByVal hwndInsertAfter As Long, ByVal X As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
' Types für die API
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End Type
' 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
Public frmAppForm As Form
Public bDocked As Boolean
Private lBorder As Long
' AppBar Informationen
Private APD As APPBARDATA
Private lDockMode As Long
Private lXTwips As Long
Private lYTwips As Long
Sub Main()
lXTwips = Screen.TwipsPerPixelX
lYTwips = Screen.TwipsPerPixelY
lBorder = 0
LoadAppBar frmAppBar, BarRight
End Sub
Public Sub LoadAppBar(AppForm As Form, Position As AppBarPos)
Dim lTop, lBottom As Long
Dim lLeft, lRight As Long
Dim lWidth, lHeight As Long
Dim lMinSize As Long ' minimale Höhe oder Breite der Bar in Pixel
Dim WTBPos As APPBARDATA
lDockMode = Position
Set frmAppForm = AppForm
bDocked = True
' Neue AppBar anlegen
Call SHAppBarMessage(ABM_NEW, APD)
' Je nach Position die Variablen füllen
Select Case lDockMode
Case ABE_LEFT
lMinSize = frmAppForm.fraBack.Width / lYTwips
lLeft = 0
lTop = 0
lRight = lMinSize + lBorder
lBottom = Screen.Height
lWidth = lMinSize * lXTwips
lHeight = Screen.Height
Case ABE_TOP
lMinSize = frmAppForm.fraBack.Height / lXTwips
lLeft = 0
lTop = 0
lRight = Screen.Width / lXTwips
lBottom = lMinSize + lBorder
lWidth = Screen.Width
lHeight = lMinSize * lYTwips
Case ABE_RIGHT
lMinSize = frmAppForm.fraBack.Width / lYTwips
lLeft = Screen.Width / lXTwips - lMinSize - lBorder
lTop = 0
lRight = Screen.Width / lXTwips
lBottom = lMinSize + lBorder
lWidth = lMinSize * lXTwips
lHeight = Screen.Height
Case ABE_BOTTOM
lMinSize = frmAppForm.fraBack.Height / lXTwips
lLeft = 0
lTop = Screen.Height / lXTwips - lMinSize - lBorder
lRight = Screen.Width / lXTwips
lBottom = Screen.Height / lXTwips
lWidth = Screen.Width
lHeight = (lBottom - lTop) * lYTwips
End Select
'--------------------------------------------------
'Nun noch die Windows Taskbar berücksichtigen
Call SHAppBarMessage(ABM_GETTASKBARPOS, WTBPos)
'--------------------------------------------------
' Taskbar unten
If WTBPos.uEdge = ABE_BOTTOM And lDockMode = ABE_BOTTOM Then
lTop = WTBPos.rc.Top - lMinSize - lBorder
lBottom = WTBPos.rc.Bottom
ElseIf WTBPos.uEdge = ABE_BOTTOM And _
(lDockMode = ABE_LEFT Or lDockMode = ABE_RIGHT) Then
lHeight = WTBPos.rc.Top * lYTwips
'--------------------------------------------------
' Taskbar oben
ElseIf WTBPos.uEdge = ABE_TOP And lDockMode = ABE_TOP Then
lTop = WTBPos.rc.Bottom
lBottom = lTop + lMinSize
ElseIf WTBPos.uEdge = ABE_TOP And _
(lDockMode = ABE_LEFT Or lDockMode = ABE_RIGHT) Then
lTop = WTBPos.rc.Bottom
lHeight = Screen.Height - WTBPos.rc.Bottom * lYTwips
'--------------------------------------------------
' Taskbar links
ElseIf WTBPos.uEdge = ABE_LEFT And lDockMode = ABE_LEFT Then
lLeft = WTBPos.rc.Right
ElseIf WTBPos.uEdge = ABE_LEFT And _
(lDockMode = ABE_TOP Or lDockMode = ABE_BOTTOM) Then
lLeft = WTBPos.rc.Right
lWidth = Screen.Width - WTBPos.rc.Right * lYTwips
'--------------------------------------------------
' Taskbar rechts
ElseIf WTBPos.uEdge = ABE_RIGHT And lDockMode = ABE_RIGHT Then
lLeft = WTBPos.rc.Left - lMinSize
ElseIf WTBPos.uEdge = ABE_RIGHT And _
(lDockMode = ABE_TOP Or lDockMode = ABE_BOTTOM) Then
lWidth = WTBPos.rc.Left * lYTwips
End If
' 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
Call SHAppBarMessage(ABM_SETPOS, APD)
' Nun das Form an die Position der AppBar bringen
DoEvents
With frmAppForm
.Show
Call SetWindowPos(.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW)
.Top = lTop * lXTwips
.Left = lLeft * lYTwips
.Width = lWidth
.Height = lHeight
End With
End Sub
Public Sub UnloadAppBar()
If bDocked Then Call SHAppBarMessage(ABM_REMOVE, APD)
bDocked = False
End Sub LoadAppBar erwartet als Übergabe ein Form, welches als AppBar fungieren soll und die Position (BarLeft, BarTop, BarRight oder BarBottom)
Gruß
Tolwyn
PS Kann ich den Kopf aus der MSDN nun wieder rausnehmen ? |  |
 | 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 |
  |
|
Neu! sevEingabe 3.0 
Einfach stark!
Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. Weitere InfosTipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) Access-Tools Vol.1 
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|
|
|
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
|
|