Jump to content

WM_COMMAND dont work after FileOpenDialog [SOLVED]


Rex
 Share

Recommended Posts

Have this big prob. ;)

I use this

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) ; Reads Company Combo, and handles data.
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo
    If Not IsHWnd($Company_Combo) Then $hWndCombo = GUICtrlGetHandle($Company_Combo)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    Switch $hWndFrom
        Case $Company_Combo, $hWndCombo
            Switch $iCode
                Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed
                    _DebugPrint("$CBN_CLOSEUP" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box
                    _DebugPrint("$CBN_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible
                    _DebugPrint("$CBN_DROPDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box
                    _DebugPrint("$CBN_EDITCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    _Edit_Changed()
                    GUICtrlSetState($Save_Adr_CheckBox, $GUI_ENABLE)
                                        ; no return value
                Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text
                    _DebugPrint("$CBN_EDITUPDATE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request
                    _DebugPrint("$CBN_ERRSPACE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus
                    _DebugPrint("$CBN_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box
                    _DebugPrint("$CBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    _CBN_SELCHANGE()

                Case $CBN_SELENDCANCEL ; Sent when the user selects an item, but then selects another control or closes the dialog box
                    _DebugPrint("$CBN_SELENDCANCEL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                    _CBN_SELENDCANCEL()

                    ;MsgBox(0, "Valgt", $Read)
                Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list
                    _DebugPrint("$CBN_SELENDOK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SETFOCUS ; Sent when a combo box receives the keyboard focus
                    _DebugPrint("$CBN_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
        EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_text, $line = @ScriptLineNumber)
     ; Dont do any thing here ;-)
        ConsoleWrite( _
        "!===========================================================" & @LF & _
        "+======================================================" & @LF & _
        "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
        "+======================================================" & @LF)

EndFunc   ;==>_DebugPrint

Func _CBN_SELCHANGE()

; Checks data in combo with data in addressbook, if match we updates the input fields with data from addressbook

                    $Read = _StringToHex(GUICtrlRead($Company_Combo))
                    $Company_Combo_SetData = IniReadSection("Address.adr", "Companys") ; Read the section Companys in addressbook
                    If Not @error Then ; if error we don't do anything else we compairs data from combo and addressbook
                        For $i = 1 To $Company_Combo_SetData[0][0]

                            If $Read = $Company_Combo_SetData[$i][1] Then ; If the read input = one of thoes read from our address book we updates the iputs with the data from addressbook
                                $Key = $i
                                $Fill = IniReadSection("Address.adr", $Company_Combo_SetData[$i][1])
                                GUICtrlSetData($Address_1_Input, _HexToString($Fill[1][1]))
                                GUICtrlSetData($Address_2_Input, _HexToString($Fill[2][1]))
                                GUICtrlSetData($ZipCode_Input, _HexToString($Fill[3][1]))
                                GUICtrlSetData($City_Input, _HexToString($Fill[4][1]))
                                $Clear = True
                                ExitLoop ; If we foundt an address in the address we exists the loop

                            EndIf

                        Next
                    EndIf

EndFunc


Func _CBN_SELENDCANCEL()
    ; Checks data in combo with data in addressbook, if match we updates the input fields with data from addressbook

                    $Read = _StringToHex(GUICtrlRead($Company_Combo))
                    $Company_Combo_SetData = IniReadSection("Address.adr", "Companys") ; Read the section Companys in addressbook
                    If Not @error Then ; Check if there is a read error, if so we don't do anything else we compair data from addressbook and combo
                        For $i = 1 To $Company_Combo_SetData[0][0]

                            If $Read = $Company_Combo_SetData[$i][1] Then
                                $Key = $i
                                $Fill = IniReadSection("Address.adr", $Company_Combo_SetData[$i][1])
                                GUICtrlSetData($Address_1_Input, _HexToString($Fill[1][1]))
                                GUICtrlSetData($Address_2_Input, _HexToString($Fill[2][1]))
                                GUICtrlSetData($ZipCode_Input, _HexToString($Fill[3][1]))
                                GUICtrlSetData($City_Input, _HexToString($Fill[4][1]))
                                GUICtrlSetState($Save_Adr_CheckBox, $GUI_DISABLE) ; Disabling save address, when tha address is loaded from address book
                                $Save_Adress_Dissabled = 1 ; We set a var, so even when we ticks update address, and un ticks it again the save address will be disabled
                                $Clear = True
                                ExitLoop
                            ElseIf $Key <> ""  And $Clear = True Then
                                GUICtrlSetData($Address_1_Input, "")
                                GUICtrlSetData($Address_2_Input, "")
                                GUICtrlSetData($ZipCode_Input, "")
                                GUICtrlSetData($City_Input, "")
                                $Clear = False
                            EndIf
                        Next
                    EndIf
EndFunc

To auto complete text put in to a combo, and to auto fill some fields, but for some reason the function don't work after using FileOpenDialog.

Can any tell me how to "re" enable the function.

Regards

/Rex

Edit:Title changed to Solved

Edited by Rex
Link to comment
Share on other sites

Just a hunch, but could this be because FileOpenDialog changes your @WorkingDir ?

After that one bit me, i now routinely readjust my working dir (with FileChangeDir)

hth,

whim

U'r right, using Yashied's exsample it works like a charme.

Did't know that file open did change the @WorkingDir, but that just shows how mutch i hav(n't) read the info ;)

Regards

/Rex

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...