Jump to content

GUI_ENABLE GUI_DISABLE


Go to solution Solved by Subz,

Recommended Posts

I am curtain that is nothing more than a Homer Moment for me but I'll be damned if see anything obvious here.

What the full program is meant to do (and does).

  1. I get a P.O from a dealer.
  2. I send the P.O. to our AR person ( the company that owns my firm has the books set up kinda weird for reasons that made some sense in 2017)
  3. The AR folks email me the invoice which I email to the dealer who sends the check to the AR folks.

The program was written many years ago as a quick and dirty product and the full thing works well for me.  However, it needs to be less dirty now since I am going to out of the office for a month.  So, I want to disable buttons that are not used in the active tab and reactive them when needed.

Here is the code.  I am obviously doing something wrong but I don't know what.

#include <Constants.au3>
#include <GUIConstants.au3>
#include <File.au3>
#Include <Array.au3>
#include <Date.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <OutlookEX.au3>

$Dealsendmail=""
$Form1 = GUICreate("Money Move", 250, 314, 100, 218)
$PageControl1 = GUICtrlCreateTab(8, 8, 200, 230)
$TabPO = GUICtrlCreateTabItem("POs")
$POLists = GUICtrlCreateCombo("POLists", 16, 40, 150, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$TabInvoice = GUICtrlCreateTabItem("Invoices")
$Dealerlist = GUICtrlCreateCombo("Dealer list", 16, 40, 175, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$InvoiceLists = GUICtrlCreateCombo("", 16, 70, 100, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlCreateTabItem("")
$emailEd = GUICtrlCreateButton("Email Ed", 6, 250, 75, 25)
$NoteemailEd = GUICtrlCreateCheckbox("Add note to Ed", 150, 250, 218, 25)
$emailDealer = GUICtrlCreateButton("Email Dealer", 6, 275, 75, 25)
$adddealeremail= GUICtrlCreateButton("Add Email", 118, 275, 75, 25)
GUICtrlSetState($emailDealer,$GUI_DISABLE)
GUICtrlSetState($adddealeremail,$GUI_DISABLE)

GUISetState(@SW_SHOW)
;some code to populate various things.  All works




While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $emailEd ;send email to AR
        ; various magic to send the email and log the event


            Exit


        Case $emailDealer ; Send invoice to dealer

        GUICtrlSetState($emailDealer,64);$GUI_ENABLE)
        GUICtrlSetState($adddealeremail,$GUI_ENABLE)
        GUICtrlSetState($emailEd,$GUI_DISABLE)
        ; various magic to send the email and log the event

    EndSwitch
WEnd

 

Link to comment
Share on other sites

  • Solution

You can't use the $emailDealer button after you've already disabled it, you would need some type of event to occur for example when switching tabs

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $emailEd ;send email to AR
            Exit
        Case $PageControl1
            If GUICtrlRead($PageControl1) = 0 Then ;~ If tab 0 then do this
                GUICtrlSetState($emailDealer, $GUI_DISABLE)
                GUICtrlSetState($adddealeremail,$GUI_DISABLE)
                GUICtrlSetState($emailEd,$GUI_ENABLE)
            ElseIf GUICtrlRead($PageControl1) = 1 Then ;~ If tab 1 then do this
                GUICtrlSetState($emailDealer, $GUI_ENABLE)
                GUICtrlSetState($adddealeremail,$GUI_ENABLE)
                GUICtrlSetState($emailEd,$GUI_DISABLE)
            EndIf
    EndSwitch
WEnd

 

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...