Jump to content
Sign in to follow this  
jorgev

Converting Switch to Select

Recommended Posts

jorgev

Hi all,

I'm not an experienced coder so i'm having some difficulties converting a Switch to a Select. Here is a piece of code to illustrate what i'm trying to do.

This function will normally show a tooltip when i hover over a button in a toolbar.

As commented the Switch is working as intended, but if i use the Select it is not working, it will actually show the "New" tooltip for every button instead of the relative tooltip.

Anyone could give an explanation of what i'm doing wrong? tx alot

EDIT: i want to convert to "Select" because later on i will ad other cases to be checked for instead of only "Case $iCode = $TTN_GETDISPINFOW" in this example.

; Handle WM_NOTIFY messages
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam, $ilParam
    Local $tInfo, $iID, $iCode
    $tInfo = DllStructCreate($tagNMTTDISPINFO, $ilParam)
    $iCode = DllStructGetData($tInfo, "Code")
    
;~  ********** Select variation (does not work) *****************
    Select
        Case $iCode = $TTN_GETDISPINFOW
            $iID = DllStructGetData($tInfo, "IDFrom")
            Select
                Case $iID
                    Select
                        Case $idNew
                            DllStructSetData($tInfo, "aText", "New")
                        Case $idOpen
                            DllStructSetData($tInfo, "aText", "Open")
                        Case $idSave
                            DllStructSetData($tInfo, "aText", "Save")
                        Case $idHelp
                            DllStructSetData($tInfo, "aText", "Help")
                    EndSelect
            EndSelect
    EndSelect

;~ switch variation (works as intended) **************************
;~  If $iCode = $TTN_GETDISPINFOW Then
;~      $iID = DllStructGetData($tInfo, "IDFrom")
;~      Switch $iID
;~          Case $idNew
;~              DllStructSetData($tInfo, "aText", "New");~
;~          Case $idOpen
;~              DllStructSetData($tInfo, "aText", "Open")
;~          Case $idSave
;~              DllStructSetData($tInfo, "aText", "Save")
;~          Case $idHelp
;~              DllStructSetData($tInfo, "aText", "Help")
;~      EndSwitch
;~  EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by jorgev

Share this post


Link to post
Share on other sites
FireFox

Why do you want to use a Select? The Switch is really recommanded especially when you are comparing always the same var.

Select
    Case $iID = $idNew
        DllStructSetData($tInfo, "aText", "New")
    Case $iID = $idOpen
        DllStructSetData($tInfo, "aText", "Open")
    Case $iID = $idSave
        DllStructSetData($tInfo, "aText", "Save")
    Case $iID = $idHelp
        DllStructSetData($tInfo, "aText", "Help")
EndSelect
Br, FireFox. Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jorgev

Tx alot FireFox,

Later on i will compare more then 1 var, that's why i wanted to learn how to do it with a Select.

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  

×