Sign in to follow this  
Followers 0
JohnW

Button Does nothing when clicked

3 posts in this topic

#1 ·  Posted (edited)

I have a program that reads in a phone number and comes back with information it looked up in a database and displays the information in a list and label. I have created a button that when clicked I want it to send information to the clipboard and then exit. For some reason I cannot get the button to do anything when clicked. I am sure I am missing something simple but here is the code and any help would be greatly appreciated.

#include<array.au3>
#include<Access.au3>
#include<GuiConstantsEx.au3>
#include <GUIListBox.au3>

Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)
global $sqlCon,$adoRs,$output,$phonenumber,$address,$city,$state,$zip,$qryPhone,$phoneDash,$custID,$addressid
global $custName, $inphone, $outputcust, $DBLoc,$count,$PickWnd,$custlist,$custlabel,$clipBtn

If $cmdline[0] <> 0 Then
    $inphone = $cmdline[1]
;~  $outputcust = $cmdline[2]
;~  msgbox(0,"error",$inphone)
Else
    Msgbox(0,"Error","No parameters given")
EndIf
    $pickWnd= GuiCreate("PhonePop",500,250)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Events")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Events")
GUISetOnEvent($GUI_EVENT_RESTORE, "_Events")

$custlist = GUICtrlCreateList("",10,10,240,125)
$custlabel = GuiCtrlCreateLabel("",260,10,200,125)
$clipBtn = GuiCtrlCreateButton("Ok",225,175,50)
GUISetOnEvent($clipBtn,"ClipButton")

ConnectDB()
GUISwitch($pickWnd)
GUISetState(@SW_Show,$pickWnd)
while 1
    Sleep(60)
WEnd

Func ConnectDB()
    $DBLoc = IniRead("PhonePop.ini","DatabaseLoc","DB","")
    $sqlCon = ObjCreate("ADODB.Connection")
    $sqlCon.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & $DBLoc)
;~  $qryPhone = getPhoneNo()
    $qryPhone = $inphone
    $phoneDash = StringMid($qryPhone,1,3) & "-" & stringMid($qryPhone,4,3) & "-" & StringMid($qryPhone,7,4)
;~  msgbox(0,"Test",$phoneDash)
;~ msgbox(0,"Test",$outputcust)
    $count = 0
    $adoRs = $sqlCon.Execute("Select DISTINCT * From Gehl WHERE Phone ='" & $phoneDash & "'")
    with $adoRs
        While Not .EOF
                $count=$count +1
                .moveNext
            Wend
            If $count = 0 Then
                Exit
            EndIf
    EndWith
;~  msgbox(0,"",$count)
    with $adoRs
        .moveFirst
    While Not .EOF
            $custID = $adoRs.Fields("CUSTOMER Id").value
            $custName = $adoRs.Fields("Customer Name").value
    ;$addressid = $adoRs.Fields("ADDRESS Line1").value
    ;$address = $adoRs.Fields("ADDRESS Line2").value
    ;$zip = $adoRs.Fields("ZIP CODE").value
            $city = $adoRs.Fields("CITY").value
            $state = $adoRs.Fields("STATE").value
            $phonenumber = $adoRs.Fields("Phone").value
            GUICtrlSetData($custlist,$custID)
            $output = $custName & @CRLF & $city & ", " & $state &  @CRLF & @CRLF & $phonenumber
            Guictrlsetdata($custlabel,$output)
;~          msgbox(0,"Test",$output )
;~          ClipPut($custID)
            .moveNext
        WEnd
        
    
EndWith
$sqlCon.Close



;~  Exit
EndFunc 

Func ClipButton()
    ClipPut("11111111")
    Exit
EndFunc

Func _Events()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
        Case $GUI_EVENT_RESTORE
        Case Else 
    EndSwitch
Endfunc
Edited by JohnW

Share this post


Link to post
Share on other sites



Use GuiSetOnEvent for the special GUI messages (like $GUI_EVENT_CLOSE).

Use GuiCtrlSetOnEvent for your GUI controls.

Share this post


Link to post
Share on other sites

Thanks, I knew it had to be something simple.

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