Announcement

Collapse
No announcement yet.

Tab select

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

  • Tab select

    Good morning!

    I am stucked: I want to use tabs in a dialog, but when I add controls to the tab, the program hangs. Can you help?

    Code:
    FUNCTION ShowCP(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt  AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_CP->->
        LOCAL hDlg   AS DWORD
        LOCAL hFont1 AS DWORD
    
        DIALOG NEW hParent, "Camping Platz Info", 70, 70, 491, 395, %WS_POPUP OR _
            %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR _
            %WS_VISIBLE OR %DS_MODALFRAME OR %DS_CENTER OR %DS_3DLOOK OR _
            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD LABEL,    hDlg, %IDC_CPNAME, "", 5, 6, 480, 24
        CONTROL ADD TEXTBOX,  hDlg, %IDC_CPAnschrift, "Anschrift", 10, 54, 225, _
            51, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR _
            %WS_VSCROLL OR %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR _
            %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR _
            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD TEXTBOX,  hDlg, %IDC_CPTEL, "", 310, 54, 170, 15
        CONTROL ADD TEXTBOX,  hDlg, %IDC_CPEMAIL, "", 310, 69, 170, 15
        CONTROL ADD TEXTBOX,  hDlg, %IDC_CPWEB, "", 310, 84, 170, 15
        CONTROL ADD "SysListView32", hDlg, %IDC_CPVISITS, "", 10, 123, 150, 93, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %LVS_REPORT OR _
            %LVS_SINGLESEL OR %LVS_SHOWSELALWAYS, %WS_EX_CLIENTEDGE OR _
            %WS_EX_LEFT OR %WS_EX_RIGHTSCROLLBAR
    
        CONTROL ADD OPTION,   hDlg, %IDC_NOISE1, "Tag u. Nacht ruhig", 175, 132, _
            110, 12, %WS_CHILD OR %WS_VISIBLE OR %WS_GROUP OR %WS_TABSTOP OR _
            %BS_TEXT OR %BS_AUTORADIOBUTTON OR %BS_LEFT OR %BS_VCENTER, _
            %WS_EX_LEFT OR %WS_EX_LTRREADING
        CONTROL ADD OPTION,   hDlg, %IDC_NOISE2, "Nachts ruhig", 175, 144, 110, _
            12
        CONTROL ADD OPTION,   hDlg, %IDC_NOISE3, "Überwiegend ruhig", 175, 156, _
            110, 12
        CONTROL ADD OPTION,   hDlg, %IDC_NOISE4, "Geräusche durch Straße oder " + _
            "Nachbarplatz", 175, 168, 110, 21
        CONTROL ADD OPTION,   hDlg, %IDC_NOISE5, "Geräuschvoll, nicht unbedingt " + _
            "zu empfehlen", 175, 189, 110, 21
        CONTROL ADD "msctls_updown32", hDlg, %IDC_MSCTLS_UPDOWN32_1, _
            "msctls_updown32_1", 295, 117, 11, 105, %WS_CHILD OR %WS_VISIBLE
        CONTROL ADD IMAGEX,   hDlg, %IDC_CPIMAGEX, "", 310, 117, 175, 105, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_BITMAP OR %SS_SUNKEN
        CONTROL ADD "SysDateTimePick32", hDlg, %IDC_CPOPEN_FROM, "", 75, 237, 60, _
            12, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %DTS_SHORTDATEFORMAT, _
            %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
            %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD "SysDateTimePick32", hDlg, %IDC_CPOPEN_TO, _
            "SysDateTimePick32_1", 140, 237, 60, 12, %WS_CHILD OR %WS_VISIBLE OR _
            %WS_TABSTOP OR %DTS_SHORTDATEFORMAT, %WS_EX_CLIENTEDGE OR _
            %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD CHECKBOX, hDlg, %IDC_CPDOGS_MAIN, "Hunde erlaubt in " + _
            "Hauptsaison", 10, 252, 190, 12
        CONTROL ADD CHECKBOX, hDlg, %IDC_CPDOGS_OUTOFSEASON, "Hunde erlaubt in " + _
            "Nebensaison", 10, 264, 190, 12
        CONTROL ADD CHECKBOX, hDlg, %IDC_CPWINTER, "Wintercamping", 10, 276, 190, _
            12
        CONTROL ADD CHECKBOX, hDlg, %IDC_CPALLYEAR, "Dauercamping", 10, 288, 190, _
            12
        CONTROL ADD CHECKBOX, hDlg, %IDC_CPFKK, "FKK Camp", 10, 300, 190, 12
        CONTROL ADD CHECKBOX, hDlg, %IDC_CPBORDERS, "Parzellierte " + _
            "Touristenplätze", 10, 312, 190, 12
        CONTROL ADD LISTBOX,  hDlg, %IDC_CPPITCH, , 10, 324, 190, 15, %WS_CHILD _
            OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR %LBS_NOTIFY, _
            %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
            %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD LISTBOX,  hDlg, %IDC_CPACCESS, , 10, 339, 190, 15, %WS_CHILD _
            OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR %LBS_NOTIFY, _
            %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
            %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD "SysTabControl32", hDlg, %IDC_SYSTABCONTROL32_1, "", 210, _
            237, 270, 117, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
            %TCS_SINGLELINE OR %TCS_RIGHTJUSTIFY, %WS_EX_LEFT OR _
            %WS_EX_LTRREADING
        CONTROL ADD LINE,     hDlg, %IDC_LINE1, "Line1", 5, 36, 480, 3
        CONTROL ADD FRAME,    hDlg, %IDC_UNUSED, "CP-Informationen und " + _
            "Infrastruktur", 5, 225, 480, 132
        CONTROL ADD FRAME,    hDlg, %IDC_UNUSED, "Anschrift", 5, 45, 238, 63
        CONTROL ADD FRAME,    hDlg, %IDC_UNUSED, "Kontaktdaten", 245, 45, 240, 63
        CONTROL ADD LABEL,    hDlg, %IDC_UNUSED, "Tel:", 250, 57, 55, 12
        CONTROL ADD LABEL,    hDlg, %IDC_UNUSED, "email", 250, 72, 55, 12
        CONTROL ADD LABEL,    hDlg, %IDC_UNUSED, "Web", 250, 90, 55, 12
        CONTROL ADD FRAME,    hDlg, %IDC_UNUSED, "Besuche", 5, 114, 160, 108
        CONTROL ADD FRAME,    hDlg, %IDC_UNUSED, "Platz Ruhe / Geräuschspiegel", _
            170, 114, 120, 108
        CONTROL ADD LABEL,    hDlg, %IDC_UNUSED, "Öffnungszeit", 10, 237, 60, 12
    
        hFont1 = PBFormsMakeFont("MS Sans Serif", 18, 700, %FALSE, %FALSE, _
            %FALSE, %ANSI_CHARSET)
    
        CONTROL SEND hDlg, %IDC_CPNAME, %WM_SETFONT, hFont1, 0
    #PBFORMS END DIALOG
    
    	insert_visists_header (hDlg)
    	insert_Pitch_sizes(hDlg)
    	insert_Tab_Options(hDlg)
    
        DIALOG SHOW MODAL hDlg, CALL ShowCPProc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_CP
        DeleteObject hFont1
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    
    FUNCTION AttachACCELERATOR1(BYVAL hDlg AS DWORD) AS DWORD
    #PBFORMS BEGIN ACCEL %IDR_ACCELERATOR1->%IDD_AZEL
        LOCAL hAccel   AS DWORD
        LOCAL tAccel() AS ACCELAPI
        DIM   tAccel(1 TO 1) AS ACCELAPI
    
        ASSIGNACCEL tAccel(1), ASC("I"), %IDM_CPINFO, %FVIRTKEY OR %FCONTROL OR _
            %FNOINVERT
    
        ACCEL ATTACH hDlg, tAccel() TO hAccel
    #PBFORMS END ACCEL
        FUNCTION = hAccel
    END FUNCTION
    
    #PBFORMS BEGIN ASSIGNACCEL 
    FUNCTION ASSIGNACCEL(tAccel AS ACCELAPI, BYVAL wKey AS WORD, BYVAL wCmd AS _
        WORD, BYVAL byFVirt AS BYTE) AS LONG
        tAccel.fVirt = byFVirt
        tAccel.key   = wKey
        tAccel.cmd   = wCmd
    END FUNCTION
    #PBFORMS END ASSIGNACCEL
    
    SUB insert_visists_header (BYVAL hDlg AS DWORD)
        listview INSERT column hDlg, %IDC_CPVISITS, 1,"Besuch", 35, 0
        listview INSERT column hDlg, %IDC_CPVISITS, 2,"von",50,0
        Listview INSERT column hDlg, %IDC_CPVISITS, 3,"bis",50,0
        listview fit header hDlg, %IDC_CPVISITS, 3
    END SUB
    
    SUB insert_Pitch_Sizes(BYVAL hDlg AS DWORD)
    
        LISTBOX ADD hDlg, %IDC_CPPITCH, "Stellplatzgröße <= 70 m² (klein)"
        LISTBOX ADD hDlg, %IDC_CPPITCH, "Stellplatzgröße > 70 < 100 m² (mittel)"
        LISTBOX ADD hDlg, %IDC_CPPITCH, "Stellplatzgröße >= 100 m² (groß)"
         
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP und Stellplatz leicht"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP mittel / Stellplatz leicht"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP schwierig / Stellplatz leicht"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP leicht / Stellplatz mittel"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP leicht / Stellplatz schwierig"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP mittel / Stellplatz leicht"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP und Stellplatz mittel"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP mittel / Stellplatz schwierig"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP schwierig / Stellplatz leicht"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP schwierig / Stellplatz mittel"
    	LISTBOX ADD hDlg, %IDC_CPACCESS, "Zufahrt zu CP und Stellplatz schwierig"
    end sub
    
    sub insert_Tab_Options(byval hDlg as dword)
    local hTab1, hTab2, hTab3, hTab4 AS LONG
    
    'TAB 1
    	TAB INSERT PAGE hDlg, %IDC_CP_OPTIONS, 1, 0, "Infrastruktur" TO hTab1
    
    '	 CONTROL ADD CHECKBOX, hTab1, %IDC_CP_MAINS, "Strom", 2, 5, 105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_WLAN, "Wireless LAN", 2, 17, 105, _
    '        12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_TERMINAL, "Internet Terminal (am " + _
    '        "Platz)", 2, 29, 105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_WOMO, "Ver- und Entsorgung WoMo", _
    '        2, 41, 105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_FRESHWATER, "Frischwasseranschluß", _
    '        2, 53, 105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_GREYWATER, "Ab- (Grau-) " + _
    '        "Wasseranschluß", 2, 65, 105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_SAT, "SAT- / Kabelantenne", 2, 77, _
    '        105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_GASSUPPLY, "Gasversorgungsanschluß", _
    '        2, 89, 105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_LEBENSM, "Lebensmittel am Platz", _
    '        140, 5, 105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_IMBISS, "Imbiß am Platz", 140, 17, _
    '        105, 12
    '    CONTROL ADD CHECKBOX, hTab1, %IDC_CP_RESTAURANT, "Restaurant am Platz", _
    '        140, 29, 105, 12
              
    'TAB2
        TAB INSERT PAGE hDlg, %IDC_CP_OPTIONS, 2, 0, "Sanitär"  TO hTab2
    
    '    CONTROL ADD CHECKBOX, hTab2, %IDC_CP_BABY, "Babywickelraum", 2, 5, _
    '      120, 12
    '    CONTROL ADD CHECKBOX, hTab2, %IDC_CP_WASHBOX, "Einzelwaschkabinen", 2, _
    '      17, 120, 12
    
    'TAB3         
    	TAB INSERT PAGE hDlg, %IDC_CP_OPTIONS, 3, 0, "Freizeit" TO hTab3
    '	CONTROL ADD CHECKBOX, hTab3, %IDC_CHILDREN,"Kinderspielplatz",2,5,120,12
    
    'TAB4
    	TAB INSERT page hDlg, %IDC_CP_OPTIONS, 4, 0, "Eigener Kommentar" TO hTab4
    '	CONTROL ADD TEXTBOX,  hTab4, %IDC_COMMENT, "", 2, 5, 260, 96, _
    '		%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR _
    '		%WS_VSCROLL OR %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR _
    '		%ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR _
    '		%WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
    
    END SUB

  • #2
    I don't see any individual dialogs.

    ...here is simple DDT example:

    Code:
    '******************************************************************************
    ' PROJECT: Quick Tab Visual Designer DDT generated code.
    ' FILE:    Your file name
    ' CREATED: On 07-28-2009 at 07:09:17
    '******************************************************************************
    
    #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
    %IDTAB_PAGE_4    = 104
    %IDC_OK          = 105
    %IDC_CANCEL      = 106
    %IDC_APPLY       = 107
    
    '---Page 1 control identifiers
    %IDC_EDIT_1     = 1000
    %IDC_GROUPBOX_1 = 1001
    
    '---Page 2 control identifiers
    %IDC_BUTTON_1      = 1002
    %IDC_STATICLABEL_1 = 1003
    
    '---Page 3 control identifiers
    %IDC_LISTVIEW_1    = 1004
    
    '---Page 4 control identifiers
    %IDC_COMBOBOX_1    = 1005
    %IDC_GROUPBOX_2    = 1006
    %IDC_RADIOBUTTON_1 = 1007
    %IDC_RADIOBUTTON_2 = 1008
    %IDC_RADIOBUTTON_3 = 1009
    
    '---Declares
    DECLARE FUNCTION CreateMainDialog(BYVAL hParent AS LONG) AS LONG
    DECLARE FUNCTION CreateMainTabControl(BYVAL hDlg AS LONG) AS LONG
    DECLARE FUNCTION CreateDialogTabPage1(BYVAL hParent AS LONG) AS LONG
    DECLARE FUNCTION CreateDialogTabPage2(BYVAL hParent AS LONG) AS LONG
    DECLARE FUNCTION CreateDialogTabPage3(BYVAL hParent AS LONG) AS LONG
    DECLARE FUNCTION CreateDialogTabPage4(BYVAL hParent AS LONG) AS LONG
    DECLARE CALLBACK FUNCTION MainDialogProc()
    DECLARE CALLBACK FUNCTION TabPageDlgProc1()
    DECLARE CALLBACK FUNCTION TabPageDlgProc2()
    DECLARE CALLBACK FUNCTION TabPageDlgProc3()
    DECLARE CALLBACK FUNCTION TabPageDlgProc4()
    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 SampleComboBox(BYVAL hDlg AS LONG,BYVAL lID AS LONG,BYVAL lCount AS LONG) AS LONG
    DECLARE FUNCTION SampleListView(BYVAL hDlg AS LONG,BYVAL lID AS LONG,BYVAL lColCnt AS LONG,BYVAL lRowCnt AS LONG) AS LONG
    
    '---Globals
    GLOBAL ghTab() AS LONG  'keep handles for each tab page
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
    
        LOCAL ticc AS INIT_COMMON_CONTROLSEX
    
        'Load the common controls library...
        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
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    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
    
        CALL SetRect(rc,50,50,256,225)
    
        DIALOG NEW hParent, "Your Caption",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom, _
            %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME 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
    
        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
    
        SELECT CASE (CBMSG)
    
            CASE %WM_INITDIALOG
                'add the main tab control and tab pages...
                DIM ghTab(3) AS GLOBAL LONG
                CALL CreateMainTabControl(CBHNDL)
                CALL CreateMainDlgButtons(CBHNDL)
                CALL SetWindowPos(GetDlgItem(CBHNDL,%IDTAB_MAIN),%HWND_BOTTOM, _
                         0,0,0,0,%SWP_NOMOVE OR %SWP_NOSIZE)
    
            CASE %WM_COMMAND
                SELECT CASE LOWRD(CBWPARAM)
                    CASE %IDC_OK
                        IF HIWRD(CBWPARAM) = %BN_CLICKED THEN
                            DIALOG END CBHNDL
                        END IF
                    CASE %IDC_CANCEL,%IDCANCEL
                        IF HIWRD(CBWPARAM) = %BN_CLICKED THEN
                            DIALOG END CBHNDL
                        END IF
                    CASE %IDC_APPLY
                        IF HIWRD(CBHNDL) = %BN_CLICKED THEN
                            '
                        END IF
                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
    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
    
        '---
        szCaption = "Edit1"
        CALL SetRect(rc,47,74,133,16)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR %WS_VISIBLE
        StyleEx = %WS_EX_CLIENTEDGE
        CONTROL ADD TEXTBOX,hDlg,%IDC_EDIT_1,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
        '---
        szCaption = "GroupBox1"
        CALL SetRect(rc,13,49,213,62)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %BS_GROUPBOX
        StyleEx = 0
        CONTROL ADD FRAME,hDlg,%IDC_GROUPBOX_1,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        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
    
        '---
        szCaption = "Label1"
        CALL SetRect(rc,47,49,133,12)
        STYLE   = %WS_BORDER OR %WS_CHILD OR %WS_CLIPSIBLINGS OR _
                  %WS_VISIBLE OR %SS_NOTIFY
        StyleEx = 0
        CONTROL ADD LABEL,hDlg,%IDC_STATICLABEL_1,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
        '---
        szCaption = "Button1"
        CALL SetRect(rc,73,74,67,18)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                  %WS_VISIBLE OR %BS_PUSHBUTTON
        StyleEx = 0
        CONTROL ADD BUTTON,hDlg,%IDC_BUTTON_1,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        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
    
        '---
        szCaption = "ListView1"
        CALL SetRect(rc,13,18,207,129)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                  %WS_VISIBLE OR %LVS_REPORT OR %LVS_SHOWSELALWAYS OR _
                  %LVS_SINGLESEL
        StyleEx = %WS_EX_CLIENTEDGE
        CONTROL ADD "SysListView32",hDlg,%IDC_LISTVIEW_1,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        CALL SampleListView(hDlg,%IDC_LISTVIEW_1,3,30)
    
        ghTab(2) = hDlg
    
        DIALOG SHOW MODELESS hDlg, CALL TabPageDlgProc3 TO lRslt
        DIALOG SHOW STATE hDlg,%SW_HIDE
    
        FUNCTION = lRslt
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION CreateDialogTabPage4(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,"TabPage4",0,0,0,0,%WS_CHILD OR %DS_CONTROL _
            OR %WS_CLIPSIBLINGS OR %DS_NOFAILCREATE OR %DS_SETFONT,0,TO hDlg
    
        '---
        szCaption = "GroupBox2"
        CALL SetRect(rc,40,55,107,86)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %BS_GROUPBOX
        StyleEx = 0
        CONTROL ADD FRAME,hDlg,%IDC_GROUPBOX_2,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
            
        '---
        CALL SetRect(rc,40,25,133,49)
        STYLE   = %WS_BORDER OR %WS_CHILD OR %WS_CLIPSIBLINGS OR _
                  %WS_TABSTOP OR %WS_VISIBLE OR %CBS_DROPDOWNLIST OR _
                  %CBS_NOINTEGRALHEIGHT
        StyleEx = 0
        CONTROL ADD COMBOBOX,hDlg,%IDC_COMBOBOX_1, , _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
        '---
        szCaption = "Radio1"
        CALL SetRect(rc,47,68,73,12)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                  %WS_VISIBLE OR %BS_AUTORADIOBUTTON
        StyleEx = 0
        CONTROL ADD OPTION,hDlg,%IDC_RADIOBUTTON_1,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
        '---
        szCaption = "Radio2"
        CALL SetRect(rc,47,86,73,12)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                  %WS_VISIBLE OR %BS_AUTORADIOBUTTON
        StyleEx = 0
        CONTROL ADD OPTION,hDlg,%IDC_RADIOBUTTON_2,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
        '---
        szCaption = "Radio3"
        CALL SetRect(rc,47,105,73,12)
        STYLE   = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
                  %WS_VISIBLE OR %BS_AUTORADIOBUTTON
        StyleEx = 0
        CONTROL ADD OPTION,hDlg,%IDC_RADIOBUTTON_3,szCaption, _
            rc.nLeft,rc.nTop,rc.nRight,rc.nBottom,STYLE,StyleEx
    
        CALL SampleComboBox(hDlg,%IDC_COMBOBOX_1,30)
    
        ghTab(3) = hDlg
    
        DIALOG SHOW MODELESS hDlg, CALL TabPageDlgProc4 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_EDIT_1
                        SELECT CASE CBCTLMSG
                            CASE %EN_CHANGE
                        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_BUTTON_1
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                        END IF
                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_NOTIFY
                ptnmhdr = CBLPARAM
                SELECT CASE @ptnmhdr.idFrom
                    CASE %IDC_LISTVIEW_1        'ListView...
                        SELECT CASE @ptnmhdr.code
                            CASE %LVN_COLUMNCLICK
                            CASE %LVN_ITEMCHANGED
                        END SELECT
                END SELECT
    
            CASE %WM_DESTROY
                CALL DeleteControlFont(CBHNDL)
    
        END SELECT
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION TabPageDlgProc4()
    
        LOCAL ptnmhdr AS NMHDR PTR
    
        SELECT CASE CBMSG
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_COMBOBOX_1
                        SELECT CASE CBCTLMSG
                            CASE %CBN_SELCHANGE
                            CASE %CBN_SELENDOK
                        END SELECT
                    CASE %IDC_RADIOBUTTON_1
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                        END IF
                    CASE %IDC_RADIOBUTTON_2
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                        END IF
                    CASE %IDC_RADIOBUTTON_3
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                        END IF
                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,2,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(3) AS STRING
        sText(0) = "Tab1"
        sText(1) = "Tab2"
        sText(2) = "Tab3"
        sText(3) = "Tab4"
    
        FOR i = 0 TO 3
            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)
        CALL CreateDialogTabPage4(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  = 6 :DIALOG PIXELS hDlg,tm,tm   TO UNITS tm,tm
        gap = 6 :DIALOG PIXELS hDlg,gap,gap TO UNITS gap,gap
    
        CALL SetRect(rc,rcm.nRight+bor-tm-120-gap*2,rcm.nBottom-cap-0,40,15)
        CONTROL ADD BUTTON,hDlg,%IDC_OK,"&OK",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom
        CALL SetRect(rc,rcm.nRight+bor-tm-80-gap,rcm.nBottom-cap-0,40,15)
        CONTROL ADD BUTTON,hDlg,%IDC_CANCEL,"&Cancel",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom
        CALL SetRect(rc,rcm.nRight+bor-tm-40,rcm.nBottom-cap-0,40,15)
        CONTROL ADD BUTTON,hDlg,%IDC_APPLY,"&Apply",rc.nLeft,rc.nTop,rc.nRight,rc.nBottom
    
    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
    
    '--------------------------------------------------------------------------------
    ' ** Sample code **
    '--------------------------------------------------------------------------------
    FUNCTION SampleComboBox(BYVAL hDlg AS LONG,BYVAL lID AS LONG,BYVAL lCount AS LONG) AS LONG
    
        LOCAL i AS LONG
    
        FOR i = 1 TO lCount
            COMBOBOX ADD hDlg, lID, "Item #" + FORMAT$(i)
        NEXT i
    
        CONTROL SEND hDlg,lID,%CB_SETCURSEL,0,0
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION SampleListView(BYVAL hDlg AS LONG,BYVAL lID AS LONG,BYVAL lColCnt AS LONG, BYVAL lRowCnt AS LONG) AS LONG
    
        LOCAL lStyle AS LONG,tLVC AS LV_COLUMN,tLVI AS LV_ITEM
        LOCAL szBuf AS ASCIIZ*32,lCol AS LONG,lRow AS LONG,hCtl AS LONG
    
        CONTROL HANDLE hDlg, lID TO hCtl
    
        lStyle = ListView_GetExtendedListViewStyle(hCtl)
        ListView_SetExtendedListViewStyle hCtl, _
            lStyle OR %LVS_EX_FULLROWSELECT OR %LVS_EX_GRIDLINES
    
        'Load column headers.
        tLVC.mask    = %LVCF_FMT OR %LVCF_TEXT OR %LVCF_SUBITEM
        tLVC.fmt     = %LVCFMT_LEFT
        tLVC.pszText = VARPTR(szBuf)
        FOR lCol = 0 TO lColCnt - 1
            szBuf = "Column" + FORMAT$(lCol)
            tLVC.iOrder = lCol
           ListView_InsertColumn hCtl, lCol, tLVC
        NEXT lCol
    
        'Load sample data.
        FOR lRow = 0 TO lRowCnt - 1
            tLVI.stateMask   = %LVIS_FOCUSED
            tLVI.pszText     = VARPTR(szBuf)
            tLVI.iItem       = lRow
            FOR lCol = 0 TO lColCnt - 1
                szBuf           = "Column" + FORMAT$(lCol) + " Row" + FORMAT$(lRow)
                tLVI.iSubItem   = lCol
                tLVI.lParam     = lRow
                IF lCol = 0 THEN
                    tLVI.mask = %LVIF_TEXT OR %LVIF_PARAM OR %LVIF_STATE
                    ListView_InsertItem hCtl, tLVI
                ELSE
                    tLVI.mask = %LVIF_TEXT
                    ListView_SetItem hCtl, tLVI
                END IF
            NEXT lCol
        NEXT i
    
        'Auto size columns.
        FOR lCol = 0 TO lColCnt - 1
            ListView_SetColumnWidth hCtl, lCol, %LVSCW_AUTOSIZE
        NEXT lCol
    
    END FUNCTION
    Last edited by Jules Marchildon; 28 Jul 2009, 06:17 AM.
    Best regards
    Jules
    www.rpmarchildon.com

    Comment


    • #3
      Well, the code I posted is only a fraction of the whole program. When I quote all occurances of "control add option" in the dialog, the program does not hang, but I still cannot change the display of the tab, i.e. I can change the tab header, but the shown controls remain the same.

      Hope you understand what I mean...
      Last edited by Werner Bleckwendt; 28 Jul 2009, 06:53 AM.

      Comment


      • #4
        It would help to see the whole program, or a code snippet that is compilable and runable, at least until it hangs, since the issue maybe caused something elsewhere.
        Rod
        In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

        Comment


        • #5
          Werner,

          Are you creating individual dialogs for each tab?
          I can tell in your sub sub insert_Tab_Options(byval hDlg as dword)
          that you are not. You cannot attach controls to the tab itself.

          Basically, you create 4 dialogs and yo add your controls
          to each respective dialog, then show-hide them
          based on which tab is selected. See my code for example.

          Regards,
          Jules
          Best regards
          Jules
          www.rpmarchildon.com

          Comment


          • #6
            Sorry Werner,

            I just read the PB9 Help, as I was not sure what the Tab Insert Page statement was...


            TAB INSERT PAGE hDlg, id&, page&, image&, text$ [CALL CallBack] TO Hndlv&

            A page is added to this TAB Control. The parameter page& specifies the position of the page to be inserted (1=first, 2=second, etc.). An optional image to be displayed on the tab area is selected from the attached IMAGELIST, based upon the parameter image& (1=first, 2=second, etc.). Set image& to 0 if no image is desired. The text$ parameter specifies the text to be displayed on the tab area. CallBack is the name of a callback procedure to be used for the page dialog. The handle of the newly created dialog is assigned to the variable designated by Hndlv&.


            My mistake.
            Regards,
            Jules
            Best regards
            Jules
            www.rpmarchildon.com

            Comment


            • #7
              Here you go...

              I used the tab example that came with PBWIN9 and installed your sub "insert_Tab_Options(hDlg)"

              What made it work correctly was adding a callback to the statement...

              TAB INSERT PAGE hDlg, %ID_TAB, 1, 0, "Infrastruktur" CALL TabProc TO hTab1

              HTH
              Regards,
              Jules


              Code:
              '==============================================================================
              '
              '  TABCONTROL.BAS example for PowerBASIC for Windows
              '  Copyright (c) 2008 PowerBASIC, Inc.
              '  All Rights Reserved.
              '
              '  Small DDT demonstration of a Tab control.
              '
              '==============================================================================
              
              #COMPILER PBWIN 9
              #COMPILE EXE
              #DIM ALL
              
              #INCLUDE "win32api.inc"
              
              ' Control equates
              %ID_TAB            = 1000
              %ID_TAB1_TBFIRST   = 1001
              %ID_TAB1_LBFIRST   = 1002
              %ID_TAB1_LBLAST    = 1003
              %ID_TAB1_TBLAST    = 1004
              %ID_TAB1_BNSUBMIT  = 1005
              %ID_TAB2_CBCHOICES = 1006
              %ID_TAB3_LBCHOICES = 1007
              %ID_TAB3_TEXTBOX   = 1008
              
              
              GLOBAL hDlg AS LONG
              
              
              SUB insert_Tab_Options(BYVAL hDlg AS DWORD)
              
              LOCAL hTab1, hTab2, hTab3, hTab4 AS LONG
              
              'TAB 1
                  TAB INSERT PAGE hDlg, %ID_TAB, 1, 0, "Infrastruktur" CALL TabProc TO hTab1
              
                  CONTROL ADD CHECKBOX, hTab1, 100, "Strom", 2, 5, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 102, "Wireless LAN", 2, 17, 105,12
                  CONTROL ADD CHECKBOX, hTab1, 103, "Internet Terminal (am " + "Platz)", 2, 29, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 104, "Ver- und Entsorgung WoMo", 2, 41, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 105, "Frischwasseranschluß",2, 53, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 106, "Ab- (Grau-) " + "Wasseranschluß", 2, 65, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 107, "SAT- / Kabelantenne", 2, 77, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 108, "Gasversorgungsanschluß", 2, 89, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 109, "Lebensmittel am Platz",140, 5, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 110, "Imbiß am Platz", 140, 17, 105, 12
                  CONTROL ADD CHECKBOX, hTab1, 111, "Restaurant am Platz",140, 29, 105, 12
              
              'TAB2
                  TAB INSERT PAGE hDlg, %ID_TAB, 2, 0, "Sanitär"  CALL TabProc TO hTab2
              
                  CONTROL ADD CHECKBOX, hTab2, 112, "Babywickelraum", 2, 5,120, 12
                  CONTROL ADD CHECKBOX, hTab2, 113, "Einzelwaschkabinen", 2,17, 120, 12
              
              'TAB3
                  TAB INSERT PAGE hDlg, %ID_TAB, 3, 0, "Freizeit"  CALL TabProc TO hTab3
                 CONTROL ADD CHECKBOX, hTab3, 114,"Kinderspielplatz",2,5,120,12
              
              'TAB4
                  TAB INSERT PAGE hDlg, %ID_TAB, 4, 0, "Eigener Kommentar" CALL TabProc TO  hTab4
                 CONTROL ADD TEXTBOX,  hTab4, 115, "", 2, 5, 260, 96, _
                     %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR _
                     %WS_VSCROLL OR %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR _
                     %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR _
                     %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
              
              END SUB
              
              
              FUNCTION PBMAIN () AS LONG
                LOCAL hTab1     AS LONG
                LOCAL hTab2     AS LONG
                LOCAL hTab3     AS LONG
                LOCAL hBoldFont AS LONG
              
                ' Create the font used by some controls in this example
                FONT NEW "Arial", 10, 1 TO hBoldFont
              
                DIALOG NEW 0, "Tab Control Example", , , 300, 140, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR _
                  %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
                  %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
              
                ' Add a Tab control to the main dialog box
                CONTROL ADD TAB, hDlg, %ID_TAB, "", 1, 1, 298, 138
              
              #IF 0
                ' Build the Tab 1 dialog and it's controls
                TAB INSERT PAGE hDlg, %ID_TAB, 1, 0, "Tab 1", CALL TabProc TO hTab1
                CONTROL ADD LABEL,   hTab1, %ID_TAB1_LBFIRST,  "First name", 2, 6, 100, 12
                CONTROL SET COLOR    hTab1, %ID_TAB1_LBFIRST, %WHITE, -2
                CONTROL SET FONT     hTab1, %ID_TAB1_LBFIRST, hBoldFont
                CONTROL ADD TEXTBOX, hTab1, %ID_TAB1_TBFIRST, "", 60, 6, 100, 12
              
                CONTROL ADD LABEL,   hTab1, %ID_TAB1_LBLAST,  "Last name", 2, 20, 100, 12
                CONTROL SET COLOR    hTab1, %ID_TAB1_LBLAST, %WHITE, -2
                CONTROL SET FONT     hTab1, %ID_TAB1_LBLAST, hBoldFont
                CONTROL ADD TEXTBOX, hTab1, %ID_TAB1_TBLAST, "", 60, 20, 100, 12
              
                CONTROL ADD BUTTON,  hTab1, %ID_TAB1_BNSUBMIT, "Submit", 235, 100, 50, 14
                CONTROL SET FONT     hTab1, %ID_TAB1_BNSUBMIT, hBoldFont
              
                ' Build the Tab 2 dialog and it's controls
                TAB INSERT PAGE hDlg, %ID_TAB, 2, 0, "Tab 2", CALL TabProc TO hTab2
                CONTROL ADD COMBOBOX, hTab2, %ID_TAB2_CBCHOICES, , 2, 6, 100, 40, %CBS_DROPDOWNLIST OR %WS_TABSTOP OR %WS_CHILD
                CONTROL SET COLOR     hTab2, %ID_TAB2_CBCHOICES, %BLACK, %GREEN
                CONTROL SET FONT      hTab2, %ID_TAB2_CBCHOICES, hBoldFont
                COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 1"
                COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 2"
                COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 3"
                COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 4"
                COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 5"
                COMBOBOX SELECT       hTab2, %ID_TAB2_CBCHOICES, 1
              
                ' Build the Tab 3 dialog and it's controls
                TAB INSERT PAGE hDlg, %ID_TAB, 3, 0, "Tab 3", CALL TabProc TO hTab3
                CONTROL ADD LISTBOX,  hTab3, %ID_TAB3_LBCHOICES, , 2, 6, 100, 60
                CONTROL SET COLOR     hTab3, %ID_TAB3_LBCHOICES, %WHITE, %RED
                CONTROL SET FONT      hTab3, %ID_TAB3_LBCHOICES, hBoldFont
                LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 1"
                LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 2"
                LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 3"
                LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 4"
                LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 5"
                LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 6"
                LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 7"
               
                CONTROL ADD TEXTBOX,  hTab3, %ID_TAB3_TEXTBOX, "", 120, 6, 100, 12, %WS_CHILD OR %WS_TABSTOP OR %WS_VISIBLE OR %ES_READONLY
                CONTROL SET COLOR     hTab3, %ID_TAB3_TEXTBOX, %WHITE, %RED
                CONTROL SET FONT      hTab3, %ID_TAB3_TEXTBOX, hBoldFont
              #ENDIF
              
                CALL insert_Tab_Options(hDlg)
                                               
                ' Display the main dialog box
                DIALOG SHOW MODAL hDlg
              
                ' Destory the font used in this application. PowerBASIC
                ' will also destory the font when the application ends,
                ' so we did not need to do this.
                FONT END hBoldFont
              
              END FUNCTION
              
              ' Callback function used by all Tab dialogs
              CALLBACK FUNCTION TabProc
                LOCAL hDC  AS LONG
                LOCAL cTab AS LONG
                LOCAL i    AS LONG
                LOCAL s    AS STRING
              
                SELECT CASE AS LONG CB.MSG
              
                  CASE %WM_COMMAND
                    SELECT CASE AS LONG CB.CTL
              
                      CASE %ID_TAB1_BNSUBMIT
                      CASE %ID_TAB2_CBCHOICES
                      CASE %ID_TAB3_LBCHOICES
              
                    END SELECT
              
                END SELECT
              
              END FUNCTION
              Last edited by Jules Marchildon; 28 Jul 2009, 07:55 AM.
              Best regards
              Jules
              www.rpmarchildon.com

              Comment


              • #8
                Originally posted by Jules Marchildon View Post
                Werner,

                Are you creating individual dialogs for each tab?
                I can tell in your sub sub insert_Tab_Options(byval hDlg as dword)
                that you are not. You cannot attach controls to the tab itself.

                Basically, you create 4 dialogs and yo add your controls
                to each respective dialog, then show-hide them
                based on which tab is selected. See my code for example.

                Regards,
                Jules
                I could send you the file zipped by email, but it is too large to post it here.

                Also, I think with PB9 you can attach controls to a tab directly.
                TAB INSERT PAGE hDlg, %IDC_CP_OPTIONS, 1, 0, "Infrastruktur" TO hTab1

                CONTROL ADD CHECKBOX, hTab1, %IDC_CP_MAINS, "Strom", 2, 5, 105, 12
                Tab insert returns a handle which is then used with the controls one want to add.

                Comment


                • #9
                  Werner,

                  Check my comment in Post #7 above. Let me know if that solves your problem.

                  Regards,
                  Jules
                  Best regards
                  Jules
                  www.rpmarchildon.com

                  Comment


                  • #10
                    Here you go...

                    I used the tab example that came with PBWIN9 and installed your sub "insert_Tab_Options(hDlg)"

                    What made it work correctly was adding a callback to the statement...

                    TAB INSERT PAGE hDlg, %ID_TAB, 1, 0, "Infrastruktur" CALL TabProc TO hTab1
                    Thanks, but I think that is not the problem. I understand the PB9 manual that one can either use a new callback to handle the window messages or use a routine in the callback of the dialog:
                    SELECT CASE AS LONG CBMSG
                    CASE %WM_NOTIFY
                    IF cb.nmid = %IDC_CP_OPTIONS AND cb.nmcode = %TCN_SELCHANGE THEN
                    TAB GET SELECT cb.hndl, %IDC_CP_OPTIONS TO cTab
                    TAB SELECT cb.hndl, %IDC_CP_OPTIONS, cTab
                    FUNCTION = 1
                    EXIT FUNCTION
                    END IF

                    CASE %WM_INITDIALOG
                    CONTROL GET TEXT GetParent(CB.HNDL), %IDC_LOCATION TO cpname
                    CONTROL SET TEXT cb.hndl, %IDC_CPNAME, cpname

                    Comment


                    • #11
                      OK, I changed to your WM_NOTIFY instead and tested and works correctly.
                      So there must be something else at play here.

                      You can send your zipped file to jm + Xpress + @ + rogers + . + com
                      I will look at it a little later tonight, I have to zip out of here now...

                      thx.
                      Regards,
                      Jules


                      Code:
                      '==============================================================================
                      '
                      '  TABCONTROL.BAS example for PowerBASIC for Windows
                      '  Copyright (c) 2008 PowerBASIC, Inc.
                      '  All Rights Reserved.
                      '
                      '  Small DDT demonstration of a Tab control.
                      '
                      '==============================================================================
                      
                      #COMPILER PBWIN 9
                      #COMPILE EXE
                      #DIM ALL
                      
                      #INCLUDE "win32api.inc"
                      
                      ' Control equates
                      %ID_TAB            = 1000
                      %ID_TAB1_TBFIRST   = 1001
                      %ID_TAB1_LBFIRST   = 1002
                      %ID_TAB1_LBLAST    = 1003
                      %ID_TAB1_TBLAST    = 1004
                      %ID_TAB1_BNSUBMIT  = 1005
                      %ID_TAB2_CBCHOICES = 1006
                      %ID_TAB3_LBCHOICES = 1007
                      %ID_TAB3_TEXTBOX   = 1008
                      
                      
                      GLOBAL hDlg AS LONG
                      
                      
                      SUB insert_Tab_Options(BYVAL hDlg AS DWORD)
                      
                      LOCAL hTab1, hTab2, hTab3, hTab4 AS LONG
                      
                      'TAB 1
                          TAB INSERT PAGE hDlg, %ID_TAB, 1, 0, "Infrastruktur" TO hTab1 'CALL TabProc TO hTab1
                      
                          CONTROL ADD CHECKBOX, hTab1, 100, "Strom", 2, 5, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 102, "Wireless LAN", 2, 17, 105,12
                          CONTROL ADD CHECKBOX, hTab1, 103, "Internet Terminal (am " + "Platz)", 2, 29, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 104, "Ver- und Entsorgung WoMo", 2, 41, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 105, "Frischwasseranschluß",2, 53, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 106, "Ab- (Grau-) " + "Wasseranschluß", 2, 65, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 107, "SAT- / Kabelantenne", 2, 77, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 108, "Gasversorgungsanschluß", 2, 89, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 109, "Lebensmittel am Platz",140, 5, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 110, "Imbiß am Platz", 140, 17, 105, 12
                          CONTROL ADD CHECKBOX, hTab1, 111, "Restaurant am Platz",140, 29, 105, 12
                      
                      'TAB2
                          TAB INSERT PAGE hDlg, %ID_TAB, 2, 0, "Sanitär" TO hTab2  'CALL TabProc TO hTab2
                      
                          CONTROL ADD CHECKBOX, hTab2, 112, "Babywickelraum", 2, 5,120, 12
                          CONTROL ADD CHECKBOX, hTab2, 113, "Einzelwaschkabinen", 2,17, 120, 12
                      
                      'TAB3
                          TAB INSERT PAGE hDlg, %ID_TAB, 3, 0, "Freizeit" TO hTab3 'CALL TabProc TO hTab3
                         CONTROL ADD CHECKBOX, hTab3, 114,"Kinderspielplatz",2,5,120,12
                      
                      'TAB4
                          TAB INSERT PAGE hDlg, %ID_TAB, 4, 0, "Eigener Kommentar" TO hTab4  'CALL TabProc TO  hTab4
                         CONTROL ADD TEXTBOX,  hTab4, 115, "", 2, 5, 260, 96, _
                             %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR _
                             %WS_VSCROLL OR %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR _
                             %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR _
                             %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
                      
                      END SUB
                      
                      
                      '------------------------------------------------------------------------------
                      '   ** CallBacks **
                      '------------------------------------------------------------------------------
                      CALLBACK FUNCTION ShowDIALOG1Proc()
                      
                          SELECT CASE AS LONG CBMSG
                              CASE %WM_INITDIALOG
                                  ' Initialization handler
                      
                              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_NOTIFY
                                  LOCAL cTab AS DWORD
                                  IF CB.NMID = %ID_TAB AND CB.NMCODE = %TCN_SELCHANGE THEN
                                      TAB GET SELECT CB.HNDL, %ID_TAB TO cTab
                                      TAB SELECT CB.HNDL, %ID_TAB, cTab
                                      FUNCTION = 1
                                      EXIT FUNCTION
                                  END IF
                                  
                              CASE %WM_COMMAND
                                  '' Process control notifications
                                  'SELECT CASE AS LONG CBCTL
                                  '    CASE %IDC_SYSTABCONTROL32_1
                                  'END SELECT
                                  
                          END SELECT
                          
                      END FUNCTION
                      
                      FUNCTION PBMAIN () AS LONG
                        LOCAL hTab1     AS LONG
                        LOCAL hTab2     AS LONG
                        LOCAL hTab3     AS LONG
                        LOCAL hBoldFont AS LONG
                      
                        ' Create the font used by some controls in this example
                        FONT NEW "Arial", 10, 1 TO hBoldFont
                      
                        DIALOG NEW 0, "Tab Control Example", , , 300, 140, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR _
                          %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
                          %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                      
                        ' Add a Tab control to the main dialog box
                        CONTROL ADD TAB, hDlg, %ID_TAB, "", 1, 1, 298, 138
                      
                      #IF 0
                        ' Build the Tab 1 dialog and it's controls
                        TAB INSERT PAGE hDlg, %ID_TAB, 1, 0, "Tab 1", CALL TabProc TO hTab1
                        CONTROL ADD LABEL,   hTab1, %ID_TAB1_LBFIRST,  "First name", 2, 6, 100, 12
                        CONTROL SET COLOR    hTab1, %ID_TAB1_LBFIRST, %WHITE, -2
                        CONTROL SET FONT     hTab1, %ID_TAB1_LBFIRST, hBoldFont
                        CONTROL ADD TEXTBOX, hTab1, %ID_TAB1_TBFIRST, "", 60, 6, 100, 12
                      
                        CONTROL ADD LABEL,   hTab1, %ID_TAB1_LBLAST,  "Last name", 2, 20, 100, 12
                        CONTROL SET COLOR    hTab1, %ID_TAB1_LBLAST, %WHITE, -2
                        CONTROL SET FONT     hTab1, %ID_TAB1_LBLAST, hBoldFont
                        CONTROL ADD TEXTBOX, hTab1, %ID_TAB1_TBLAST, "", 60, 20, 100, 12
                      
                        CONTROL ADD BUTTON,  hTab1, %ID_TAB1_BNSUBMIT, "Submit", 235, 100, 50, 14
                        CONTROL SET FONT     hTab1, %ID_TAB1_BNSUBMIT, hBoldFont
                      
                        ' Build the Tab 2 dialog and it's controls
                        TAB INSERT PAGE hDlg, %ID_TAB, 2, 0, "Tab 2", CALL TabProc TO hTab2
                        CONTROL ADD COMBOBOX, hTab2, %ID_TAB2_CBCHOICES, , 2, 6, 100, 40, %CBS_DROPDOWNLIST OR %WS_TABSTOP OR %WS_CHILD
                        CONTROL SET COLOR     hTab2, %ID_TAB2_CBCHOICES, %BLACK, %GREEN
                        CONTROL SET FONT      hTab2, %ID_TAB2_CBCHOICES, hBoldFont
                        COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 1"
                        COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 2"
                        COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 3"
                        COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 4"
                        COMBOBOX ADD          hTab2, %ID_TAB2_CBCHOICES, "Choice 5"
                        COMBOBOX SELECT       hTab2, %ID_TAB2_CBCHOICES, 1
                      
                        ' Build the Tab 3 dialog and it's controls
                        TAB INSERT PAGE hDlg, %ID_TAB, 3, 0, "Tab 3", CALL TabProc TO hTab3
                        CONTROL ADD LISTBOX,  hTab3, %ID_TAB3_LBCHOICES, , 2, 6, 100, 60
                        CONTROL SET COLOR     hTab3, %ID_TAB3_LBCHOICES, %WHITE, %RED
                        CONTROL SET FONT      hTab3, %ID_TAB3_LBCHOICES, hBoldFont
                        LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 1"
                        LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 2"
                        LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 3"
                        LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 4"
                        LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 5"
                        LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 6"
                        LISTBOX ADD           hTab3, %ID_TAB3_LBCHOICES, "Item 7"
                      
                        CONTROL ADD TEXTBOX,  hTab3, %ID_TAB3_TEXTBOX, "", 120, 6, 100, 12, %WS_CHILD OR %WS_TABSTOP OR %WS_VISIBLE OR %ES_READONLY
                        CONTROL SET COLOR     hTab3, %ID_TAB3_TEXTBOX, %WHITE, %RED
                        CONTROL SET FONT      hTab3, %ID_TAB3_TEXTBOX, hBoldFont
                      #ENDIF
                      
                        CALL insert_Tab_Options(hDlg)
                      
                        ' Display the main dialog box
                        'DIALOG SHOW MODAL hDlg
                        LOCAL lRslt AS LONG
                        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                        
                        ' Destory the font used in this application. PowerBASIC
                        ' will also destory the font when the application ends,
                        ' so we did not need to do this.
                        FONT END hBoldFont
                        
                        FUNCTION = lRslt
                        
                      END FUNCTION
                      
                      #IF 0
                      ' Callback function used by all Tab dialogs
                      CALLBACK FUNCTION TabProc
                        LOCAL hDC  AS LONG
                        LOCAL cTab AS LONG
                        LOCAL i    AS LONG
                        LOCAL s    AS STRING
                      
                        SELECT CASE AS LONG CB.MSG
                      
                          CASE %WM_COMMAND
                            SELECT CASE AS LONG CB.CTL
                      
                              CASE %ID_TAB1_BNSUBMIT
                              CASE %ID_TAB2_CBCHOICES
                              CASE %ID_TAB3_LBCHOICES
                      
                            END SELECT
                      
                        END SELECT
                      
                      END FUNCTION
                      #ENDIF
                      Best regards
                      Jules
                      www.rpmarchildon.com

                      Comment


                      • #12
                        Sent the file to your mailbox, Thanks for your help.

                        rgds
                        Werner

                        Comment


                        • #13
                          Werner,

                          Got it.

                          Made a compiled version, you are getting standard notifications but not from the DDT TAB control engine,... this is why it's failing. The hTab1-hTab4 are valid handles and the tab notifications are received, when I checked using a callback, the DDT TAB engine is seeing nothing.

                          If using DDT statements to manipulate a DDT control, I can only suggest you use DDT to create the control.

                          Make this modification and give it a try. works for me know.

                          Code:
                          'CONTROL ADD "SysTabControl32", hDlg, %IDC_CP_OPTIONS, "", 210, 237, 270, _
                              '    117, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %TCS_SINGLELINE OR _
                              '    %TCS_RIGHTJUSTIFY, %WS_EX_LEFT OR %WS_EX_LTRREADING
                              
                              ' Add a Tab control to the main dialog box
                              CONTROL ADD TAB, hDlg, %IDC_CP_OPTIONS, "", 210, 237, 270, 117
                          Regards,
                          Jules
                          Best regards
                          Jules
                          www.rpmarchildon.com

                          Comment


                          • #14
                            Jules,

                            thanks for your help. I am rather surprised, because I thought I tried this
                            before and it did not work - now it does.

                            However, the program still hangs if one of the options buttons is clicked and I
                            have no idea why.

                            I used PBFORMS 1.51 to create the dialogs, so I thought PB9 would be compatible at least as long as there is no new PBFORMS version available.

                            Best regards
                            Last edited by Werner Bleckwendt; 29 Jul 2009, 04:26 AM.

                            Comment


                            • #15
                              Next surprise, the code:
                              SELECT CASE AS LONG CBMSG
                              CASE %WM_NOTIFY
                              IF cb.nmid = %IDC_CP_OPTIONS AND cb.nmcode = %TCN_SELCHANGE THEN
                              TAB GET SELECT cb.hndl, %IDC_CP_OPTIONS TO cTab
                              TAB SELECT cb.hndl, %IDC_CP_OPTIONS, cTab
                              FUNCTION = 1
                              EXIT FUNCTION
                              END IF
                              seems not to be neccessary. Obviously the DDT engine handles these messages, because you can select tabs even if above code is left out from the dialogs callback

                              Comment


                              • #16
                                Just an additional information: The order of the controls in the dialog function is critical:
                                If I put the control add tab statement at the end of the controls, i.e. after a control with an ID %IDC_UNUSED (these are in more than one dialog), the tab is not shown, if it is before such a control it works ok

                                Comment


                                • #17
                                  Originally posted by Werner Bleckwendt View Post
                                  Jules,

                                  thanks for your help. I am rather surprised, because I thought I tried this
                                  before and it did not work - now it does.

                                  However, the program still hangs if one of the options buttons is clicked and I
                                  have no idea why.

                                  I used PBFORMS 1.51 to create the dialogs, so I thought PB9 would be compatible at least as long as there is no new PBFORMS version available.

                                  Best regards
                                  I just checked, and yes, it hangs. I'll take a look to see what's up....
                                  Also, I'm sure the PBFORMS will get an update to reflect the new TAB features with the DDT CONTROL ADD TAB code, ...that was your "gotcha" here.

                                  Regards,
                                  Jules
                                  Best regards
                                  Jules
                                  www.rpmarchildon.com

                                  Comment


                                  • #18
                                    Originally posted by Werner Bleckwendt View Post
                                    Just an additional information: The order of the controls in the dialog function is critical:
                                    If I put the control add tab statement at the end of the controls, i.e. after a control with an ID %IDC_UNUSED (these are in more than one dialog), the tab is not shown, if it is before such a control it works ok
                                    That would make sense, the dialog needed for the tab has not been created, therefore no
                                    valid handle to assign the controls to. It's necessary to have the CONTROL TAB ADD first and a parent handle for the child controls.

                                    Regards,
                                    Jules
                                    Best regards
                                    Jules
                                    www.rpmarchildon.com

                                    Comment


                                    • #19
                                      Originally posted by Jules Marchildon View Post
                                      That would make sense, the dialog needed for the tab has not been created, therefore no
                                      valid handle to assign the controls to. It's necessary to have the CONTROL TAB ADD first and a parent handle for the child controls.

                                      Regards,
                                      Jules
                                      Sorry, you misunderstood. Only frame and label controls were in front of the tab:

                                      control add tab ...
                                      control add frame...
                                      control add label...

                                      works ok

                                      control add frame...
                                      control add label...
                                      control add tab..

                                      works not - give it a try -you just need to move the control add tab statement to the end of the function

                                      The tab does not show up if you choose the second order - that is why it did not work here, when I changed the code from the "custom control" to the DDT TAB style

                                      Comment


                                      • #20
                                        Next surprise, the code:
                                        Code:
                                        CASE %WM_NOTIFY
                                          IF cb.nmid = %IDC_CP_OPTIONS AND cb.nmcode = %TCN_SELCHANGE THEN
                                             TAB GET SELECT cb.hndl, %IDC_CP_OPTIONS TO cTab
                                             TAB SELECT cb.hndl, %IDC_CP_OPTIONS, cTab
                                              FUNCTION = 1
                                              EXIT FUNCTION
                                         END IF
                                        seems not to be neccessary. Obviously the DDT engine handles these messages, because you can select tabs even if above code is left out from the dialogs callback
                                        Whoa there. WM_NOTIFY/TCN_SELCHANGE is a notification.
                                        Notifies a tab control's parent window that the currently selected tab has changed. This message is sent in the form of a WM_NOTIFY message
                                        When you get this notification the user has already selected a new tab via mouse or keyboard action.

                                        You can take code action here if you want, but the selection has already changed.

                                        Almost all the "CB.MSG" and "CB.nmcode" messages are notification messages; only a limited number are "opportunities" (and if you do not take the opportunity, a default action is taken).

                                        In this case it didn't happen to you here for reasons explained below, but not understanding that these messages are "notifications" can cause your program to either hang (enter endless loop) or experience a stack fault here, because your code essentially does this:
                                        Code:
                                          Windows sends WM_NOTIFY/TCN_SELCHANGE telling me tab cTab was selected 
                                          Let's select tab cTab. This results in... 
                                          Windows sends WM_NOTIFY/TCN_SELCHANGE telling me tab cTab was selected 
                                          Let's select tab cTab. This results in.... 
                                          Windows sends WM_NOTIFY/TCN_SELCHANGE telling me tab cTab was selected 
                                          Let's select tab cTab. This results in ....
                                          Windows sends WM_NOTIFY/TCN_SELCHANGE telling me tab cTab was selected 
                                          Let's select tab cTab. This results in ....
                                         ...
                                        See a pattern here?

                                        However, you are lucky. We can only guess (but it's a good guess) that the DDT engine implements TAB SELECT using the TCM_SETCURSEL message... which does NOT result in a WM_NOTIFY/TCN_SELCHANGE notification. (Details in your Windows SDK reference).

                                        MCM
                                        Last edited by Michael Mattias; 29 Jul 2009, 07:37 AM.
                                        Michael Mattias
                                        Tal Systems (retired)
                                        Port Washington WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X