Announcement

Collapse
No announcement yet.

case %buttonID works, case %textbox does not

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • case %buttonID works, case %textbox does not

    I have a listbox filled with items(names of plants, shrubs, etc.). When I type in letters in the textbox, and press the button, it works like I want. The matching letters (with names) are selected in the listbox.
    The same code used in case %IDC_LETTERS (the textbox) does not work. the Do-loop operates only once per letter entry.
    I would like to have it work when entering the letters in the text box.
    Any ideas?

    NEVER MIND. I FOUND MY ERROR. I HAD LEFT OUT MY LINE THAT RETREIVED THE LETTERS BEING TYPED IN.
    My mind is going, I'm afraid!!

    Here is the code I am using with the dialog and callback procedure.

    John Tate
    Code:
    CALLBACK FUNCTION ShowSelVnameProc()
    LOCAL TBS(),varNum AS LONG
    LOCAL VarietyName,letters AS STRING
    STATIC DiggerRecNum AS LONG
    LOCAL dtemp AS digger
    STATIC R3,numofnames AS LONG
    REDIM tbs(1 TO 10)
    TBS(1) = 250
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
                DIALOG GET USER CBHNDL,1 TO DiggerRecNum
                GET #2,DiggerRecNum,dtemp
                DIALOG SET TEXT CBHNDL, "SELECTING VARIETIES FOR " + dtemp.diggername
                CONTROL SEND CBHNDL,%IDC_LISTBOX3,%LB_SETTABSTOPS,1,VARPTR(tbs(1))
                FillVarietyLB(CBHNDL,numofnames)
                CONTROL SET FOCUS CBHNDL, %idc_letters
                R3 = 0
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    ' /* Inserted by PB/Forms 02-06-2008 14:50:04
                    CASE %IDC_SELLETTERS  'button when pushed accepts letters typed by user
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                             CONTROL GET TEXT CBHNDL,%IDC_LETTERS TO letters
    
                      INCR r3
                     DO
                         LISTBOX SELECT CBHNDL,%IDC_LISTBOX3,R3
                         LISTBOX GET TEXT CBHNDL,%IDC_LISTBOX3 TO VarietyName
                          IF LEFT$(UCASE$(varietyname),LEN(letters))= UCASE$(letters) THEN EXIT LOOP
                         IF r3 > numofnames THEN r3 = 0: EXIT LOOP
                         INCR r3
                         LOOP
    
                    END IF
                    ' */
    
                    ' /* Inserted by PB/Forms 02-06-2008 13:53:26
                    CASE %IDC_LETTERS  'textbox that accepts letter typed in by user
                            IF CBCTL = %IDC_LETTERS AND CBCTLMSG = %EN_CHANGE THEN
                            INCR R3
                     DO
                         LISTBOX SELECT CBHNDL,%IDC_LISTBOX3,R3  'r3 is list position in LB3
                         LISTBOX GET TEXT CBHNDL,%IDC_LISTBOX3 TO VarietyName
                          IF LEFT$(UCASE$(varietyname),LEN(letters))= UCASE$(letters) THEN EXIT LOOP 'if match found, exit loop
                         IF r3 > numofnames THEN:r3= 0: EXIT LOOP  'if r3 > total number of item in LB, then no match was found.
                         INCR r3
                         LOOP
                        END IF
                        
                    CASE %IDC_LABEL57
                    ' */
    
                    CASE %IDC_LISTBOX3
                         IF CBCTL = %IDC_LISTBOX3 AND CBCTLMSG = %LBN_DBLCLK THEN
                            CONTROL POST CBHNDL,%IDC_SELVariety, %BM_CLICK,0,0
                            END IF
                    CASE %IDC_SELVARIETY
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            LISTBOX GET TEXT CBHNDL ,%idc_listbox3 TO VarietyName
                            Varnum = VAL(PARSE$(VarietyName,$TAB,2))
                            ShowEnterPay(CBHNDL,DiggerRecNum,Varnum,0,0,0)
                        END IF
    
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '--------------------------------------------------------------------------
    
    
    '------------------------------------------------------------------------------
    FUNCTION ShowSelVname(BYVAL hParent AS DWORD,Digrecnum AS LONG)AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_SelVname->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW  hParent, "", 70, 70, 375, 257, %WS_POPUP OR %WS_BORDER OR _
            %WS_DLGFRAME OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR _
            %DS_CENTER OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
            %WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD LISTBOX, hDlg, %IDC_LISTBOX3, , 60, 10, 200, 190, %WS_CHILD _
            OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR %LBS_NOTIFY OR _
            %LBS_USETABSTOPS, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR _
            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD BUTTON,  hDlg, %IDC_SELVARIETY, "SELECT VARIETY", 50, 220, _
            65, 15
        CONTROL ADD BUTTON,  hDlg, %IDCANCEL, "EXIT", 140, 220, 50, 15
        CONTROL ADD TEXTBOX, hDlg, %IDC_LETTERS, "", 265, 20, 100, 13
        CONTROL ADD LABEL,   hDlg, %IDC_LABEL57, "ENTER LETTERS OF NAME", 265, _
            10, 100, 10
        CONTROL ADD BUTTON,  hDlg, %IDC_SELLETTERS, "SELECT LETTERS", 275, 35, _
            75, 15
    #PBFORMS END DIALOG
        DIALOG SET USER hdlg,1,DigRecnum
        DIALOG SHOW MODAL hDlg, CALL ShowSelVnameProc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_SelVname
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    Last edited by John Tate; 10 Feb 2008, 09:29 PM. Reason: found my error
Working...
X