Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1540to1544
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

MSG Box Positionieren?

MSG Box Positionieren?
12.02.2017 16:11:03
Andi
Hallo;
Kann man eine MSG Box positionieren, so das sie nicht mehr mitten im Bildschirm, sondern rechts mittig auftaucht?
Habe nichts weiter gefunden, wo man so was einstellen könnte.
Grüße Andi

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: "Ja, kann man!" owt
12.02.2017 16:31:43
Herbert
,,,
AW: MSG Box Positionieren?
12.02.2017 16:32:08
Hajo_Zi
Hallo Andi,
Option Explicit
' 1.Teil - alles in ein Standart-Modul:
' MsgBOx an bestimmte Position
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long,  _
_
ByVal nIndex As Long) As Long
Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" _
(ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As  _
Long
Public 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
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Const GWL_HINSTANCE = (-6)
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOACTIVATE = &H10
Public Const HCBT_ACTIVATE = 5
Public Const WH_CBT = 5
Public hHook As Long
Public MsgBoxPosX As Integer
Public MsgBoxPosY As Integer
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Function WinProc(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If lMsg = HCBT_ACTIVATE Then
SetWindowPos wParam, 0, MsgBoxPosX, MsgBoxPosY, 0, 0, SWP_NOSIZE Or SWP_NOZORDER Or  _
SWP_NOACTIVATE
UnhookWindowsHookEx hHook
End If
WinProc = False
End Function
Function msg(msgText As String, msgButton As Long, msgTitel As String, xPos As Long, yPos As  _
Long)
Dim hInst As Long
Dim XLInst As Long
Dim Thread As Long
MsgBoxPosX = xPos
MsgBoxPosY = yPos
XLInst = FindWindow("xlmain", vbNullString)
hInst = GetWindowLong(XLInst, GWL_HINSTANCE)
Thread = GetCurrentThreadId()
hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProc, hInst, Thread)
MsgBox msgText, msgButton, msgTitel, 0, 0
End Function
' 2.Teil - Aufruf von überall:
Sub Aufruf_MsgBox()
Dim Dummy As Byte
'ButtonTypen:
'0 = OK
'1 = OK , Cancel
'2 = Abort , Ignore, Retry
'3 = Yes , No, Cancel
'4 = Yes , No
'5 = Retry , Cancel
'IconTypen:
'16 = Critical
'32 = Question
'48 = Exclamation
'64 = Information
'Syntax: msg(Text,Button(siehe oben),Titel,Position X-Achse,Position Y-Achse)
'Variablen: msg(as string, as Long, as String, as Long, as Long)
Dummy = msg("Ich bin Positioniert :-)", 4, "Achtung!", 5, 50)
End Sub
' Von Der Zugvogel (Mischa Reichelt   mIsCHa)
Benutze eine UserForm ist einfacher.

Anzeige
Wodka-Modul? Русский Стандарт owT
12.02.2017 19:21:39
Luc:-?
:-?
AW: Wodka-Modul? Русский Стандарт owT
12.02.2017 20:54:27
Andi
Danke für die Antworten- lass es mal lieber in der Mitte- habe eh das 64 Bit und schon wars das.
MfG Andi

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige