Announcement

Collapse
No announcement yet.

Trying to get LISTBOX RESET to work on SYSTABCONTROL32 tab

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

  • Trying to get LISTBOX RESET to work on SYSTABCONTROL32 tab

    This (stripped down) code generates a dialog with a combobox of States.

    Once a State is selected, a Tab Control appears with 3 Tabs.
    Each Tab has a listbox with 10 items.
    The first time a State is selected the code executes as expected and populates the listboxes on each Tab with 10 items.

    When the user selects another State from the COMBOBOX, the PopulateListBox() function sends a ListBox Reset , and new LISTBOX ADD's, but the control doesn't appear to update.

    Could anyone help me spot my error? :wavey:

    Thanks in advance



    Code:
    '****************************************************
    ' Purpose: Report LD/Filelist/Approved.Txt inconsistencies
    ' PROJECT: Quick Tab Visual Designer DDT generated code.
    ' FILE:       LDList.BAS
    ' CREATED: On 05-01-2006 at 10:58:20
    '******************************************************************************
    #COMPILE  EXE
    
    #INCLUDE  "WIN32API.INC"
    #INCLUDE  "COMMCTRL.INC"
    
    '---Main Tab Identifiers
    %IDTAB_MAIN      = 100
    %IDTAB_PAGE_1    = 101
    %IDTAB_PAGE_2    = 102
    %IDTAB_PAGE_3    = 103
    
    
    '---Page 1 control identifiers
    %IDC_LISTBOX_1 = 1000
    %IDC_LISTBOX_2 = 1001
    %IDC_LISTBOX_3 = 1002
    
    %IDC_COMBOBOX_FEDST = 3013
    
    '---Declares
    DECLARE FUNCTION CreateMainDialog(BYVAL hParent AS LONG) AS LONG
    DECLARE FUNCTION CreateMainTabControl(BYVAL hDlg AS LONG) AS LONG
    DECLARE FUNCTION EnumCharSet(elf AS ENUMLOGFONT,ntm AS NEWTEXTMETRIC,BYVAL FontType AS LONG,CharSet AS LONG) AS LONG
    DECLARE FUNCTION MakeFontEx(BYVAL sFont AS STRING, BYVAL PointSize AS LONG, BYVAL fBold AS LONG, _
        BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG, BYVAL StrikeThru AS LONG) AS LONG
    DECLARE SUB CreateMainDlgButtons(BYVAL hDlg AS LONG)
    DECLARE SUB DeleteControlFont(BYVAL hDlg AS LONG)
    DECLARE SUB SetCtlTooltip(BYVAL hCtl AS LONG,sText AS STRING)
    DECLARE SUB SetTabPageRectDDT(BYVAL hDlg AS LONG,rcRet AS RECT)
    DECLARE FUNCTION PopulateListBox(BYVAL hDlg AS LONG,BYVAL lID AS LONG,BYVAL lCount AS LONG) AS LONG
    
    '---Globals
    GLOBAL ghTab() AS LONG  'keep handles for each tab page
    GLOBAL A$,B$,C$,ST$,pf$,pfo$
    GLOBAL DirList$(), FileList$(),StApproved$(),StNotApproved$(), ApprovedMissing$()
    GLOBAL AllApproved$(),TTFiles$(), TMP$(), TMP2$(), FedStates$(), PGList$(), PG3List$()
    GLOBAL AlreadyCreated AS LONG
    
    
    FUNCTION PBMAIN()
    
        LOCAL ticc AS INIT_COMMON_CONTROLSEX
    
        'Load the common controls library...
        DIM DirList$(0)
        DIM FileList$(0)
        DIM StApproved$(0)
        DIM StNotApproved$(0)
        DIM ApprovedMissing$(0)
        DIM AllApproved$(0)
        DIM TTFiles$(0)
        DIM PGList$(0)
        DIM TMP$(0)
        DIM TMP2$(0)
        DIM A$
        LOCAL A1, I, II AS LONG
    
        ticc.dwSize = SIZEOF(ticc)
        ticc.dwICC = %ICC_WIN95_CLASSES OR %ICC_INTERNET_CLASSES OR %ICC_DATE_CLASSES
        CALL InitCommonControlsEx(ticc)
    
        CALL CreateMainDialog(%HWND_DESKTOP)
    
    END FUNCTION
    
    SUB PopulateComboBoxFedSt(BYVAL hDlg AS DWORD, BYVAL lID AS LONG)
    
        LOCAL i, J AS LONG
        LOCAL hCtl AS DWORD
    
        CONTROL HANDLE hDlg, lId TO hCtl
        CONTROL SEND   hDlg, lID, %CB_SETEXTENDEDUI, %TRUE, 0
    
        COMBOBOX ADD hDlg, lID, "ALASKA"
        COMBOBOX ADD hDlg, lID, "ALABAMA"
        COMBOBOX ADD hDlg, lID, "ARKANSAS"
        COMBOBOX ADD hDlg, lID, "ARIZONA"
        COMBOBOX ADD hDlg, lID, "CALIFORNIA"
        COMBOBOX ADD hDlg, lID, "COLORADO"
        COMBOBOX ADD hDlg, lID, "CONNECTICUTT"
    
        COMBOBOX SELECT hDlg, lID, 1
    
    END SUB
    
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION CreateMainDialog(BYVAL hParent AS LONG) AS LONG
    
        LOCAL lRslt AS LONG,hDlg AS LONG,hFont AS LONG
        LOCAL hIcon AS LONG,rc AS RECT
        LOCAL A1    AS LONG
    
        CALL SetRect(rc,50,50,614,214)
    
        DIALOG NEW hParent, "LDList 2008",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom, _
            %WS_POPUP OR %WS_BORDER OR %WS_THICKFRAME OR %WS_CAPTION OR _
            %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _
            %WS_SYSMENU OR %DS_NOFAILCREATE OR %DS_SETFONT OR %DS_3DLOOK, _
            %WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT, TO hDlg
    
        CONTROL ADD COMBOBOX, hDlg, %IDC_COMBOBOX_FEDST, , 70, 2, 95, 70, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR _
            %CBS_DROPDOWN OR %CBS_SORT, %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
            %WS_EX_RIGHTSCROLLBAR
    
        hFont = MakeFontEx("MS Sans Serif",8,400,0,0,0)
    
        DIALOG SEND hDlg, %WM_SETFONT, hFont, 0
    
        'load a system icon...
    
        hIcon = LoadIcon(%NULL,BYVAL %IDI_APPLICATION)
        CALL SetClassLong(hDlg,%GCL_HICON,hIcon)
    
        DIALOG SHOW MODAL hDlg, CALL MainDialogProc TO lRslt
    
        DeleteObject hFont
    
        FUNCTION = lRslt
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION MainDialogProc()
    
        LOCAL pNMHDR AS NMHDR PTR, PageNo AS LONG, hFontTab AS LONG
        LOCAL A1, I, II     AS LONG
        LOCAL ticc AS INIT_COMMON_CONTROLSEX
        DIM DirList$(0)
        DIM FileList$(0)
        DIM StApproved$(0)
        DIM StNotApproved$(0)
        DIM ApprovedMissing$(0)
        DIM AllApproved$(0)
        DIM TTFiles$(0)
        DIM PGList$(0)
        DIM TMP$(0)
        DIM TMP2$(0)
        DIM A$
    
    
    
        SELECT CASE (CBMSG)
    
            CASE %WM_INITDIALOG
                'add the main tab control and tab pages...
                DIM ghTab(9) AS GLOBAL LONG
                CALL PopulateComboBoxFedSt(CBHNDL, %IDC_ComboBox_FedSt)
    
            CASE %WM_COMMAND
               SELECT CASE AS LONG CBCTLMSG
                   CASE %CBN_SELCHANGE
                        SELECT CASE CBCTL
                           CASE %IDC_COMBOBOX_FEDST : GOSUB ResetItAll
                        END SELECT
                END SELECT
    
                SELECT CASE LOWRD(CBWPARAM)
                END SELECT
    
            CASE %WM_NOTIFY
                pNMHDR = CBLPARAM
                IF @pNMHDR.hWndFrom = GetDlgItem(CBHNDL,%IDTAB_MAIN) THEN
                    SELECT CASE @pNMHDR.Code
                        CASE %TCN_SELCHANGING
                            CONTROL SEND CBHNDL,%IDTAB_MAIN,%TCM_GETCURSEL,0,0 TO PageNo
                            DIALOG SHOW STATE ghTab(PageNo),%SW_HIDE
                        CASE %TCN_SELCHANGE
                            CONTROL SEND CBHNDL,%IDTAB_MAIN,%TCM_GETCURSEL,0,0 TO PageNo
                            DIALOG SHOW STATE ghTab(PageNo),%SW_SHOW
                    END SELECT
                END IF
    
            CASE %WM_DESTROY
                'destroy the tab control font...
                CONTROL SEND CBHNDL,%IDTAB_MAIN,%WM_GETFONT,0,0 TO hFontTab
                IF ISTRUE(hFontTab) THEN CALL DeleteObject(hFontTab)
    
        END SELECT
    
        EXIT FUNCTION
    
    ResetItAll:
    
        COMBOBOX GET TEXT CBHNDL, %IDC_Combobox_FedSt TO St$
    
        ST$=UCASE$(TRIM$(ST$))
    
        IF LEN(ST$)<2 THEN RETURN
    
        
        RESET FileList$() : RESET Tmp2$() : RESET Tmp$() : RESET TTFiles$() : RESET StApproved$()
        REDIM FileList$(0)
        REDIM Tmp2$(0)
        REDIM Tmp$(0)
        REDIM TTFiles$(0)
        REDIM StApproved$(0)
    
        ? "AlreadyCreated="+STR$(alreadyCreated)
        IF AlreadyCreated=0 THEN
           CALL CreateMainTabControl(CBHNDL)
           CALL CreateMainDlgButtons(CBHNDL)
           CALL SetWindowPos(GetDlgItem(CBHNDL,%IDTAB_MAIN),%HWND_BOTTOM, _
                 0,0,0,0,%SWP_NOMOVE OR %SWP_NOSIZE)
           AlreadyCreated=1
        ELSE
           FOR I=1 TO 9
             IF I=1 THEN ? "Here"
             CALL PopulateListBox(CBHNDL, 999+I, I)                             'Populate each Tab's listboxes
           NEXT
    
           DIALOG SHOW STATE ghTab(0),%SW_SHOW
    
        END IF
    
    RETURN
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION CreateDialogTabPage1(BYVAL hParent AS LONG) AS LONG
    
        LOCAL hDlg AS LONG,hFont AS LONG,rc AS RECT,sText AS STRING,lRslt AS LONG
        LOCAL STYLE AS DWORD,StyleEx AS DWORD,szCaption AS ASCIIZ*255
    
        DIALOG NEW hParent,"TabPage1",0,0,0,0,%WS_CHILD OR %DS_CONTROL _
            OR %WS_CLIPSIBLINGS OR %DS_NOFAILCREATE OR %DS_SETFONT,0,TO hDlg
    
        '---
        CALL SetRect(rc,0,0,597,158)
        STYLE   = %WS_BORDER OR %WS_CHILD OR %WS_CLIPSIBLINGS OR _
                  %WS_TABSTOP OR %WS_VISIBLE OR %WS_VSCROLL OR _
                  %LBS_NOINTEGRALHEIGHT OR %LBS_NOTIFY
        StyleEx = 0
        CONTROL ADD LISTBOX,hDlg,%IDC_LISTBOX_1, , _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        CALL PopulateListBox(hDlg,%IDC_LISTBOX_1,1)
    
        ghTab(0) = hDlg
    
        DIALOG SHOW MODELESS hDlg, CALL TabPageDlgProc1 TO lRslt
        DIALOG SHOW STATE hDlg,%SW_HIDE
    
        FUNCTION = lRslt
    END FUNCTION
    
    FUNCTION CreateDialogTabPage2(BYVAL hParent AS LONG) AS LONG
    
        LOCAL hDlg AS LONG,hFont AS LONG,rc AS RECT,sText AS STRING,lRslt AS LONG
        LOCAL STYLE AS DWORD,StyleEx AS DWORD,szCaption AS ASCIIZ*255
    
        DIALOG NEW hParent,"TabPage2",0,0,0,0,%WS_CHILD OR %DS_CONTROL _
            OR %WS_CLIPSIBLINGS OR %DS_NOFAILCREATE OR %DS_SETFONT,0,TO hDlg
    
        '---
        CALL SetRect(rc,0,0,597,158)
        STYLE   = %WS_BORDER OR %WS_CHILD OR %WS_CLIPSIBLINGS OR _
                  %WS_TABSTOP OR %WS_VISIBLE OR %WS_VSCROLL OR _
                  %LBS_NOINTEGRALHEIGHT OR %LBS_NOTIFY
        StyleEx = 0
        CONTROL ADD LISTBOX,hDlg,%IDC_LISTBOX_2, , _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        CALL PopulateListBox(hDlg,%IDC_LISTBOX_2,2)
    
        ghTab(1) = hDlg
    
        DIALOG SHOW MODELESS hDlg, CALL TabPageDlgProc2 TO lRslt
        DIALOG SHOW STATE hDlg,%SW_HIDE
    
        FUNCTION = lRslt
    END FUNCTION
    
    FUNCTION CreateDialogTabPage3(BYVAL hParent AS LONG) AS LONG
    
        LOCAL hDlg AS LONG,hFont AS LONG,rc AS RECT,sText AS STRING,lRslt AS LONG
        LOCAL STYLE AS DWORD,StyleEx AS DWORD,szCaption AS ASCIIZ*255
    
        DIALOG NEW hParent,"TabPage3",0,0,0,0,%WS_CHILD OR %DS_CONTROL _
            OR %WS_CLIPSIBLINGS OR %DS_NOFAILCREATE OR %DS_SETFONT,0,TO hDlg
    
        '---
        CALL SetRect(rc,0,0,597,158)
        STYLE   = %WS_BORDER OR %WS_CHILD OR %WS_CLIPSIBLINGS OR _
                  %WS_TABSTOP OR %WS_VISIBLE OR %WS_VSCROLL OR _
                  %LBS_NOINTEGRALHEIGHT OR %LBS_NOTIFY
        StyleEx = 0
        CONTROL ADD LISTBOX,hDlg,%IDC_LISTBOX_3, , _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        CALL PopulateListBox(hDlg,%IDC_LISTBOX_3,3)
    
        ghTab(2) = hDlg
    
        DIALOG SHOW MODELESS hDlg, CALL TabPageDlgProc3 TO lRslt
        DIALOG SHOW STATE hDlg,%SW_HIDE
    
        FUNCTION = lRslt
    END FUNCTION
    
    
    
    CALLBACK FUNCTION TabPageDlgProc1()
    
        LOCAL ptnmhdr AS NMHDR PTR
    
        SELECT CASE CBMSG
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_LISTBOX_1
                        SELECT CASE CBCTLMSG
                            CASE %LBN_SELCHANGE
                            CASE %LBN_DBLCLK
                        END SELECT
                END SELECT
    
            CASE %WM_DESTROY
                CALL DeleteControlFont(CBHNDL)
    
        END SELECT
    
    END FUNCTION
    
    CALLBACK FUNCTION TabPageDlgProc2()
    
        LOCAL ptnmhdr AS NMHDR PTR
    
        SELECT CASE CBMSG
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_LISTBOX_2
                        SELECT CASE CBCTLMSG
                            CASE %LBN_SELCHANGE
                            CASE %LBN_DBLCLK
                        END SELECT
                END SELECT
    
            CASE %WM_DESTROY
                CALL DeleteControlFont(CBHNDL)
    
        END SELECT
    
    END FUNCTION
    
    CALLBACK FUNCTION TabPageDlgProc3()
    
        LOCAL ptnmhdr AS NMHDR PTR
    
        SELECT CASE CBMSG
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_LISTBOX_3
                        SELECT CASE CBCTLMSG
                            CASE %LBN_SELCHANGE
                            CASE %LBN_DBLCLK
                        END SELECT
                END SELECT
    
            CASE %WM_DESTROY
                CALL DeleteControlFont(CBHNDL)
    
        END SELECT
    
    END FUNCTION
    
    
    FUNCTION CreateMainTabControl(BYVAL hDlg AS LONG) AS LONG
    
        LOCAL hFontTab AS LONG,i AS LONG,STYLE AS DWORD,StyleEx AS DWORD
        LOCAL rc AS RECT,rcm AS RECT,ttc_item AS TC_ITEM,szItem AS ASCIIZ*255
    
        'position tab within the main window...
        DIALOG GET CLIENT hDlg TO rcm.nRight,rcm.nBottom
        CALL SetRect(rc,2,22,rcm.nRight-4,rcm.nBottom-24)
    
        STYLE = %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
                %TCS_TABS OR %TCS_SINGLELINE OR %TCS_FOCUSONBUTTONDOWN
        StyleEx = 0
        CONTROL ADD "SysTabControl32",hDlg,%IDTAB_MAIN,"", _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        hFontTab = MakeFontEx("MS Sans Serif",8,0,0,0,0)
        CONTROL SEND hDlg,%IDTAB_MAIN,%WM_SETFONT,hFontTab,%TRUE
    
        'Insert tabs in the tab control...
        DIM sText(2) AS STRING
        sText(0) = "First Tab"
        sText(1) = "Second Tab"
        sText(2) = "Third Tab"
    
        FOR i = 0 TO UBOUND(sText)
            szItem              = sText(i)
            ttc_item.mask       = %TCIF_TEXT
            ttc_item.pszText    = VARPTR(szItem)
            ttc_item.cchTextMax = LEN(szItem)
            ttc_item.iImage     = -1
            ttc_item.lParam     = 0
            CONTROL SEND hDlg,%IDTAB_MAIN,%TCM_INSERTITEM,i,VARPTR(ttc_item)
        NEXT
    
        'create the tab pages...
        CALL CreateDialogTabPage1(hDlg)
        CALL CreateDialogTabPage2(hDlg)
        CALL CreateDialogTabPage3(hDlg)
    
        'allow the tab pages to fit evenly within the tab control...
        CALL SetTabPageRectDDT(hDlg,BYVAL VARPTR(rc))
        FOR i = 0 TO UBOUND(ghTab)
            DIALOG SET LOC ghTab(i),rc.nLeft,rc.nTop
            DIALOG SET SIZE ghTab(i),rc.nRight,rc.nBottom
        NEXT
    
        'only show the first dialog on tab 1...
        DIALOG SHOW STATE ghTab(0),%SW_SHOW
    
        FUNCTION = GetDlgItem(hDlg,%IDTAB_MAIN)
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '  ** Helper routines **
    '------------------------------------------------------------------------------
    SUB CreateMainDlgButtons(BYVAL hDlg AS LONG)
    
        'add buttons to the main dialog...
        LOCAL rc AS RECT, rcm AS RECT
        LOCAL cap AS LONG, bor AS LONG,tm AS LONG,gap AS LONG
    
        DIALOG GET CLIENT hDlg TO rcm.nRight, rcm.nBottom
    
        cap = GetSystemMetrics(%SM_CYCAPTION):DIALOG PIXELS hDlg,cap,cap TO UNITS cap,cap
        bor = GetSystemMetrics(%SM_CXBORDER) :DIALOG PIXELS hDlg,bor,bor TO UNITS bor,bor
        tm  = 7 :DIALOG PIXELS hDlg,tm,tm   TO UNITS tm,tm
        gap = 7 :DIALOG PIXELS hDlg,gap,gap TO UNITS gap,gap
    
    
    END SUB
    
    SUB SetTabPageRectDDT(BYVAL hDlg AS LONG,rcRet AS RECT)
    
        LOCAL tRect AS RECT,twRect AS RECT,pRect AS RECT,hTab AS LONG
        LOCAL b AS LONG,l AS LONG,r AS LONG,t AS LONG
        LOCAL lb AS LONG,tb AS LONG,c AS LONG,f AS LONG,tm AS LONG
    
        hTab = GetDlgItem(hDlg,%IDTAB_MAIN)
    
        CALL GetWindowRect(hTab,twRect)
        CALL GetWindowRect(GetParent(hTab),pRect)
    
        lb = twRect.nLeft-pRect.nLeft
        tb = twRect.nTop-pRect.nTop
        c  = GetSystemMetrics(%SM_CYCAPTION)
        f  = GetSystemMetrics(%SM_CXBORDER)
    
        CONTROL SEND hDlg,%IDTAB_MAIN,%TCM_GETITEMRECT,0,VARPTR(tRect)
    
        tm = 4
        l  = lb-2*f+tm
        t  = tb-c-f+tRect.nBottom+tm
        r  = twRect.nRight-twRect.nLeft-4*f-2*tm
        b  = twRect.nBottom-twRect.nTop-tRect.nBottom-4*f-2*tm
    
        CALL SetRect(rcRet,l,t,r,b)
    
        DIALOG PIXELS GetParent(hTab),rcRet.nLeft,rcRet.nTop TO UNITS rcRet.nLeft,rcRet.nTop
        DIALOG PIXELS GetParent(hTab),rcRet.nRight,rcRet.nBottom TO UNITS rcRet.nRight,rcRet.nBottom
    
    END SUB
    
    SUB DeleteControlFont(BYVAL hDlg AS LONG)
    
        LOCAL hCtlChild AS LONG, hFontCtl AS LONG
    
        hCtlChild = GetWindow(hDlg,%GW_CHILD)
        hFontCtl = SendMessage(hCtlChild,%WM_GETFONT,0,0)
        IF ISTRUE(hFontCtl) THEN DeleteObject hFontCtl
        WHILE hCtlChild
            hFontCtl = SendMessage(hCtlChild,%WM_GETFONT,0,0)
            IF ISTRUE(hFontCtl) THEN DeleteObject hFontCtl
            hCtlChild = GetWindow(hCtlChild, %GW_HWNDNEXT)
        WEND
    END SUB
    
    '------------------------------------------------------------------------------
    ' Get type of character set - ansi, symbol... a must for some fonts.
    '------------------------------------------------------------------------------
    FUNCTION EnumCharSet(elf AS ENUMLOGFONT,ntm AS NEWTEXTMETRIC,BYVAL FontType AS LONG,CharSet AS LONG) AS LONG
        CharSet = elf.elfLogFont.lfCharSet
    END FUNCTION
    '------------------------------------------------------------------------------
    ' Create a desirable font and return its handle.
    ' Enhanced with proper enumeration of character set via EnumCharSet.
    ' Original code by Dave Navarro, Enhancement by Borje Hagsten.
    '------------------------------------------------------------------------------
    
    FUNCTION MakeFontEx(BYVAL sFont AS STRING, BYVAL PointSize AS LONG, BYVAL fBold AS LONG, _
                        BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG, BYVAL StrikeThru AS LONG) AS LONG
    
        LOCAL hDC AS LONG, CharSet AS LONG, CyPixels AS LONG
    
        hDC = GetDC(%HWND_DESKTOP)
            CyPixels  = GetDeviceCaps(hDC, %LOGPIXELSY)
            EnumFontFamilies hDC, BYVAL STRPTR(sFont), CODEPTR(EnumCharSet), BYVAL VARPTR(CharSet)
        ReleaseDC %HWND_DESKTOP, hDC
    
        PointSize = 0 - (PointSize * CyPixels) \ 72
    
        FUNCTION = CreateFont(PointSize,0,0,0, fBold, _
                              fItalic,fUnderline,StrikeThru,CharSet, _
                              %OUT_TT_PRECIS,%CLIP_DEFAULT_PRECIS, _
                              %DEFAULT_QUALITY,%FF_DONTCARE, _
                              BYCOPY sFont)
    
    END FUNCTION
    
    SUB SetCtlTooltip(BYVAL hCtl AS LONG,sText AS STRING)
    
        STATIC hTooltip AS LONG,hInst AS LONG
        LOCAL ti AS TOOLINFO,szText AS ASCIIZ*255
    
        hInst = GetModuleHandle(BYVAL %NULL)
    
        IF hTooltip  = 0 THEN
            hToolTip = CreateWindowEx(0,"tooltips_class32","",%TTS_ALWAYSTIP, _
                                      0,0,0,0,0,BYVAL %NULL,hInst,BYVAL %NULL)
        END IF
    
        IF hTooltip THEN
            szText      = sText
            ti.cbSize   = LEN(ti)
            ti.uFlags   = %TTF_SUBCLASS OR %TTF_IDISHWND
            ti.hWnd     = GetParent(hCtl)
            ti.uId      = hCtl
            ti.lpszText = VARPTR(szText)
            CALL SendMessage(hToolTip,%TTM_ADDTOOL,0,BYVAL VARPTR(ti))
        END IF
    
    END SUB
    
    FUNCTION PopulateListBox(BYVAL hDlg AS LONG,BYVAL lID AS LONG,BYVAL lCount AS LONG) AS LONG
    
        LOCAL i,j,k,found  AS LONG
        LOCAL A$
    
        LISTBOX RESET hDLg, lID   'Make sure it's empty to begin with
    
        IF lcount=1 THEN ? "ST$="+ST$
        SELECT CASE lCount
          CASE 1
              FOR I=1 TO 10
                 LISTBOX ADD hDlg, lID, ST$+" Tab 1 Line "+FORMAT$(I)
              NEXT
          CASE 2
              FOR I=1 TO 10
                 LISTBOX ADD hDlg, lID, ST$+" Tab 2 Line "+FORMAT$(I)
              NEXT
          CASE 3
              FOR I=1 TO 10
                 LISTBOX ADD hDlg, lID, ST$+" Tab 3 Line "+FORMAT$(I)
              NEXT
        END SELECT
    
    
    END FUNCTION
    Nathan Maddox

  • #2
    A glance at the code shows the listboxes are created as a child of each tab page, but you are calling the populate function with CBHNDL.

    Try changing:

    Code:
     
    PopulateListBox(CBHNDL, 999+I, I)
    to

    Code:
     
    PopulateListBox(ghTab(?), 999+I, I)
    ..where "?" is the tab dialog index.
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Thank You Kev Peel

      Works like a charm.
      Nathan Maddox

      Comment

      Working...
      X