Hoi,
ich wollte mal fragen, wie man eine MsgBox zB farbig machen kann, oder bestimmte Sachen, wie den Rand usw. ändern kann.
Die soll ned so trist ausschauen
MsgBox mit graflicher Gestaltung machen
-
- [ offen ]
-
Nightfire -
8. Mai 2008 um 19:11 -
Geschlossen -
Erledigt
-
-
- Offizieller Beitrag
Geht nur, wenn Du Dir Deine eigene MsgBox programmierst (eigene Funktion).
-
wie würde das dann ca. aussehen?
-
- Offizieller Beitrag
Kommt darauf an, was in der MsgBox alles angezeigt werden soll (nur Text, Text+Bild) und was für Buttons Du haben willst.
Schreib doch mal, was Dir da so vorschwebt. Für eine universelle MsgBox fehlt mir momentan die Zeit. -
Also, sozusagen eine eigene GUI
( GUICreate ... GUICtrlCreate... ) -
es sollte eine art inputbox werden, runder rand und zb. ein dunkles blau als farbe.
zb -
- Offizieller Beitrag
Vielleicht sowas:
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>$out = _InputBox('Bitte Namen eingeben!')
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
MsgBox(0, '', $out)Func _InputBox($text)
[/autoit]
$OnEvent = Opt('GUIOnEventMode', 0)
$GUI_Input = GUICreate('Inputbox', 400, 200, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
WinSetOnTop('Inputbox', '', 1)
GUICtrlCreatePic('rund.gif', 0, 0, 400, 200)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($text, 100, 60, 240, 30)
GUICtrlSetColor(-1, '0xffff00')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 14, 800, 0, 'Times New Roman')
$Input = GUICtrlCreateInput('', 100, 100, 200, 30)
GUICtrlSetFont(-1, 14, 800, 0, 'Times New Roman')
GUICtrlSetBkColor(-1, '0xfffffe')
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Input
ExitLoop
EndSwitch
WEnd
$out = GUICtrlRead($Input)
GUIDelete($GUI_Input)
Opt('GUIOnEventMode', $OnEvent)
Return $out
EndFuncFür das Beispiel brauchst Du noch das Bild aus dem Anhang.
-
Habe auch mal versucht 'ne eigene MsgBox zu basteln, gar nicht so einfach ...
Spoiler anzeigen
[autoit]$iMsg = MessageBox('Dies ist ein Test-String mit Zeichenfolgen WWWWWWWWWW DDDDDDiiiiiiiiiiDDDDDDggggggggggDDDDDDDDDDDDDD!', _
[/autoit] [autoit][/autoit] [autoit]
'&Hinzufügen', '&Entfernen', '&Abbrechen')MsgBox(266304, Default, 'Der Rückgabewert von MessageBox ist : ' & $iMsg)
[/autoit] [autoit][/autoit] [autoit]Func MessageBox($szString, $szButton1, $szButton2 = '', $szButton3 = '')
[/autoit] [autoit][/autoit] [autoit]
Local $arString, $iWidth, $iHeight, $idButton1, $idButton2, $idButton3, $iLeft1, $iLeft2, $iLeft3, $iTop
$arString = StringSplit(StringReplace($szString, ' ', 4), '')
Dim $ptn[13]
$ptn[2] = '[lji' & "'" & '"´`!,\.:;]'
$ptn[3] = '[rtfI\(\)\[\]{}-]'
$ptn[4] = '[\*]'
$ptn[5] = '[\\/ sxyzJ]'
$ptn[6] = '[_+~=$§&%€\?<>abcdeghknopquvßFL]'
$ptn[7] = '[#ÄABCEKPSTVXYZ]'
$ptn[8] = '[wmÖÜDGHNORQU]'
$ptn[9] = '[M]'
$ptn[11] = '[W@\t]'
For $ic = 1 To $arString[0]
For $i = 2 To 11
If $i = 10 Then
ContinueLoop
Else
$arString[$ic] = StringRegExpReplace($arString[$ic], $ptn[$i], $i)
EndIf
Next
$iWidth += $arString[$ic]
Next
If $iWidth <= 400 Then
$iWidth = 400
Else
$iWidth +=120
EndIf
$iHeight = 240
; Button
If Not $szButton2 And Not $szButton3 Then
$iLeft1 = ($iWidth / 2) - 40
ElseIf $szButton2 And Not $szButton3 Then
$iLeft1 = ($iWidth / 2) - 90
$iLeft2 = $iLeft1 + 100
ElseIf $szButton2 And $szButton3 Then
$iLeft1 = ($iWidth / 2) - 140
$iLeft2 = $iLeft1 + 100
$iLeft3 = $iLeft2 + 100
EndIf
$iTop = $iHeight - 80
$hWndMsgBox = GUICreate(@ScriptName, $iWidth, $iHeight, -1, -1, BitOR($WS_SIZEBOX,$WS_CAPTION, $DS_SETFOREGROUND), $WS_EX_TOPMOST)
; $hWndMsgBox = GUICreate(@ScriptName, $iWidth, $iHeight, -1, -1, _
; BitOR($WS_VISIBLE, $WS_TABSTOP, $DS_MODALFRAME, $DS_SETFOREGROUND), _
; BitOR($WS_EX_APPWINDOW, $WS_EX_TOPMOST, $WS_EX_CLIENTEDGE, $WS_EX_DLGMODALFRAME ))
$idButton1 = GUICtrlCreateButton($szButton1, $iLeft1, $iTop, 80, 25)
If $iLeft2 Then $idButton2 = GUICtrlCreateButton($szButton2, $iLeft2, $iTop, 80, 25)
If $iLeft3 Then $idButton3 = GUICtrlCreateButton($szButton3, $iLeft3, $iTop, 80, 25)
$idIcon = GUICtrlCreateIcon(@AutoItExe, 0, 20, 20, 48, 48)
GUICtrlSetState($idIcon, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel($szString, 90, 40)
GUISetState(@SW_SHOW)
; Send('{LALT}')While True
[/autoit] [autoit][/autoit] [autoit]
Switch GUIGetMsg()
Case -3
Exit
Case $idButton1
GUIDelete($hWndMsgBox)
Return 1
Case $idButton2
GUIDelete($hWndMsgBox)
If $idButton2 Then Return 2
Case $idButton3
GUIDelete($hWndMsgBox)
If $idButton3 Then Return 3
EndSwitch
WEndEndFunc
[/autoit]Gruß
Greenhorn -
Oscar, deine funktioniert nicht.
-
- Offizieller Beitrag
Was genau meinst Du mit "funktioniert nicht"?
Bei mir funktioniert das.
-
Funktioniert optimal, er hat warscheinlich das Bild nicht im gleichen Verzeichnis wie die .au3.
-
ich denke es liegt an dem Include
-
öhh, warum denn am Include??? Da muss das Bild im gleichen Ordner wie das Script sein
So gehts ohne Layered und Bild
Spoiler anzeigen
[autoit]#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]$out = _InputBox('Bitte Namen eingeben!')
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
MsgBox(0, '', $out)Func _InputBox($text)
[/autoit] [autoit][/autoit] [autoit]
$OnEvent = Opt('GUIOnEventMode', 0)
$GUI_Input = GUICreate('Inputbox', 400, 200, -1, -1, $WS_POPUP)
WinSetOnTop('Inputbox', '', 1)
_EllipticGUI($GUI_Input) ; Make it Elliptic
GUISetBkColor(0x0000BB)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($text, 100, 60, 240, 30)
GUICtrlSetColor(-1, '0xffff00')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 14, 800, 0, 'Times New Roman')
$Input = GUICtrlCreateInput('', 100, 100, 200, 30)
GUICtrlSetFont(-1, 14, 800, 0, 'Times New Roman')
GUICtrlSetBkColor(-1, '0xfffffe')
GUISetState()
While 1
_ClickDrag($GUI_Input)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Input
ExitLoop
EndSwitch
WEnd
$out = GUICtrlRead($Input)
GUIDelete($GUI_Input)
Opt('GUIOnEventMode', $OnEvent)
Return $out
EndFuncFunc _EllipticGUI($h_win)
[/autoit]
Dim $pos, $ret, $ret2
$pos = WinGetPos($h_win)
$ret = DllCall( "gdi32.dll", "ptr", "CreateEllipticRgn", "int", 0, "int", 0, "int", $pos[2], "int", $pos[3])
If $ret[0] Then
$ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
If $ret2[0] Then
Return 1
Else
Return 0
EndIf
Else
Return 0
EndIf
EndFunc ;==>RoundGUI
; Dragging window whwn MoseDown
Func _ClickDrag($GUI)
Local $mouse = GUIGetCursorInfo($GUI)
If $mouse[2] = 1 Then
Local $pos = WinGetPos($GUI)
$pos[0] = MouseGetPos(0)-$pos[0]
$pos[1] = MouseGetPos(1)-$pos[1]
While $mouse[2]
WinMove($GUI,"",MouseGetPos(0)-$pos[0],MouseGetPos(1)-$pos[1])
$mouse = GUIGetCursorInfo($GUI)
WEnd
EndIf
EndFunc -
Jetzt gehts
oh man, ich will sowas auch können....
Wie macht man sowas, oder nach welchem Schema überlegt man da? -
Ich hab mir mal in CS3 ne Grafik für die MsgBox gemacht.
Und ich weiß ja auch, wie man die Einfügt, aber da sind immer so weiße Dinger am Rand, wie kann ich die wegkriegen?
Im Anhang das BildSpoiler anzeigen
[autoit]#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]$out = _InputBox('Bitte Namen eingeben!')
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
MsgBox(0, '', $out)Func _InputBox($text)
[/autoit]
$OnEvent = Opt('GUIOnEventMode', 0)
$GUI_Input = GUICreate('Inputbox', 400, 200, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
WinSetOnTop('Inputbox', '', 1)
GUICtrlCreatePic('Unbenannt-1.gif', 0, 0, 400, 200)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($text, 100, 60, 240, 30)
GUICtrlSetColor(-1, '0xffff00')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 14, 800, 0, 'Times New Roman')
$Input = GUICtrlCreateInput('', 100, 100, 200, 30)
GUICtrlSetFont(-1, 14, 800, 0, 'Times New Roman')
GUICtrlSetBkColor(-1, '0xfffffe')
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Input
ExitLoop
EndSwitch
WEnd
$out = GUICtrlRead($Input)
GUIDelete($GUI_Input)
Opt('GUIOnEventMode', $OnEvent)
Return $out
EndFunc -
Dafür ist $WS_EX_LAYERED zuständig. Diese Option nimmt die Farbe des Pixels links oben in der Exke und macht die Transparent Wenn du eine einfache RechTecksform hast, solltest du diese OPtion entfernen
-
das die Lösung so einfach ist und auch noch funzt, hätte ich ned gedacht xD