vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
TOP-Angebot: 17 bzw. 24 Entwickler-Vollversionen zum unschlagbaren Preis!  
 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

Visual-Basic Einsteiger
Re: VB6 - "Windowstate" einer Form, hier der Code für Modul1 
Autor: Hollie
Datum: 26.07.24 13:58

'Modul1:
Option Explicit
 
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd _
  As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias _
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" ( _
ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Const GW_HWNDFIRST = 0          'GetWindow
Private Const GW_HWNDNEXT = 2           'GetWindow
 
'------
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, _
  lpwndpl As WINDOWPLACEMENT) As Long
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private Type POINTAPI
    X As Long
    Y As Long
End Type
Private Type WINDOWPLACEMENT
    Length As Long
    flags As Long
    showCmd As Long
    ptMinPosition As POINTAPI
    ptMaxPosition As POINTAPI
    rcNormalPosition As RECT
End Type
Public Enum SW_CMD
    SW_HIDE = 0
    SW_SHOWNORMAL = 1
    SW_SHOWMINIMIZED = 2
    SW_SHOWMAXIMIZED = 3
    SW_SHOWNOACTIVATE = 4
    SW_SHOW = 5
    SW_MINIMIZE = 6
    SW_SHOWMINNOACTIVE = 7
    SW_SHOWNA = 8
    SW_RESTORE = 9
End Enum
'------
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
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_SHOWWINDOW = &H40
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
'------
 
Public RESULT&
Public RETVAL&
 
Private pResult&
Private pRetVal&
 
Private Declare Function SetWindowPlacement Lib "user32.dll" (ByVal hwnd As _
  Long, lpwndpl As WINDOWPLACEMENT) As Long
 
Public Function EnumWindows_FIND(Frm As Object, SuchTitel$, Optional _
  EXAKTE_SUCHE As Boolean) As Boolean
    Dim hwnd&, Title$  ', Result&, RetVal% sind anderweit bereits definiert.
    pRetVal = 0
    SuchTitel = StrConv(SuchTitel, 1)
    hwnd = GetWindow(Frm.hwnd, GW_HWNDFIRST)
    Do
        DoEvents
        pResult = GetWindowTextLength(hwnd) + 1
        Title = Space$(pResult)
        pResult = GetWindowText(hwnd, Title, pResult)
        Title = StrConv(Left$(Title, Len(Title) - 1), 1)
        Select Case EXAKTE_SUCHE
            Case False
                If InStr(1, Title, SuchTitel) > 0 Then
                    RETVAL = pResult
                    pRetVal = pRetVal + 1
                    If pRetVal >= 1 Then EnumWindows_FIND = True: Exit Function
                End If
            Case True
                If Title = SuchTitel Then
                    RETVAL = pResult
                    pRetVal = pRetVal + 1
                    If pRetVal >= 1 Then
                        RETVAL = hwnd
                        EnumWindows_FIND = True: Exit Function
                    End If
                End If
        End Select
        hwnd = GetWindow(hwnd, GW_HWNDNEXT)
    Loop Until hwnd = 0
End Function
 
'Fensterstatus abfragen: 0...normal, 1...minimiert, 2...maximiert
'"W.showCmd":            1...normal, 2...minimiert, 3...maximiert
Public Function GetWindowState(ByVal hwnd As Long) As SW_CMD
    Dim W As WINDOWPLACEMENT
    Select Case GetWindowPlacement(hwnd, W)
        Case 0: GetWindowState = -1
        Case Else: GetWindowState = W.showCmd - 1
    End Select
End Function
 
Public Function SetWindowState(ByVal hwnd As Long) As Long
    Dim W As WINDOWPLACEMENT
    W.Length = Len(W)
    W.flags = 0&
    W.showCmd = SW_SHOWNORMAL
 
'???? Wie hier korrekt weiter ???
    'Dieser Aufruf "zerstört" sogar den Erststart des Programms:
    'SetWindowState = SetWindowPlacement(hwnd, W)
 
End Function
 
Public Function Erstes_FENSTER_POSITIONIEREN(Tmp_hWnd) As Long
    Erstes_FENSTER_POSITIONIEREN = SetWindowPos(Tmp_hWnd, 0&, 10, 10, 0, 0, _
      SWP_NOSIZE)
End Function
 
Public Sub FormOnTop_HWND(ByVal myhWnd As Long, TOPMOST As Boolean)
    Select Case TOPMOST
        Case True: SetWindowPos myhWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + _
          SWP_NOMOVE + SWP_SHOWWINDOW
        Case False: SetWindowPos myhWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE _
        + SWP_NOMOVE + SWP_SHOWWINDOW
    End Select
End Sub
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
VB6 - "Windowstate" einer Form571Hollie26.07.24 13:53
Re: VB6 - "Windowstate" einer Form - hier der Code für die F...394Hollie26.07.24 13:56
Re: VB6 - "Windowstate" einer Form, hier der Code für Modul1493Hollie26.07.24 13:58
Re: VB6 - "Windowstate" einer Form416B.Th.28.07.24 09:57
Re: VB6 - "Windowstate" einer Form322Hollie29.07.24 15:29

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