Code:
Option ExplicitPrivate Declare Function GetWindowPlacement Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByRef lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function MoveWindow Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal wType As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetTimer Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom 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
Private Const MB_DEFBUTTON1 = &H0&
Private Const MB_DEFBUTTON2 = &H100&
Private Const MB_DEFBUTTON3 = &H200&
Private Const MB_ICONASTERISK = &H40&
Private Const MB_ICONEXCLAMATION = &H30&
Private Const MB_ICONHAND = &H10&
Private Const MB_ICONINFORMATION = MB_ICONASTERISK
Private Const MB_ICONQUESTION = &H20&
Private Const MB_ICONSTOP = MB_ICONHAND
Private Const MB_OK = &H0&
Private Const MB_OKCANCEL = &H1&
Private Const MB_YESNO = &H4&
Private Const MB_YESNOCANCEL = &H3&
Private Const MB_ABORTRETRYIGNORE = &H2&
Private Const MB_RETRYCANCEL = &H5&
'****** nicht nötig ?! ******
''''Private Const gcClassnameMSExcel = "XLMAIN"
Private Const WM_PAINT = &HF
Private Const strBoxTitle = "Information"
Private lngxlhWnd As Long
Public Sub prcShowBox()
' ******* nicht nötig *******
''''lngxlhWnd = FindWindow(gcClassnameMSExcel, Application.Caption)
'stattdessen
'**** Acad kennt die HWND-Prop selbst******
lngxlhWnd = ActiveDocument.hwnd
SetTimer lngxlhWnd, 0, 1, AddressOf prcTimer
MessageBox lngxlhWnd, "Hallo hier bin ich.", strBoxTitle, MB_OK Or MB_ICONINFORMATION
End Sub
Private Sub prcTimer(ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Call prcKillTimer
Call prcSetWindowPos
End Sub
Private Sub prcKillTimer()
KillTimer lngxlhWnd, 0
End Sub
Private Sub prcSetWindowPos()
Dim WinEst As WINDOWPLACEMENT
Dim lngBoxhWnd As Long
lngBoxhWnd = FindWindow("#32770", strBoxTitle)
If lngBoxhWnd <> 0 Then
WinEst.Length = Len(WinEst)
GetWindowPlacement lngBoxhWnd, WinEst
' 100,100 = Position auf dem Bildschirm
MoveWindow lngBoxhWnd, 100, 100, _
WinEst.rcNormalPosition.Right - WinEst.rcNormalPosition.Left, _
WinEst.rcNormalPosition.Bottom - WinEst.rcNormalPosition.Top, WM_PAINT
End If
End Sub