AW: MsgBox verschieben ?
12.09.2006 17:19:13
Nepumuk
Hallo Michael,
da kenne ich mehrere Varianten. Die von mir bevorzugte:
' **********************************************************************
' Modul: Modul3 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Private Declare Function GetVbaProjekt Lib "vba332.dll" Alias "EbGetExecutingProj" ( _
ByRef hVBA As Long) As Long
Private Declare Function SetWindowPos Lib "user32.dll" ( _
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 SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" ( _
ByVal idHook As Long, _
ByVal lpfn As Long, _
ByVal hmod As Long, _
ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32.dll" ( _
ByVal hHook As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32.dll" () As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOACTIVATE = &H10
Private Const HCBT_ACTIVATE = 5
Private Const WH_CBT = 5
Private hHook As Long
Private Const posX = 100&
Private Const posY = 100&
Private Function WinProc(ByVal lMsg As Long, ByVal wParam _
As Long, ByVal lParam As Long) As Long
If lMsg = HCBT_ACTIVATE Then
SetWindowPos wParam, 0, posX, posY, 0, 0, SWP_NOSIZE Or _
SWP_NOZORDER Or SWP_NOACTIVATE
UnhookWindowsHookEx hHook
End If
WinProc = False
End Function
Public Sub prcShowBox3()
Dim hInst As Long, Thread As Long
GetVbaProjekt hInst
Thread = GetCurrentThreadId()
hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProc, _
hInst, Thread)
MsgBox "Hallo, da bin ich", 64, "Information"
End Sub
Gruß
Nepumuk