Herbers Excel-Forum - das Archiv
userform sichtbar im vordergrund halten
Informationen und Beispiele zu den hier genannten Dialog-Elementen:
Betrifft: userform sichtbar im vordergrund halten
von: chris b.
Geschrieben am: 10.11.2003 21:35:02
Hallo, ist es möglich eine Userform so sichtbar zu stellen das sie immer sichtbar ist ?
Ich starte eine Mappe und starte dann eine Userform mit userform.show nach diesem Befehl verstecke ich Excel mit Application.visible = false.
Jetzt habe ich nur noch die userform auf meinem Monitor aber sobald ich den Explorer starte oder ein anderes Fenster ist die userform nicht mehr im Vordergrund !Wie kann ich es schaffen das die userform immer im vordergrund blebt bis ich sie beenden ?
Danke schon mal für eure Hilfe gruß Christian
Betrifft: AW: userform sichtbar im vordergrund halten
von: RAnton
Geschrieben am: 10.11.2003 22:20:44
hallo Chris,
schau mal da nach, vielleicht hilfts.
http://www.vbarchiv.net/archiv/tipp_450.html
Gruß
RAnton
Betrifft: AW: userform sichtbar im vordergrund halten
von: chris bx
Geschrieben am: 11.11.2003 06:07:34
danke !
Betrifft: AW: Funktioniert nicht ?
von: chris b
Geschrieben am: 11.11.2003 06:22:07
Hallo, ich habe Excel 97 und da funktioniert es nicht ???
Habe erstens keinen Borderstyle 3 nur 0 und 1 und kann nicht wie beschrieben umstellen auf Borderstyle 3.
UNd folgender code ist meine Userform. Habe auch schon den auf der seite beschriebenen code eingefügt ?!
Public x1 As String
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal wIndx 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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Const GWL_STYLE = (-16)
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Dim m1
Public cb As String
Dim whandle
Private Function GetWindowTitle(ByVal hwnd As Long) As String
Dim lResult As Long, sTemp As String
lResult = GetWindowTextLength(hwnd) + 1
sTemp = Space(lResult)
lResult = GetWindowText(hwnd, sTemp, lResult)
GetWindowTitle = Left(sTemp, Len(sTemp) - 1)
End Function
Private Sub CommandButton2_Click()
cb = ComboBox1.Value
Cells(1, 1) = cb
'Unload UserForm1
'UserForm1.Hide
If OptionButton1.Value = True Then Call vordergrund
If OptionButton2.Value = True Then Call hintergrund
Label1.Caption = "Fertig"
NeueStunde = Hour(Now())
NeueMinute = Minute(Now())
NeueSekunde = Second(Now()) + 1
WarteZeit = TimeSerial(NeueStunde, NeueMinute, NeueSekunde)
Application.Wait WarteZeit
Label1.Caption = ""
End Sub
Private Sub CommandButton3_Click()
Unload UserForm1
UserForm1.Hide
Application.Visible = True
End Sub
Private Sub UserForm_Initialize()
Dim hwnd As Long, sTitle As String, lStyle As Long
hwnd = GetWindow(FindWindow(ByVal 0&, ByVal 0&), GW_HWNDFIRST)
Do
lStyle = GetWindowLong(hwnd, GWL_STYLE) And (WS_VISIBLE Or WS_BORDER)
sTitle = GetWindowTitle(hwnd)
If (lStyle = (WS_VISIBLE Or WS_BORDER)) = True And Trim(sTitle) <> "" Then
' MsgBox sTitle
ComboBox1.AddItem sTitle
End If
hwnd = GetWindow(hwnd, GW_HWNDNEXT)
Loop Until hwnd = 0
End Sub
Private Sub Form_Load()
' Minimieren/Maximieren Buttons zur
' Laufzeit anzeigen
MinMaxButton Me
' Fenster immer im Vordergrund anzeigen
TopWindow Me.hwnd
End Sub
Private Sub Timer1_Timer()
Call TopWindow(Me.hwnd)
End Sub