Deklaration: Declare Function EnumPropsEx Lib "user32.dll" _ Alias "EnumPropsExA" ( _ ByVal hWnd As Long, _ ByVal lpEnumFunc As Long, _ ByVal lParam As Long) As Long Beschreibung: Parameter:
Rückgabewert: Beispiel: ' Fügen Sie den folgenden Code in ein öffentliches Modul ein Private Declare Function lstrlen Lib "kernel32.dll" _ Alias "lstrlenA" ( _ ByVal lpString As Any) As Long Private Declare Function lstrcpy Lib "kernel32.dll" _ Alias "lstrcpyA" ( _ ByVal lpString1 As Any, _ ByVal lpString2 As Any) As Long Private Declare Function GlobalAlloc Lib "kernel32.dll" ( _ ByVal wFlags As Long, _ ByVal dwBytes As Long) As Long Private Declare Function GlobalLock Lib "kernel32.dll" ( _ ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32.dll" ( _ ByVal hMem As Long) As Long Public Declare Function GlobalFree Lib "kernel32.dll" ( _ ByVal hMem As Long) As Long ' einige der GlobalAlloc wFlags-Konstanten Private Const GMEM_ZEROINIT = &H40 Private Const GMEM_MOVEABLE = &H2 ' Wird bei jeder gefundenen Eigenschaft von Windows aufgerufen Public Function PropEnumProcEx(ByVal hWnd As Long, ByVal lpszString As _ Long, ByVal hData As Long, ByVal dwData As Long) As Long Dim PropName As String, Retval As Long, pData As Long ' Name der Eigenschaft ermitteln PropName = Space(lstrlen(lpszString)) Retval = lstrcpy(PropName, lpszString) ' Hinzufügen des Namens in eine Combobox fall es eine ' String-Eigenschaft ist pData = GlobalLock(hData) If lstrlen(pData) < 0 Then With Form1.Combo1 If PropName = "" Then .AddItem "Unbekannt" .ItemData(.NewIndex) = hData Else .AddItem PropName End If End With End If Call GlobalUnlock(hData) ' Enumeration fortsetzen PropEnumProcEx = 1 End Function ' Erstellt einen Speicherblock mit String-Inhalt Public Function StringToHandle(ByVal Value As String) As Long Dim hGlobal As Long, pGlobal As Long ' Speicherblock erstellen und Pointer ermitteln hGlobal = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, lstrlen(Value) * 3) pGlobal = GlobalLock(hGlobal) ' String in den Speicher kopieren Call lstrcpy(pGlobal, Value) ' Speicherblock freigeben Call GlobalUnlock(hGlobal) StringToHandle = hGlobal End Function ' Ermittelt einen String anhand eines Handles Public Function HandleToString(ByVal Value As Long) As String Dim TmpStr As String, pGlobal As Long ' Speicherblock Pointer ermitteln pGlobal = GlobalLock(Value) ' String aus den Speicher kopieren TmpStr = Space(lstrlen(pGlobal)) Call lstrcpy(TmpStr, pGlobal) ' Speicherblock freigeben Call GlobalUnlock(Value) HandleToString = TmpStr End Function ' Der nun folgende Code muss in eine Form geschrieben werden Private Declare Function EnumPropsEx Lib "user32.dll" _ Alias "EnumPropsExA" ( _ ByVal hWnd As Long, _ ByVal lpEnumFunc As Long, _ ByVal lParam As Long) As Long Private Declare Function GetProp Lib "user32.dll" _ Alias "GetPropA" ( _ ByVal hWnd As Long, _ ByVal lpString As String) As Long Private Declare Function RemoveProp Lib "user32.dll" _ Alias "RemovePropA" ( _ ByVal hWnd As Long, _ ByVal lpString As String) As Long Private Declare Function SetProp Lib "user32.dll" _ Alias "SetPropA" ( _ ByVal hWnd As Long, _ ByVal lpString As String, _ ByVal hData As Long) As Long ' einige Fenstereigenschaften hinzufügen Private Sub Form_Load() Dim Retval As Long Call SetProp(Me.hWnd, "Autor", StringToHandle("LonelySuicide666")) Call SetProp(Me.hWnd, "Datum", StringToHandle("08.08.1979")) Call SetProp(Me.hWnd, "Website", StringToHandle("http://www.vbapihelpline.de")) Call SetProp(Me.hWnd, "E-Mail", StringToHandle("webmaster@vbapihelpline.de")) ' Alle Eigenschaften des Fensters enumerieren Call EnumPropsEx(Me.hWnd, AddressOf PropEnumProcEx, 0&) Combo1.ListIndex = 0 End Sub ' Eigenschaft bei Auswahl auslesen Private Sub Combo1_Click() Dim Retval As Long ' Eigenschaft auslesen und anzeigen If Combo1.Text = "Unbekannt" Then Retval = Combo1.ItemData(Combo1.ListIndex) Else Retval = GetProp(Me.hWnd, Combo1.Text) End If Label1.Caption = HandleToString(Retval) End Sub ' Beim Entladen Speicherblöcke und Fenstereigenschaften entfernen Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Dim Retval As Long, i As Integer For i = 0 To Combo1.ListCount - 1 Retval = GetProp(Me.hWnd, Combo1.List(i)) Call RemoveProp(Me.hWnd, Combo1.List(i)) Call GlobalFree(Retval) Next i End Sub Diese Seite wurde bereits 8.252 mal aufgerufen. |
Neu! sevCoolbar 3.0 Professionelle Toolbars im modernen Design! Mit sevCoolbar erstellen Sie in wenigen Minuten ansprechende und moderne Toolbars und passen diese optimal an das Layout Ihrer Anwendung an (inkl. große Symbolbibliothek) - für VB und MS-Access Buchempfehlung Tipp des Monats März 2024 Dieter Otter UTF-8 Konvertierung von Dateien und Strings VB6 selbst verfügt über keine Funktionen zur UTF-8 Konvertierung von Daten. Mit Hilfe des ADODB.Stream-Objekts lassen sich diese fehlenden Funktionen aber schnell nachrüsten. 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 |
||||||||||||||||
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. |