rückmeldung aus einer child gui in der main gui verwenden

  • 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
    [autoit]


    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.0.0
    Author: Tobias Wüst und Andreas Müller

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Installationsmenü mit spezieller Grafik

    [/autoit] [autoit][/autoit] [autoit]

    #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)

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    ; Extract image width and height from PNG
    $width = _GDIPlus_ImageGetWidth($hImage)
    $height = _GDIPlus_ImageGetHeight($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    ; 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

    [/autoit] [autoit][/autoit] [autoit]

    ; 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)

    [/autoit] [autoit][/autoit] [autoit]

    ; 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)

    [/autoit] [autoit][/autoit] [autoit]

    $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)

    [/autoit] [autoit][/autoit] [autoit]

    $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)

    [/autoit] [autoit][/autoit] [autoit]

    $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)

    [/autoit] [autoit][/autoit] [autoit]

    $progressbar001 = GUICtrlCreateProgress (850, 600, 210, 10)

    [/autoit] [autoit][/autoit] [autoit]

    $progressbar002 = GUICtrlCreateProgress (200, 800, 210, 10)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $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)

    [/autoit] [autoit][/autoit] [autoit]

    ;GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If $cmdline[0] >= 1 Then
    MsgBox(0, "Information", "Es wurde ein Parameter mitgegeben.")
    EndIf
    Menu()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Release resources
    _WinAPI_DeleteObject($hImage)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
    ; ====================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
    EndFunc ;==>WM_NCHITTEST

    [/autoit] [autoit][/autoit] [autoit]

    ; ====================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ; SetBitMap
    ; ====================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    [/autoit] [autoit][/autoit] [autoit]

    $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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    $RetVal = $aRet[0]
    If $RetVal > 32 Then
    Return 1
    Else
    Return 0
    EndIf
    EndFunc ;==>_ShellExecute

    [/autoit] [autoit][/autoit] [autoit]

    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
    ; =============================================================================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ; ============== _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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit]

    2 Mal editiert, zuletzt von Illum Zaar (17. September 2009 um 16:31)

  • Meinst du sowas?

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Haubtgui", 413, 298, 100, 219)
    GUICtrlCreateLabel ("Haubtgui",10,10)
    $Button1 = GUICtrlCreateButton("Button1", 105, 42, 75, 25, 0)
    $Input1 = GUICtrlCreateInput("Input1", 45, 132, 121, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Nebengui", 413, 298, 600, 219)
    $Input2 = GUICtrlCreateInput("Input1", 15, 54, 121, 21)
    $Button2 = GUICtrlCreateButton("Button1", 111, 195, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $1 = GUICtrlRead ($Input1)
    GUICtrlSetData ($Input2,$1)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $Button2
    $2 = GUICtrlRead ($Input2)
    GUICtrlSetData ($Input1,$2)
    Case $GUI_EVENT_CLOSE
    GUISetState (@SW_HIDE,$Form2)
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]

    mfg. Jam00