Hintergrundbild löst Fehler mit IsHWnd aus

  • Hallo,
    ich möchte gerne mein GUI mit einem Hintergrundbild verbessern ;)
    aber ich bekomme einen Fehler, wenn ich das Bild deaktiviert kurz nachdem erstellen des GUIs erstelle.
    Damit das Bild keine Controls überlagert, hab ich an den Anfang gesetzt, bevor alle anderen Ctrls erstellt werden.
    Damit die Ctrls auch bedienbar bleiben haben ich das Bild deaktiviert.

    [autoit]

    $MainGUI = GUICreate($sTitle, 753, 1024, 200, 107)
    $BG = GUICtrlCreatePic(@ScriptDir & "\bg5.jpg", 0, 0, 753, 590)
    GUICtrlSetState($BG, $GUI_DISABLE)
    $MGroup1 = GUICtrlCreateGroup("Modis", 8, 8, 521, 75)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio1 = GUICtrlCreateRadio("Einbuchen", 16, 28, 73, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio2 = GUICtrlCreateRadio("Ausbuchen", 16, 53, 75, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio3 = GUICtrlCreateRadio("Editieren", 111, 28, 63, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio4 = GUICtrlCreateRadio("Filtern", 194, 28, 47, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MCombo3 = GUICtrlCreateCombo("", 434, 20, 89, 25)
    ....
    ....
    Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndInput
    Local $nNotifyCode = BitShift($iwParam, 16)
    If Not IsHWnd($MInput2) Then $hWndMInput2 = GUICtrlGetHandle($MInput2)
    If Not IsHWnd($MInput1) Then $hWndMInput1 = GUICtrlGetHandle($MInput1)
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord($iwParam)
    $iCode = _WinAPI_HiWord($iwParam)
    ; Wenn layer den $nNotifyCode = 1 - entspricht Linker Mausklick - empfängt
    If $hWndFrom = $box And $nNotifyCode = 1 Then
    $indexB = _GUICtrlListBox_GetCurSel($box) ; Index des angeklickten items wird gespeichert
    UpdateCTRLs($indexB) ; die anderen Ctrls werden durch die zur Artikebez. gehörenden Informationen ergänzt
    ControlSetText($SenseGui, '', $SenseCtrl, _GUICtrlListBox_GetText($box, $indexB)) ; der Inhalt des Input-Ctrls wird um die vollst. Artikelbez. ergänzt
    GUISetState(@SW_HIDE, $guiBox) ; versteckt das Layer-Objekt
    $show = False
    EndIf
    Switch $hWndFrom
    Case $MInput1, $hWndMInput1
    Switch $iCode
    Case $EN_CHANGE
    ....
    ....

    [/autoit]

    Aus irgendeinem Grund kennt Autoit die ganzen Ctrls nicht mehr ($Minput1, $Minput2 usw.)
    Fehlermeldung: ==> Variable used without being declared:
    If Not IsHWnd(^ ERROR

    Anhang: Bild ohne deaktiviertes Fenster.

  • Hallo Trolleule,

    in dem von dir geposteten Skript gibt es diese Variable nicht, ebenso fehlt die func radio.

    Du solltest auch nicht in deinem Post im Skript Farben setzen, dies gibt Syntaxerror. Ebenso ist die Fehlermeldung durch deine Farbgebung unleserlich. Die #includes am Anfang fehlen auch. Unter einem echtem Hilfe suchen, stelle ich mir etwas anderes vor (bessere Vorarbeit :!: )

    mfg (Auto)Bert

  • Mein Programm hat 1700 lines, außerdem wollte ich den code wahren, er muss doch nicht komplett aufgeführt sein um das Problem zu beheben oder? Ansonsten poste ich ihn gerne nach :)

    Ich poste den main part aber compilen kann man den danach auch nicht, selbst wenn ich die au3 anhänge würde es nicht gehen weil die ganzen bilder usw. fehlen würden.

    [autoit]


    ; Includes----------------------------------------------------------------------
    #include <Misc.au3>
    #include <GUIListBox.au3>
    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListViewConstants.au3>
    #include <StaticConstants.au3>
    #include <TabConstants.au3>
    #include <WindowsConstants.au3>
    #Include <GuiEdit.au3>
    #Include <File.au3>
    #include <Array.au3>
    #Include <GuiListView.au3>
    #Include <GuiComboBox.au3>
    #include <_sql.au3>
    #include <SQLite.au3>
    #include <SQLite.dll.au3>
    #include <Constants.au3>
    #Include <GuiTab.au3>
    #Include <GuiButton.au3>
    #Include <GuiToolTip.au3>
    #include <Date.au3>
    #Include <GuiDateTimePicker.au3>
    #include <Bildschirmtastatur.au3>
    Opt("GUICloseOnESC", 0)
    Opt('GUIOnEventMode', 1)

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

    Global $zeroqu = "SELECT DISTINCT a.Artikelbezeichnung, a.Regal, a.Koordinate, FORMAT(a.BNR, '00000'), a.Mindestbestand " _
    & "FROM Artikel a WHERE a.Artikelbezeichnung LIKE "

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

    Global $sTitle = "Lagerverwaltung"
    Global $InitEditMode = 0
    Global $split
    Global $mode

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

    #Region - Deklarationen für Sense
    Global $show = False
    Global $indexB = -1
    Global $SenseGui, $SenseCtrl, $guiBox, $box
    Global $POSSenseGui[2]
    #Region Box
    $guiBox = GUICreate('', 184, 85, 6, 119, $WS_POPUP, $WS_EX_TOPMOST)
    $box = _GUICtrlListBox_Create($guiBox, '', 0, 0, 184, 86, $LBS_SORT+$WS_BORDER, 0)
    #EndRegion Box
    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") ; reagiert auf Kommandos, wie z.B. Tastenschläge
    GUIRegisterMsg($WM_MOVE, "_WM_MOVE") ; reagiert auf Fensterbewegungen
    GUIRegisterMsg(0x231, "_WM_ENTERSIZEMOVE")
    #EndRegion - Deklarationen für Sense

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

    #Region Main
    $MainGUI = GUICreate($sTitle, 753, 1024, 200, 107)
    $BG = GUICtrlCreatePic(@ScriptDir & "\bg5.jpg", 0, 0, 753, 590)
    GUICtrlSetState($BG, $GUI_DISABLE)
    $MGroup1 = GUICtrlCreateGroup("Modis", 8, 8, 521, 75)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio1 = GUICtrlCreateRadio("Einbuchen", 16, 28, 73, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio2 = GUICtrlCreateRadio("Ausbuchen", 16, 53, 75, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio3 = GUICtrlCreateRadio("Editieren", 111, 28, 63, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MRadio4 = GUICtrlCreateRadio("Filtern", 194, 28, 47, 17)
    GUICtrlSetOnEvent(-1, "Radio")
    $MCombo3 = GUICtrlCreateCombo("", 434, 20, 89, 25)
    GUICtrlSetData(-1, "abuettge|dthiel|rmueller")
    $MLabelUser = GUICtrlCreateLabel("Benutzer", 386, 22, 46, 17)
    $MGroup2 = GUICtrlCreateGroup("Optionen", 542, 8, 201, 149)
    $MCheckbox1 = GUICtrlCreateCheckbox("Seriennummer", 550, 30, 91, 17)
    GUICtrlSetOnEvent(-1, "Serial")
    $MCheckbox2 = GUICtrlCreateCheckbox("Datum/ Uhrzeit", 550, 48, 97, 17)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetOnEvent(-1, "ActivateTime")
    $MCheckbox3 = GUICtrlCreateCheckbox("Ausgebuchte Artikel einblenden", 550, 66, 171, 17)
    GUICtrlSetState(-1, $GUI_HIDE)
    $MCheckbox4 = GUICtrlCreateCheckbox("Ergebnisse gruppieren", 550, 84, 123, 17)
    GUICtrlSetState(-1, $GUI_HIDE)
    $MButton2 = GUICtrlCreateButton("Alle Artikel Anzeigen", 566, 105, 159, 40, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetOnEvent(-1, "ShowAll")
    $MGroup3 = GUICtrlCreateGroup("Init", 8, 158, 735, 425)
    $MGroup6 = GUICtrlCreateGroup("Position", 16, 278, 197, 137)
    $MCombo1 = GUICtrlCreateCombo("", 28, 320, 63, 25)
    $MCombo2 = GUICtrlCreateCombo("", 28, 376, 85, 25)
    $MLabel5 = GUICtrlCreateLabel("Regal", 28, 302, 32, 17)
    $MLabel6 = GUICtrlCreateLabel("Koordinate", 28, 358, 55, 17)
    $MGroup4 = GUICtrlCreateGroup("Informationen", 16, 178, 719, 93)
    $MLabel2 = GUICtrlCreateLabel("Artikelbezeichnung", 28, 202, 94, 17)
    $MInput2 = GUICtrlCreateInput("", 28, 220, 185, 21)
    $MBtn_Set = GUICtrlCreateButton("MBtn_Set", 218, 220, 22, 22, BitOR($BS_ICON,$WS_GROUP))
    GUICtrlSetImage(-1, @ScriptDir & "\ok4.ico", -1)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetOnEvent(-1, "InitEditMode")
    $MGroup5 = GUICtrlCreateGroup("Suchalgorithmus", 246, 202, 119, 49)
    $MRadio5 = GUICtrlCreateRadio("UND", 254, 222, 45, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)
    GUICtrlSetOnEvent(-1, "InitAutoIndex")
    $MRadio6 = GUICtrlCreateRadio("ODER", 304, 222, 51, 17)
    GUICtrlSetOnEvent(-1, "InitAutoIndex")
    $MLabelSN = GUICtrlCreateLabel("Seriennummer", 406, 202, 71, 17)
    GUICtrlSetState(-1, $GUI_HIDE)
    $MInputSN = GUICtrlCreateInput("", 406, 220, 205, 21)
    GUICtrlSetState(-1, $GUI_HIDE)
    $MGroup7 = GUICtrlCreateGroup("Lagerbestand", 224, 278, 511, 137)
    $MLabel3 = GUICtrlCreateLabel("Menge", 236, 302, 37, 17)
    $MLabel4 = GUICtrlCreateLabel("Mindestbestand", 236, 358, 79, 17)
    $MInput4 = GUICtrlCreateInput("", 236, 376, 53, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
    $MInput3 = GUICtrlCreateInput("", 236, 320, 55, 24, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER))
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $MGroup8 = GUICtrlCreateGroup("Datum/Uhrzeit", 16, 422, 719, 105)
    $MLabel8 = GUICtrlCreateLabel("Datum/ Uhrzeit von/ bis", 305, 446, 118, 17)
    $MLabel9 = GUICtrlCreateLabel(" - ", 512, 474, 13, 17)
    $MShowCal1 = GUICtrlCreateButton("", 487, 472, 22, 22, BitOR($BS_ICON,$WS_GROUP))
    GUICtrlSetImage(-1, @ScriptDir & "\cal.ico", -1)
    GUICtrlSetOnEvent(-1, "DTP1")
    $MShowCal2 = GUICtrlCreateButton("", 708, 472, 22, 22, BitOR($BS_ICON,$WS_GROUP))
    GUICtrlSetImage(-1, @ScriptDir & "\cal.ico", -1)
    GUICtrlSetOnEvent(-1, "DTP2")
    $MLabel10 = GUICtrlCreateLabel("Wann wurde welcher Artikel", 28, 472, 137, 17)
    $MRadio7 = GUICtrlCreateRadio("eingebucht", 170, 446, 75, 17)
    $MRadio8 = GUICtrlCreateRadio("ausgebucht", 170, 472, 75, 17)
    $MRadio9 = GUICtrlCreateRadio("editiert", 170, 498, 50, 17)
    $MStateLab = GUICtrlCreateLabel("DEAKTIVIERT!", 100, 424, 84, 14)
    GUICtrlSetFont(-1, 8, 400, 0, "Times New Roman")
    GUICtrlSetColor(-1, 0xFF0000)
    $MButton3 = GUICtrlCreateButton("Buchen", 626, 532, 110, 45, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "Booking")
    $MButton4 = GUICtrlCreateButton("Zurücksetzen", 548, 552, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "_Reset")
    $date_from = GUICtrlCreateDate($sNewDate, 305, 472, 180, 22, $DTS_SHORTDATEFORMAT+$DTS_UPDOWN) ; 180 breite
    $date_to = GUICtrlCreateDate($sNewDate, 526, 472, 180, 22, $DTS_SHORTDATEFORMAT+$DTS_UPDOWN) ; 564, 102 , 80, 20
    $MLabel1 = GUICtrlCreateLabel("Scannen Sie den gewünschten Artikel hier ein:", 8, 110, 332, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $MInput1 = GUICtrlCreateInput("", 346, 110, 121, 28, $ES_NUMBER)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $SenseGui = $MainGUI ; <== Für Allgemeingültigkeit Zuweisung an $SenseGui
    $SenseCtrl = $MInput2 ; <== Für Allgemeingültigkeit Zuweisung an $SenseCtrl
    $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW
    $style = "dd.MM.yyyy HH:mm:ss"
    GUICtrlSendMsg($date_from, $DTM_SETFORMAT_, 0, $style) ; setzt Format für das Datum Ctrl 1
    GUICtrlSendMsg($date_to, $DTM_SETFORMAT_, 0, $style)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
    #EndRegion Main

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

    Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndInput
    Local $nNotifyCode = BitShift($iwParam, 16)
    If Not IsHWnd($MInput2) Then $hWndMInput2 = GUICtrlGetHandle($MInput2)
    If Not IsHWnd($MInput1) Then $hWndMInput1 = GUICtrlGetHandle($MInput1)
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord($iwParam)
    $iCode = _WinAPI_HiWord($iwParam)
    ; Wenn layer den $nNotifyCode = 1 - entspricht Linker Mausklick - empfängt
    If $hWndFrom = $box And $nNotifyCode = 1 Then
    $indexB = _GUICtrlListBox_GetCurSel($box) ; Index des angeklickten items wird gespeichert
    UpdateCTRLs($indexB) ; die anderen Ctrls werden durch die zur Artikebez. gehörenden Informationen ergänzt
    ControlSetText($SenseGui, '', $SenseCtrl, _GUICtrlListBox_GetText($box, $indexB)) ; der Inhalt des Input-Ctrls wird um die vollst. Artikelbez. ergänzt
    GUISetState(@SW_HIDE, $guiBox) ; versteckt das Layer-Objekt
    $show = False
    EndIf
    Switch $hWndFrom
    Case $MInput1, $hWndMInput1
    Switch $iCode
    Case $EN_CHANGE
    $tmpbnr = GUICtrlRead($MInput1)
    If StringLen($tmpbnr) > 5 Then
    MsgBox(64, "Ungültige Regel", "Bitte verwenden Sie eine 5-stellige Buchungsnummer.", 2)
    $bnrtmp = StringTrimRight($tmpbnr, 1) ; Letztes Zeichen löschen
    GUICtrlSetData($MInput1, $bnrtmp)
    EndIf
    EndSwitch
    EndSwitch
    ; Programm befindet sich nicht im edit mode
    If $InitEditMode <> 1 Then
    Switch $hWndFrom
    Case $MInput2, $hWndMInput2 ; überwacht Artikelbezeichnung
    Switch $iCode ; msg code
    Case $EN_CHANGE ; Reaktion auf Veränderungen, wie z.B. Tastenschläge
    InitAutoIndex()
    EndSwitch
    EndSwitch
    ; Programm befindet sich im edit mode und initialisiert die Ctrls
    Else
    If Not IsHWnd($MInputSN) Then $hWndMInputSN = GUICtrlGetHandle($MInputSN)
    If Not IsHWnd($MInput4) Then $hWndMInput4 = GUICtrlGetHandle($MInput4)
    If Not IsHWnd($MCombo1) Then $hWndMCombo1 = GUICtrlGetHandle($MCombo1)
    If Not IsHWnd($MCombo2) Then $hWndMCombo2 = GUICtrlGetHandle($MCombo2)
    Switch $hWndFrom
    Case $MInput2, $hWndMInput2 ; überwacht Artikelbezeichnung
    Switch $iCode
    Case $EN_CHANGE
    If GUICtrlRead($MInput2) <> $name Then
    GUICtrlSetColor($MInput2, 0xff0000)
    Else
    GUICtrlSetColor($MInput2, 0x000000)
    EndIf
    EndSwitch
    Case $MInput1, $hWndMInput1 ; überwacht Buchungsnummer
    Switch $iCode
    Case $EN_CHANGE
    If GUICtrlRead($MInput1) <> $bnr Then
    GUICtrlSetColor($MInput1, 0xff0000)
    Else
    GUICtrlSetColor($MInput1, 0x000000)
    EndIf
    EndSwitch
    Case $MInput4, $hWndMInput4 ; überwacht Mindestbestand
    Switch $iCode
    Case $EN_CHANGE
    If GUICtrlRead($MInput4) <> $min Then
    GUICtrlSetColor($MInput4, 0xff0000)
    Else
    GUICtrlSetColor($MInput4, 0x000000)
    EndIf
    EndSwitch
    Case $MInputSN, $hWndMInputSN ; überwacht Seriennummer
    Switch $iCode
    Case $EN_CHANGE
    If GUICtrlRead($MInputSN) <> $serial Then
    GUICtrlSetColor($MInputSN, 0xff0000)
    Else
    GUICtrlSetColor($MInputSN, 0x000000)
    EndIf
    EndSwitch
    Case $MCombo1, $hWndMCombo1 ; überwacht Regal
    Switch $iCode
    Case $CBN_EDITCHANGE, $CBN_SELCHANGE ; Reaktion auf Veränderungen, wie z.B. Tastenschläge oder Selektion
    If GUICtrlRead($MCombo1) <> $frame Then
    GUICtrlSetColor($MCombo1, 0xff0000)
    Else
    GUICtrlSetColor($MCombo1, 0x000000)
    EndIf
    EndSwitch
    Case $MCombo2, $hWndMCombo2 ; überwacht Koordinate
    Switch $iCode
    Case $CBN_EDITCHANGE, $CBN_SELCHANGE
    If GUICtrlRead($MCombo2) <> $coord Then
    GUICtrlSetColor($MCombo2, 0xff0000)
    Else
    GUICtrlSetColor($MCombo2, 0x000000)
    EndIf
    EndSwitch
    EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]

    Also programm funktioniert, aber durch das deaktivieren des Bildes, kommt irgendwie alles durcheinander und ich weiss nicht warum. Vielleicht gibt es ja noch eine alternative das Bild sauber hinter die Ctrls zu setzen ohne diese dadurch zu sperren/ unbedienbar zu machen.

    [autoit]


    GUICtrlSetState($BG, $GUI_DISABLE)

    [/autoit]
  • hey du hast recht, so funktionierts :thumbup:
    du Genie ;)

    Vielen Dank für die Mega schnelle Hilfe