Tach.
Hab mal ne MsgBox gemacht, bei der man die Position und Hintergrundfarbe wärhlen kann.
Will sie noch so verändern, dass man auch die Größe ändern kann.
Das dauert aber etwas.
Die Rückgabewerte und Flags sind die gleichen wie in einer normalen MsgBox.
Hier mal das Script: ( Beispiel ist unten im Script )
Spoiler anzeigen
; ==================================================================================================
;
; Name: _MsgBox
; Funktion: Eine einfach MsgBox, bei der man Position und Farbe ändern kann.
;
; Parameter: $Flag: Der Flag gibt an, wie die Box aussieht, und welche Buttons angezeigt werden.
; $ExFlag: Bestimmt, welches Icon angezeigt werden soll.
; $Titel: Titel der MsgBox.
; $Text: Text, der in der MsgBox stehen soll.
; .....|Optional|.....
; $Width: Bestimmt die Breite der msgBox. (Standart = 245)
; .....|Optional|.....
; $Heigth: Bestimmt die Höhe der MsgBox. (Standart = 200)
; .....|Optional|.....
; $Left: X-Position der MsgBox. (-1 definiert die Mitte des Bildschirms)
; .....|Optional|.....
; $Top: Y-Position der MsgBox. (-1 definiert die Mitte des Bildschirms)
; .....|Optional|.....
; $Color: Hintergrundfarbe der MsgBox (Standart = 0xCCCCCC)
; .....|Optional|.....
; $OnTop: 1 = Bestimmt, dass die MsgBox immer im Vordergrund steht. (Standart = 0)
; .....|Optional|.....
; $Sound: 1 = Bestimmt, dass der Sound an ist. (Standart = 1)
;
; ==================================================================================================
#include <WindowsConstants.au3>
Func _MsgBox ($Flag, $ExFlag, $Titel, $Text, $Width = 245, $Height = 200, $Left = -1, $Top = -1, $Color = 0xCCCCCC, $OnTop = 0, $SoundPlay = 1)
Local $iOnEventMode = Opt("GUIOnEventMode", 0)
Local $Size = 7, $FontWidth = 700, $return, $Sound = @WindowsDir & "\Media\", $PosX = $Height-25
$MsgGUI = GUICreate ($Titel, $Width, $Height, $Left, $Top)
If $OnTop = 1 Then WinSetOnTop ($MsgGUI, "", 1)
GUISetBkColor ($Color)
GUISetIcon ("User32.dll", -1)
GUISetState (@SW_SHOW, $MsgGUI)
$MsgText = GUICtrlCreateLabel ($Text, 60, 10, $Width-65, $Height-40)
GUICtrlSetBkColor (-1, $Color)
; -------------------------------------
Switch $Flag
Case 0
$Ex1 = Execute (($Width-75)/2)
Case 1, 4, 5
$Ex2 = Execute (($Width-150)/3)
$Ex3 = Execute (($Ex2*2)+75)
Case 2, 3, 6
$Ex4 = Execute (($Width-225)/4)
$Ex5 = Execute (($Ex4*2)+75)
$Ex6 = Execute (($Ex4*3)+(75*2))
EndSwitch
; -------------------------------------
Switch $ExFlag
Case 0
GUICtrlCreateIcon ("User32.dll", -1, 10, 10, 32, 32)
If $SoundPlay = 1 Then SoundPlay ($Sound & "Windows XP-Ping.wav")
Case 16
GUICtrlCreateIcon ("User32.dll", -4, 10, 10, 32, 32)
If $SoundPlay = 1 Then SoundPlay ($Sound & "Windows XP-kritischer Fehler.wav")
Case 32
GUICtrlCreateIcon ("User32.dll", -3, 10, 10, 32, 32)
If $SoundPlay = 1 Then SoundPlay ($Sound & "chimes.wav")
Case 48
GUICtrlCreateIcon ("User32.dll", -2, 10, 10, 32, 32)
If $SoundPlay = 1 Then SoundPlay ($Sound & "Windows XP-Hinweis.wav")
Case 64
GUICtrlCreateIcon ("User32.dll", -5, 10, 10, 32, 32)
If $SoundPlay = 1 Then SoundPlay ($Sound & "windows xp-informationsleiste.wav")
EndSwitch
; -------------------------------------
If $Flag = 0 Then
$Button1 = GUICtrlCreateButton ("Ok", $Ex1, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
While 1
$Msg1 = GUIGetMsg ()
Switch $msg1
Case $Button1
$return = 1
ExitLoop
Case -3
$return = 2
ExitLoop
EndSwitch
WEnd
EndIf
; -------------------------------------
If $Flag = 1 Then
$Button2 = GUICtrlCreateButton ("Ok", $Ex2, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button3 = GUICtrlCreateButton ("Abbrechen", $Ex3, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
While 1
$Msg2 = GUIGetMsg ()
Switch $msg2
Case $Button2
$return = 1
ExitLoop
Case $Button3
$return = 2
ExitLoop
Case -3
$return = 2
ExitLoop
EndSwitch
WEnd
EndIf
; -------------------------------------
If $Flag = 2 Then
$Button4 = GUICtrlCreateButton ("Abbrechen", $Ex4, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button5 = GUICtrlCreateButton ("Wiederhohlen", $Ex5, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button6 = GUICtrlCreateButton ("Ignorieren", $Ex6, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
While 1
$Msg3 = GUIGetMsg ()
Switch $msg3
Case $Button4
$return = 2
ExitLoop
Case $Button5
$return = 4
ExitLoop
Case $Button6
$return = 5
ExitLoop
Case -3
$return = 2
ExitLoop
EndSwitch
WEnd
EndIf
; -------------------------------------
If $Flag = 3 Then
$Button7 = GUICtrlCreateButton ("Ja", $Ex4, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button8 = GUICtrlCreateButton ("Nein", $Ex5, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button9 = GUICtrlCreateButton ("Abbrechen", $Ex6, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
While 1
$Msg4 = GUIGetMsg ()
Switch $msg4
Case $Button7
$return = 6
ExitLoop
Case $Button8
$return = 7
ExitLoop
Case $Button9
$return = 2
ExitLoop
Case -3
$return = 2
ExitLoop
EndSwitch
WEnd
EndIf
; -------------------------------------
If $Flag = 4 Then
$Button10 = GUICtrlCreateButton ("Ja", $Ex2, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button11 = GUICtrlCreateButton ("Nein", $Ex3, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
While 1
$Msg4 = GUIGetMsg ()
Switch $msg4
Case $Button10
$return = 6
ExitLoop
Case $Button11
$return = 7
ExitLoop
Case -3
$return = 2
ExitLoop
EndSwitch
WEnd
EndIf
; -------------------------------------
If $Flag = 5 Then
$Button12 = GUICtrlCreateButton ("Wiederhohlen", $Ex2, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button13 = GUICtrlCreateButton ("Abbrechen", $Ex3, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
While 1
$Msg4 = GUIGetMsg ()
Switch $msg4
Case $Button12
$return = 4
ExitLoop
Case $Button13
$return = 2
ExitLoop
Case -3
$return = 2
ExitLoop
EndSwitch
WEnd
EndIf
; -------------------------------------
If $Flag = 6 Then
$Button14 = GUICtrlCreateButton ("Abbrechen", $Ex4, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button15 = GUICtrlCreateButton ("Wiederhohlen", $Ex5, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
$Button16 = GUICtrlCreateButton ("Weiter", $Ex6, $PosX, 75, 20)
GUICtrlSetFont (-1, $Size, $FontWidth)
While 1
$Msg4 = GUIGetMsg ()
Switch $msg4
Case $Button14
$return = 2
ExitLoop
Case $Button15
$return = 4
ExitLoop
Case $Button16
$return = 11
ExitLoop
Case -3
$return = 2
ExitLoop
EndSwitch
WEnd
EndIf ;==> Flags
; ---
GUIDelete($MsgGUI)
Opt("GUIOnEventMode", $iOnEventMode)
Return($return)
EndFunc ;==> _MsgBox
; ---
; ---
; ---
; BEISPIEL ( Um die Udf zu benutzen, entweder ab hier löschen, oder auskommentieren!
_MsgBox (0, 64, "Titel der MsgBox", "Dies ist der Text, der in der MsgBox stehen soll." & @CRLF & @CRLF & "Das steht 2 Zeilen weiter.")
MfG
EDIT: Neue Version.
Jetz kann man auch noch bestimmen, ob die MsgBox immer im Vordergund sein soll oder nicht ($OnTop)...
Edit: Neue version, nun kann man die Sounds noch ausschalten.
EDIT: Neue Version: Nun lässt sich auch die Größe der MsgBox verändern. Dabei bleiben das Label und die Buttons immder im Verhältniss zur Größe.