Hier der Code, dass die Form immer im Vordergrund bleibt. Du brauchst ne Form und nen Modul.
Form:
Option Explicit
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 HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private XPos&, YPos&
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong _ As Long) As Long
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOZORDER = &H4
Private Const SWP_REFRESH = SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or _
SWP_NOACTIVATE Or SWP_FRAMECHANGED
Private Const GWL_STYLE = (-16)
Private Sub Form_Load()
TopWindow Me.hwnd
End Sub
Public Sub FormOnTop(ByVal hwnd As Long, ByVal OnTop As Boolean)
If OnTop Then
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub
Public Sub TopWindow(hwnd As Long)
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
End Sub Und fürs Modul:
Option Explicit
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 Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong _ As Long) As Long
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOZORDER = &H4
Private Const SWP_REFRESH = SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or _
SWP_NOACTIVATE Or SWP_FRAMECHANGED
Private Const GWL_STYLE = (-16)
Private Const HWND_TOPMOST = -1 Hinweis: In der IDE funzt das nich bei Windows Fenstern. Da geht es erst, wenn du die exe-Datei hast. Du kannst trotzdem prüfen, ob es geht, denn wenn es funzt, dürfte die IDE beim starten(F5) nich mehr in den Vordergrund kommen.
Ansonsten einfach mal kurz die exe erstellen und testen.
Um etwas in der Registry zu speichern nehme ich folgendes:
speichern
SaveSetting (App.Title, "optionen", "bla", bla) auslesen
GetSetting(App.Title, "optionen", "bla", bla) Die Begriffe in der Klammer kannst du selber wählen. Die quickhelp in vb erklärt alles in der Klammer ganz gut. Einfach die Klammer setzen, dann sagt vb dir schon was es will.
Falls trotzdem noch Fragen sind, einfach fragen.
----------------------------------------------------------------
vb@rchiv =/= To boldly go where no programmer has gone before =/=
|