Hallo Zusammen
ich habe eine Gui geschrieben, welche ein PNG im hintergrund hat, möchte aber das ereignis, das beim klicken auf ein Bild in der child Gui erzeugt wird, in der main gui auswerten und als auslöser für eine funktion nutzen. Nun das funktioniert bei mir noch nicht....
Ich hoffe jemand kann mir dazu den entscheidenden Tipp geben.
Vielen Dank.
Ich möchte noch darauf hinweise, das der gepostete Script nur ein Prototyp ist und noch nicht voll funktionsfähig. Das Scripdesign ist auch noch etwas chaotisch, also überseht das einfach mal...
Hier dann mal der Script: (Aufgrund der Grösse, ist dieses Script mit Grafiken auf Rapidshare zu finden >>Klick<< )
edit:
im script ist mir noch ein kleiner deklarierungsfehler unterlaufen. ($i1 war nicht deklariert... ) Es funktioniert leider immer noch nicht.
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: Tobias Wüst und Andreas Müller
Script Function:
Installationsmenü mit spezieller Grafik
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit];#NoTrayIcon
#include <GDIPlus.au3>
#include <GuiComboBox.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
Opt("MustDeclareVars", 0)
Global Const $AC_SRC_ALPHA = 1
[/autoit] [autoit][/autoit] [autoit]; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\icons\dvdcase.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
; Extract image width and height from PNG
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
; Create layered window
$GUI = GUICreate("Background", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
WinSetOnTop($GUI, "", 0)
;fade in png background
$i = 255
;For $i = 0 To 255 Step 10
SetBitmap($GUI, $hImage, $i)
;Next
; create child MDI gui window to hold controls
$controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)
; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\icons\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)
$Exit = GUICtrlCreateButton("Exit", 1190, 40, 50, 40, 0x0001)
[/autoit] [autoit][/autoit] [autoit]$msg = "I n s t a l l i e r t W i r d :"
[/autoit] [autoit][/autoit] [autoit]$lable = _GUICtrlCreateLabelEx($msg, 870, 250, $SS_LEFT, 0xFFFFFF, 12, 40, 1, "Arial")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x000000)
$msg1 = "S p i e l N a m e"
[/autoit] [autoit][/autoit] [autoit]$lable1 = _GUICtrlCreateLabelEx($msg1, 895, 560, $SS_LEFT, 0xFFFFFF, 12, 40, 1, "Arial")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x000000)
$msg2 = "I n s t a l l i e r t i s t :"
[/autoit] [autoit][/autoit] [autoit]$lable2= _GUICtrlCreateLabelEx($msg2, 210, 50, $SS_LEFT, 0xFFFFFF, 12, 40, 1, "Arial")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x000000)
$progressbar001 = GUICtrlCreateProgress (850, 600, 210, 10)
[/autoit] [autoit][/autoit] [autoit]$progressbar002 = GUICtrlCreateProgress (200, 800, 210, 10)
GUISetState()
$controlGui2 = GUICreate("2ndControlGUI", 100, 100, 150, 80, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TRANSPARENT, $WS_EX_MDICHILD), $GUI)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\icons\Counter-Strike Source (2).gif", 0, 0, 100, 100)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
;GUICtrlCreateButton("button", 300, 400, 100, 100, $BS_BITMAP)
;GUICtrlSetImage(-1, @ScriptDir & "\icons\Counter-Strike Source (2).gif", 1)
;GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If $cmdline[0] >= 1 Then
MsgBox(0, "Information", "Es wurde ein Parameter mitgegeben.")
EndIf
Menu()
; Release resources
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
Func Menu()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
While 1
$nMsg001 = GUIGetMsg(0)
Switch $nMsg001 ; Beginn der 'Switch'-Anweisung; -------------------------------------------------------------------------------------------------------------------------------------------------------------
Case $Pic1 ; Testen
MsgBox(0, "Test", "Es geht soweit.") ; War/Ist nur zum testen.
Prozess_laeuft()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
#cs Case $Pic2 ; Testen
; MsgBox(0, "Test", "Es geht soweit.", 2) ; War/Ist nur zum testen.
Prozess_laeuft()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
Case $Pic3 ; Testen
; MsgBox(0, "Test", "Es geht soweit.", 2) ; War/Ist nur zum testen.
Prozess_laeuft()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
Case $Pic4 ; Testen
; MsgBox(0, "Test", "Es geht soweit.", 2) ; War/Ist nur zum testen.
Prozess_laeuft()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
Case $Pic5 ; Testen
; MsgBox(0, "Test", "Es geht soweit.", 2) ; War/Ist nur zum testen.
Prozess_laeuft()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
Case $Pic6 ; Testen
; MsgBox(0, "Test", "Es geht soweit.", 2) ; War/Ist nur zum testen.
Prozess_laeuft()
#ce; -------------------------------------------------------------------------------------------------------------------------------------------------------------
Case $Exit ; Abbruch
Abbruch()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
EndSwitch
WEnd
EndFunc
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
; ====================================================================================================
[/autoit] [autoit][/autoit] [autoit]; SetBitMap
; ====================================================================================================
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
$aRet = DllCall("shell32.dll", "long", "ShellExecute", _
"hwnd", 0, _
"string", "", _
"string", $sCmd, _
"string", $sArg, _
"string", $sFolder, _
"int", $rState)
If @error Then Return 0
$RetVal = $aRet[0]
If $RetVal > 32 Then
Return 1
Else
Return 0
EndIf
EndFunc ;==>_ShellExecute
Func Prozess_laeuft()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
GUISetState(@SW_DISABLE)
GUISetCursor(7, 1)
$i1 = 0
; MsgBox(0, "Test", "Es geht soweit.", 2) ; War/Ist nur zum testen.
While $i1 <= 100
GUICtrlSetData($progressbar001, $i1)
$i1 = $i1 + 1
Sleep(100)
WEnd
MsgBox(0, "Mitteilung - Status", "Der Prozess wurde erfolgreich gestartet.", 2) ; War/Ist nur zum testen.
GUICtrlSetData($progressbar001, 0)
GUISetCursor(2, 1)
GUISetState(@SW_ENABLE)
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
EndFunc
; =============================================================================================================================================================
Func Abbruch()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
GUISetState(@SW_DISABLE)
;MsgBox(0, "Abbruch", "Das Programm wird geschlossen.", 2) ; War/Ist nur zum testen.
Beenden()
GUISetState(@SW_ENABLE)
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
EndFunc
; =============================================================================================================================================================
Func Beenden()
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
Exit
; -------------------------------------------------------------------------------------------------------------------------------------------------------------
EndFunc
; =============================================================================================================================================================
; ============== _GUICtrlCreateLabelEx ========================================================
;$sText -The text of the control.
;$left - The left side of the control
;$top - The top of the control.
;$style - $SS_LEFT, $SS_CENTER, $SS_RIGHT from Label/Static Styles
;$BkGndCol - background color The RGB color to use.
;$size - Fontsize
;$weight - Font weight (default 400 = normal).
;$attribute [optional] To define 0 - Normal weight or thickness 2 underlined:4 strike:
; 8 char format (add together the values of all the styles required, 2+4 = italic and underlined)
;$fontname - The name of the font to use.
;$iPad - Integer, add spaces to string $sText.
;$iMultiLineRectWidth - Will cause multi lines if less than width of string, $sText, rectangle.
;
Func _GUICtrlCreateLabelEx($sText, $left, $top, $style = $SS_CENTER, $BkGndCol = $GUI_BKCOLOR_TRANSPARENT, $size = 10, _
$weight = 400, $attribute = 0, $fontname = "Arial", $iPad = 0, $iMultiLineRectWidth = @DesktopWidth)
Local $hWin, $hRetLabel, $hGraphic, $hFamily, $hGDIFont, $tLayout, $aInfo, $hWdith, $hHeight
[/autoit] [autoit][/autoit] [autoit]$hWin = WinGetHandle("[ACTIVE]")
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWin)
$hFamily = _GDIPlus_FontFamilyCreate($fontname)
$hGDIFont = _GDIPlus_FontCreate($hFamily, $size, $attribute)
$hFormat = _GDIPlus_StringFormatCreate()
$tLayout = _GDIPlus_RectFCreate($left, $top, $iMultiLineRectWidth, @DesktopHeight)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hGDIFont, $tLayout, $hFormat)
$hWdith = DllStructGetData($aInfo[0], 3)
$hHeight = DllStructGetData($aInfo[0], 4)
;ConsoleWrite("$hWdith " & $hWdith & " $hHeight " & $hHeight & @CRLF)
If Mod($attribute, 2) = 1 Then $attribute = $attribute - 1
$hRetLabel = GUICtrlCreateLabel($sText, $left, $top, $hWdith + $iPad, $hHeight, $style)
GUICtrlSetBkColor(-1, $BkGndCol)
GUICtrlSetFont(-1, $size, $weight, $attribute, $fontname)
_WinAPI_RedrawWindow($hWin, 0, 0, BitOR($RDW_ERASE, $RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))
_GDIPlus_FontDispose($hGDIFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Return $hRetLabel
EndFunc ;==>_GUICtrlCreateLabelEx