Sign in to follow this  
Followers 0
JAFN

Buttons not showing up when routine is called one way but fine another way.

7 posts in this topic

This will be somewhat vague as I can't see a way to get it across without a ton of code. And probably not even then.

A few days back you guys finally helped me through creating a working double click routine. I had wanted it to trigger an edit routine that was already in the main code loop.

So I bundled up the code into a function and linked it to double click and to the edit button.

It still functions perfectly when the edit button triggers the routine.

But when the double click triggers it, it displays the window created but none of the buttons or inputs.

Hopefully that wasn't too vague.

Anyone got any ideas.


[size="2"]The second mouse gets the cheese[/size]

Share this post


Link to post
Share on other sites



some code would help alot


[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It's probably because you're calling it through the Windows Message, which should never activate a blocking routine. It will either lock up the whole program/computer or just fail to function correctly.

You'd be better off using the double click to change a variable that, inside your while...wend loop, activates your edit gui. Something like this:

While 1
    If $DblClickEdit = 1 then
         ; call your editing function here
        $DblClickEdit = 0
    Endif
Wend

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ; Windows message function used to call the double click function
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $lParam
    $hWndListView = $LVid
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_ITEMACTIVATE
                    Local $nmia = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    Local $I = DllStructGetData($nmia, "Index")
                    $DblClickEdit = 1
            Beep(900,300(
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

The calling function

Func EditRoutine()

    KeyTap(@ScriptLineNumber)
    If _GUICtrlListView_GetSelectedIndices($LVid) = "" Then
        MsgBox(48, "Warning", "No Item has been selected")
    Else
        GUISetState(@SW_DISABLE, $DVDid)
        $row = _GUICtrlListView_GetSelectedIndices($hListView)
        AddEditWindow("Edit", $Data[$row][0], $Data[$row][3], $Data[$row][2], $Data[$row][1])
        GUISetState(@SW_ENABLE, $DVDid)
        ; set focus to edited line.
        _GUICtrlListView_EnsureVisible($hListView, $row)
        _GUICtrlListView_SetItemState($hListView, $row, $LVIS_SELECTED, $LVIS_SELECTED) ; To highlight
        GUICtrlSetState($Apply, $GUI_ENABLE)
        GUICtrlSetState($Refresh, $GUI_ENABLE)
    EndIf
    WinActivate($NameVersion)

EndFunc

The Function it calls (the one that works one way but not the other

Func AddEditWindow($Flag, $val0, $val1, $val2, $val3)

    ; Add, Edit

    $Top = ReadPosition("Y")
    $Left = ReadPosition("X")

    $AddEditID = GUICreate($Flag & " DVD information", 560 - 8, 190, $Left + 4, $Top + 150)

    $AddEditApply = GUICtrlCreateButton("Apply", ButtonCenter(560 - 4, 450, 80), ButtonPosition(1, 4, 40), 80, 40,  $BS_DEFPUSHBUTTON )
    MsgBox(0,"","Here")
    ;   GUICtrlSetTip($Apply, "Apply list to file.", "Explanation", 1)
    $AddEditCancel = GUICtrlCreateButton("Cancel", ButtonCenter(560 - 4, 450, 80), ButtonPosition(2, 4, 40), 80, 40)

    ; x, y
    GUICtrlCreateLabel(IniRead($Name & ".ini", "Column Header","Title","Title"), 5, 10 + 10)
    $AddEditTitle = GUICtrlCreateInput($val0, 60, 5 + 10, 200, 30)

    GUICtrlCreateLabel(IniRead($Name & ".ini", "Column Header","Genre","Genre"), 5, 10 + 50)
    $AddEditGenre = GUICtrlCreateCombo($val1, 60, 5 + 50, 100, 30)
    SetComboArray($AddEditGenre)

    GUICtrlCreateLabel(IniRead($Name & ".ini", "Column Header","Quantity","Quantity"), 5, 10 + 90)
    $AddEditQuantity = GUICtrlCreateInput($val2, 60, 5 + 90, 100, 30)

    GUICtrlCreateLabel(IniRead($Name & ".ini", "Column Header","Price","Price"), 5, 10 + 130)
    $AddEditPrice = GUICtrlCreateInput($val3, 60, 5 + 130, 100, 30)

    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                KeyTap(@ScriptLineNumber)
                GUIDelete($AddEditID)
                $AddEditID = ""
                ExitLoop
            Case $AddEditCancel
                KeyTap(@ScriptLineNumber)
                GUIDelete($AddEditID)
                $AddEditID = ""
                ExitLoop
            Case $AddEditApply
                KeyTap(@ScriptLineNumber)
                If $Flag = "Add" Then
                    ReDim $Data[UBound($Data) + 1][4]
                    $dummy = UBound($Data) - 1
                Else
                    $dummy = _GUICtrlListView_GetSelectedIndices($LVid)
                EndIf
                $Data[$dummy][0] = GUICtrlRead($AddEditTitle)
                $Data[$dummy][1] = GUICtrlRead($AddEditPrice)
                $Data[$dummy][2] = GUICtrlRead($AddEditQuantity)
                $Data[$dummy][3] = GUICtrlRead($AddEditGenre)

                RefreshListView()
                GUIDelete($AddEditID)
                $AddEditID = ""
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>CreateEditWindow

Edit Window buttons and inputs either invisible or not created.


[size="2"]The second mouse gets the cheese[/size]

Share this post


Link to post
Share on other sites

It's probably because you're calling it through the Windows Message, which should never activate a blocking routine. It will either lock up the whole program/computer or just fail to function correctly.

You'd be better off using the double click to change a variable that, inside your while...wend loop, activates your edit gui. Something like this:

worked perfectly, thank you.

Now that I think about it I can see why it would be a bad idea.

But can you explain why it doesn't work?

As always I am amazed at the speed of help.

This is the nicest, quickest and most helpful help forum I have ever used.


[size="2"]The second mouse gets the cheese[/size]

Share this post


Link to post
Share on other sites

When you activate a windows message call, line _WM_NOTIFY, you have to return from it as soon as possible or it will lock up the program. This link in the Wiki will explain it better than I can. :unsure:


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

When you activate a windows message call, line _WM_NOTIFY, you have to return from it as soon as possible or it will lock up the program. This link in the Wiki will explain it better than I can. :unsure:

No that made sense.

So, it only opened the window before it ran out of time and it locked up.

Good to know.


[size="2"]The second mouse gets the cheese[/size]

Share this post


Link to post
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
Sign in to follow this  
Followers 0