AW: Uhr für Userform
27.09.2005 20:48:31
Sylvio
Hallo Helmut,
du brauchst ein paar funktionen in einem modul:
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Eins zum finden des excelfensters eins zum setzen des timers eins zum beenden des timers
dann noch ne variable festlegen:
Public iHwnd As Long
dann müssen noch paar subs ins modul rein:
Private Sub MeineHwnd()
Dim sClass As String, sCap As String
sClass = "XLMAIN"
iHwnd = FindWindow(sClass, sCap)
End Sub
Private Sub TimerAdresse(ByVal hwnd As Long, _
ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Tooldialog.lblZeit = Time
End Sub
Public Sub StartTime()
MeineHwnd
SetTimer iHwnd, 0, 1000, AddressOf TimerAdresse
End Sub
Public Sub EndeTime()
MeineHwnd
KillTimer iHwnd, 0
End Sub
ein paar anweisungen in die userform rein:
Private Sub UserForm_Terminate()
EndeTime
End Sub
Private Sub UserForm_Activate()
iHwnd = FindWindow(vbNullString, Tooldialog.Caption)
MoveWindow iHwnd, 0, 0, lHSize, lVSize, 1
StartTime
End Sub
das ganze gut umrühren und fertig :-)
achso Tooldialog hieß meine Userform und lblZeit das Label wo es drin angezeigt wurde
Gruß Sylvio