Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Owner Drawn Tab Control with bkgd color & icons

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

  • Owner Drawn Tab Control with bkgd color & icons

    [CODE]
    #pbforms created
    '************************************************************************
    '* odtabcontrol *
    '* by bernard ertl *
    '* july 21, 2002 *
    '* *
    '* credits: *
    '* this code builds upon the tab control sample for pbforms. *
    '* *
    '* i adapted code from jules marchildon & peter lameijn found here: *
    '* http://www.powerbasic.com/support/pb...ead.php?t=3773 *
    '* *
    '* rotatetext function courtesy of borje hagsten. *
    '* *
    '* description: *
    '* this code shows how to use tab controls with custom background color *
    '* and icons. *
    '* *
    '* note: if you use a vertical style tab, you should draw your own icons*
    '* already rotated 90 or 270 degrees. *
    '* *
    '* tested ok on win95 & win98. use at your own risk. *
    '* *
    '* restrictions: *
    '* - code assumes tabs and not buttons *
    '* - code requires %tcs_multiline or %tcs_raggedright in order to set *
    '* the proper padding to allow for icons. i have been unable to get*
    '* tabctrl_setpadding to work with other style combinations. *
    '* - code requires dialog size large enough to maintain a singleline *
    '* tab control. this code does not draw multiple tab lines *
    '* correctly. *
    '************************************************************************

    #compile exe
    #dim all

    '--------------------------------------------------------------------------------
    ' ** includes **
    '--------------------------------------------------------------------------------
    #pbforms begin includes
    #if not %def(%winapi)
    #include "win32api.inc"
    #endif
    #if not %def(%commctrl_inc)
    #include "commctrl.inc"
    #endif
    #include "pbforms.inc"
    #pbforms end includes
    '--------------------------------------------------------------------------------



    '--------------------------------------------------------------------------------
    ' ** constants **
    '--------------------------------------------------------------------------------
    #pbforms begin constants
    %idd_dialog1 = 101
    %idd_dialog2 = 102
    %idd_dialog3 = 103
    %idd_dialog4 = 104
    %idd_dialog5 = 105
    %idd_dialog6 = 106
    %idc_systabcontrol32_1 = 1001
    %idc_textbox1 = 1011
    %idc_textbox2 = 1012
    %idc_textbox3 = 1013
    %idc_textbox4 = 1014
    %idc_textbox5 = 1015
    %idc_label1 = 1016
    %idc_tab_overlay_label = 1016
    #pbforms end constants

    'owner drawn tab control constants
    %odtc_icon_width = 16
    %odtc_margin_spacing = 3 'matches win98 default tab height
    %odtc_text_offset_from_icon = 4
    %odtc_max_string = 40 'number of bytes for asciiz tab strings

    %odtc_tab_cntrl_horz_offset = 5 '#pixels between dialog border and tab border
    %odtc_tab_cntrl_vert_offset = 5 '#pixels between dialog border and tab border
    '--------------------------------------------------------------------------------



    '--------------------------------------------------------------------------------
    ' ** types **
    '--------------------------------------------------------------------------------
    type tcimagetype
    ztext as asciiz * %odtc_max_string
    hicon as dword
    end type

    type colorset
    bkface as long 'color for raised button face
    bkfacesunken as long 'color for depressed button face
    bkhighlight as long 'color for highlighted items
    bkhighlightsunken as long 'color for depressed face on higlighted items
    txdefault as long 'default color for text
    txgrayed as long 'color for grayed text
    txhighlighted as long 'color for highlighted text
    end type
    '--------------------------------------------------------------------------------



    '--------------------------------------------------------------------------------
    ' ** globals **
    '--------------------------------------------------------------------------------
    global getcolorfor() as colorset
    global currentdisplaymode as long
    global gpage() as dword
    global tabheight as long
    global tabborderthickness as long
    global tcimages() as tcimagetype 'maintain image info for each tab
    '--------------------------------------------------------------------------------



    '--------------------------------------------------------------------------------
    ' ** declarations **
    '--------------------------------------------------------------------------------
    declare callback function showdialog1proc()
    declare callback function showdialog2proc()
    declare callback function showdialog3proc()
    declare callback function showdialog4proc()
    declare callback function showdialog5proc()
    declare callback function showdialog6proc()
    declare function sampletabctrl(byval hdlg as dword, byval lid as long, byval _
    lcount as long) as long
    declare function showdialog1(byval hparent as dword) as long
    declare function showdialog2(byval hparent as dword) as long
    declare function showdialog3(byval hparent as dword) as long
    declare function showdialog4(byval hparent as dword) as long
    declare function showdialog5(byval hparent as dword) as long
    declare function showdialog6(byval hparent as dword) as long
    #pbforms declarations
    '--------------------------------------------------------------------------------


    '--------------------------------------------------------------------------------
    ' ** support procs **
    '--------------------------------------------------------------------------------
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' simple font rotation in pb by borje hagsten, july 2000
    ' public domain
    ' http://www.powerbasic.com/support/pb...ead.php?t=2428
    '
    ' modified for odtabcontrol by bernard ertl
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    sub rotatetext(byval hwnd&, byval degr%, byval txt$, byval x&, byval y&, byval txcolor&)

    local lfont as logfont, rc as rect
    local hdc as long, hfont as long, newfont as long
    local ncm as nonclientmetrics

    if degr% = 0 then degr% = 360

    ncm.cbsize = len( nonclientmetrics)
    systemparametersinfo %spi_getnonclientmetrics, sizeof( ncm), byval varptr(ncm), 0
    lfont = ncm.lfmenufont

    lfont.lfescapement = degr% * 10 '<- set angle
    lfont.lforientation = degr% * 10
    lfont.lfoutprecision = %out_tt_precis
    lfont.lfclipprecision =%clip_default_precis
    lfont.lffacename = "times new roman" '<- font name
    'note: ms sans serif does not rotate...

    'create font and assign handle to a variable
    hfont = createfontindirect( byval varptr(lfont))

    hdc = getdc(hwnd&)
    newfont = selectobject(hdc, hfont)

    setbkmode hdc, %transparent
    settextcolor hdc, txcolor&

    textout hdc, x&, y&, byval strptr(txt$), len(txt$) '<- print text

    deleteobject selectobject(hdc, newfont)
    releasedc hwnd&, hdc

    end sub
    '--------------------------------------------------------------------------------



    '--------------------------------------------------------------------------------
    function pbmain()

    local dm as devmode
    dim getcolorfor( 1)

    'set colors for 256 color mode
    getcolorfor(0).bkface = rgb( 128, 128, 0)
    getcolorfor(0).bkfacesunken = rgb( 128, 128, 0) '%yellow does not make good 3d effect
    getcolorfor(0).bkhighlight = rgb( 128, 0, 0)
    getcolorfor(0).bkhighlightsunken = rgb( 128, 0, 0) '%red does not make good 3d effect
    getcolorfor(0).txdefault = getsyscolor( %color_menutext)
    getcolorfor(0).txgrayed = &h00505050 'dark gray
    getcolorfor(0).txhighlighted = %yellow

    'set colors for 16 bit/high color or better
    getcolorfor(1).bkface = rgb( 200, 200, 152)
    getcolorfor(1).bkfacesunken = rgb( 220, 220, 188)
    getcolorfor(1).bkhighlight = rgb( 173, 173, 101)
    getcolorfor(1).bkhighlightsunken = rgb( 187, 187, 128)
    getcolorfor(1).txdefault = getsyscolor( %color_menutext)
    getcolorfor(1).txgrayed = getsyscolor( %color_graytext)
    getcolorfor(1).txhighlighted = %blue

    dm.dmsize = len( devmode)
    enumdisplaysettings byval 0, %enum_current_settings, dm
    currentdisplaymode = iif&( dm.dmbitsperpel > 8, 1, 0)

    pbformsinitcomctls (%icc_win95_classes or %icc_date_classes or %icc_internet_classes)

    showdialog1 %hwnd_desktop
    end function
    '--------------------------------------------------------------------------------



    '--------------------------------------------------------------------------------
    ' ** callbacks **
    '--------------------------------------------------------------------------------
    callback function showdialog1proc()

    register i as long, j as long

    static htcbrush as long ' maintain a custom background color brush for tab control
    static tcdlgborder as long ' remember the 'coordinate' of the right edge of the parent dialog
    static tctabborder as long ' remember the 'coordinate' of the right edge of the last tab

    local htab as long

    local ldisptr as drawitemstruct ptr
    local mminfo as minmaxinfo ptr
    local pnmhdr as nmhdr ptr
    local result as long
    local rc as rect
    local rc2 as rect
    local pt as pointapi

    select case cbmsg
    case %wm_initdialog
    'initialize custom brush for painting tab control
    htcbrush = createsolidbrush( getcolorfor( currentdisplaymode).bkface)

    'get current dialog size
    getclientrect cbhndl, rc

    'adjust rect for tab control
    rc.ntop = %odtc_tab_cntrl_vert_offset
    rc.nleft = %odtc_tab_cntrl_horz_offset
    rc.nright = rc.nright - %odtc_tab_cntrl_horz_offset * 2
    rc.nbottom = rc.nbottom - %odtc_tab_cntrl_vert_offset * 2
    htab = getdlgitem( cbhndl, %idc_systabcontrol32_1)
    movewindow htab, rc.nleft, rc.ntop, rc.nright, rc.nbottom, 0

    'add padding to account for icon width
    tabctrl_setpadding htab, %odtc_icon_width , %odtc_margin_spacing

    'set global dimensioning variables
    tabctrl_getitemrect htab, 1, rc2
    'assume x & y borders are same thickness....
    tabborderthickness = getsystemmetrics( %sm_cyedge)

    'get styles for tab control
    j = getwindowlong( htab, %gwl_style)
    'adjust position & sizes of child dialogs
    if (j and %tcs_right) and (j and %tcs_vertical) then
    'tabs are vertical and to the right side
    tabheight = rc2.nright - rc2.nleft
    'adjust upper left corner and height & width for child dialogs
    rc.ntop = rc.ntop + tabborderthickness
    rc.nleft = rc.nleft + tabborderthickness
    rc.nright = rc.nright - tabheight - tabborderthickness * 3 + 1
    rc.nbottom = rc.nbottom - tabborderthickness * 2
    'set dlgborder for label
    tcdlgborder = rc.nbottom + %odtc_tab_cntrl_vert_offset
    elseif (j and %tcs_vertical) then
    'tabs are vertical and to the left side
    tabheight = rc2.nright - rc2.nleft
    'adjust upper left corner and height & width for child dialogs
    rc.ntop = rc.ntop + tabborderthickness
    rc.nleft = rc.nleft + tabheight + tabborderthickness * 2
    rc.nright = rc.nright - tabheight - tabborderthickness * 3
    rc.nbottom = rc.nbottom - tabborderthickness * 2
    'set dlgborder for label
    tcdlgborder = rc.nbottom + %odtc_tab_cntrl_vert_offset
    elseif (j and %tcs_bottom) then
    'tabs are horizontal and at the bottom
    tabheight = rc2.nbottom - rc2.ntop
    'adjust upper left corner and height & width for child dialogs
    rc.ntop = rc.ntop + tabborderthickness
    rc.nleft = rc.nleft + tabborderthickness
    rc.nright = rc.nright - tabborderthickness * 2
    rc.nbottom = rc.nbottom - tabheight - tabborderthickness * 3 'three borders : 2 for frame and 1 between tab & window
    'set dlgborder for label
    tcdlgborder = rc.nright + %odtc_tab_cntrl_horz_offset
    else
    'tabs are horizontal and at the top
    tabheight = rc2.nbottom - rc2.ntop
    'adjust upper left corner and height & width for child dialogs
    rc.ntop = rc.ntop + tabheight + tabborderthickness * 2
    rc.nleft = rc.nleft + tabborderthickness
    rc.nright = rc.nright - tabborderthickness * 2
    rc.nbottom = rc.nbottom - tabheight - tabborderthickness * 3
    'set dlgborder for label
    tcdlgborder = rc.nright + %odtc_tab_cntrl_horz_offset
    end if
    for i = 0 to ubound( gpage())
    movewindow gpage( i), rc.nleft, rc.ntop, rc.nright, rc.nbottom, 0
    next

    case %wm_getminmaxinfo
    mminfo = cblparam
    if (getwindowlong( getdlgitem( cbhndl, %idc_systabcontrol32_1), %gwl_style) and %tcs_vertical) then
    'set the minimum dialog height to maintain single line tab
    @mminfo.ptmintracksize.y = tctabborder + %odtc_tab_cntrl_vert_offset + getsystemmetrics( %sm_cysizeframe) * 2 + getsystemmetrics( %sm_cycaption) + tabborderthickness + 1
    else
    'set the minimum dialog width to maintain single line tab
    @mminfo.ptmintracksize.x = tctabborder + %odtc_tab_cntrl_horz_offset + getsystemmetrics( %sm_cxsizeframe) * 2 + tabborderthickness + 1
    end if

    case %wm_drawitem
    if cbwparam = %idc_systabcontrol32_1 then
    ldisptr = cblparam

    tabctrl_getitemrect @ldisptr.hwnditem, @ldisptr.itemid, rc
    rc2 = rc

    'get styles for tab control
    j = getwindowlong( getdlgitem( cbhndl, %idc_systabcontrol32_1), %gwl_style)
    if (j and %tcs_right) and (j and %tcs_vertical) then
    'tabs are vertical and to the right side
    if isfalse (@ldisptr.itemstate and %ods_selected) then rc.nright = rc.nright + tabborderthickness
    select case as long @ldisptr.itemid
    case 0
    if (@ldisptr.itemstate and %ods_selected) then
    rc.nleft = rc.nleft + 1
    else
    rc.ntop = rc.ntop - tabborderthickness
    end if
    case ubound( gpage)
    if tctabborder = 0 then
    'initial drawing
    tctabborder = rc.nbottom + tabborderthickness * 2 + 1
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), rc.nleft + %odtc_tab_cntrl_horz_offset, tctabborder, tabheight + tabborderthickness, tcdlgborder, 0
    else
    if (@ldisptr.itemstate and %ods_selected) then
    tctabborder = rc.nbottom + tabborderthickness * 3 + 1
    else
    tctabborder = rc.nbottom + tabborderthickness * 2 + 1
    rc.nbottom = rc.nbottom + tabborderthickness
    end if
    end if
    end select
    if (@ldisptr.itemstate and %ods_selected) then
    rc.nleft = rc.nleft - tabborderthickness * 4
    rc2.nright = rc2.nright + tabborderthickness
    rc2.nleft = rc2.nleft + tabborderthickness
    end if

    fillrect @ldisptr.hdc, rc, htcbrush
    setbkmode @ldisptr.hdc, %transparent
    if (j and %tcs_hottrack) then
    getcursorpos pt
    screentoclient getdlgitem( cbhndl, %idc_systabcontrol32_1), pt
    if ptinrect( rc, pt.x, pt.y) then
    i = getcolorfor( currentdisplaymode).txhighlighted
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if

    rotatetext @ldisptr.hwnditem, 270, tcimages( @ldisptr.itemid).ztext, rc2.nright - %odtc_margin_spacing - tabborderthickness, rc2.ntop + tabborderthickness + %odtc_icon_width + %odtc_text_offset_from_icon + %odtc_margin_spacing, i
    'draw icon if any...
    if tcimages( @ldisptr.itemid).hicon then drawiconex @ldisptr.hdc, rc2.nleft - tabborderthickness + %odtc_margin_spacing, rc2.ntop + %odtc_margin_spacing + tabborderthickness, _
    tcimages( @ldisptr.itemid).hicon, 16, 16, 0, byval 0, %di_normal
    elseif (j and %tcs_vertical) then
    'tabs are vertical and to the left side
    if isfalse (@ldisptr.itemstate and %ods_selected) then rc.nleft = rc.nleft - tabborderthickness
    select case as long @ldisptr.itemid
    case 0
    if (@ldisptr.itemstate and %ods_selected) then
    rc.nright = rc.nright - 1
    else
    rc.ntop = rc.ntop - tabborderthickness
    end if
    case ubound( gpage)
    if tctabborder = 0 then
    'initial drawing
    tctabborder = rc.nbottom + tabborderthickness * 2 + 1
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), rc.nleft + %odtc_tab_cntrl_horz_offset, tctabborder, tabheight + tabborderthickness, tcdlgborder, 0
    else
    if (@ldisptr.itemstate and %ods_selected) then
    tctabborder = rc.nbottom + tabborderthickness * 3 + 1
    else
    tctabborder = rc.nbottom + tabborderthickness * 2 + 1
    rc.nbottom = rc.nbottom + tabborderthickness
    end if
    end if
    end select
    if (@ldisptr.itemstate and %ods_selected) then
    rc.nright = rc.nright + tabborderthickness * 2
    rc2.nleft = rc2.nleft - tabborderthickness
    end if

    fillrect @ldisptr.hdc, rc, htcbrush
    setbkmode @ldisptr.hdc, %transparent
    if (j and %tcs_hottrack) then
    getcursorpos pt
    screentoclient getdlgitem( cbhndl, %idc_systabcontrol32_1), pt
    if ptinrect( rc, pt.x, pt.y) then
    i = getcolorfor( currentdisplaymode).txhighlighted
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if

    rotatetext @ldisptr.hwnditem, 90, tcimages( @ldisptr.itemid).ztext, rc2.nleft + %odtc_margin_spacing, rc2.nbottom - tabborderthickness - %odtc_icon_width - %odtc_text_offset_from_icon - %odtc_margin_spacing, i

    'draw icon if any...
    if tcimages( @ldisptr.itemid).hicon then drawiconex @ldisptr.hdc, rc2.nleft + %odtc_margin_spacing, rc2.nbottom - tabborderthickness - %odtc_icon_width - %odtc_margin_spacing, _
    tcimages( @ldisptr.itemid).hicon, 16, 16, 0, byval 0, %di_normal
    elseif (j and %tcs_bottom) then
    'tabs are horizontal and at the bottom
    if isfalse (@ldisptr.itemstate and %ods_selected) then rc.nbottom = rc.nbottom + tabborderthickness
    select case as long @ldisptr.itemid
    case 0
    'special case for first tab...
    if (@ldisptr.itemstate and %ods_selected) then
    'if selected, need to draw one less pixel at top
    rc.ntop = rc.ntop + 1
    else
    'if not selected, need to paint background where border is not drawn
    rc.nleft = rc.nleft - tabborderthickness
    end if
    case ubound( gpage)
    'special case for last tab...
    if tctabborder = 0 then
    'initial drawing, set tctabborder and set label maintain background color
    tctabborder = rc.nright + tabborderthickness * 2 + 1
    'assume that last tab is not the default when tab control is initialized...
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), tctabborder, rc.ntop + %odtc_tab_cntrl_vert_offset, tcdlgborder, tabheight + tabborderthickness , 0
    else
    'adjust tctabborder depending upon selection state
    if (@ldisptr.itemstate and %ods_selected) then
    tctabborder = rc.nright + tabborderthickness * 3 + 1
    else
    tctabborder = rc.nright + tabborderthickness * 2 + 1
    rc.nright = rc.nright + tabborderthickness
    end if
    end if
    end select
    if (@ldisptr.itemstate and %ods_selected) then
    rc.ntop = rc.ntop - tabborderthickness * 2
    rc2.ntop = rc2.ntop + tabborderthickness
    end if
    if (j and %tcs_hottrack) then
    getcursorpos pt
    screentoclient getdlgitem( cbhndl, %idc_systabcontrol32_1), pt
    if ptinrect( rc, pt.x, pt.y) then
    i = getcolorfor( currentdisplaymode).txhighlighted
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if

    fillrect @ldisptr.hdc, rc, htcbrush
    setbkmode @ldisptr.hdc, %transparent
    settextcolor @ldisptr.hdc, i

    textout @ldisptr.hdc, rc2.nleft + tabborderthickness + %odtc_icon_width + %odtc_text_offset_from_icon + %odtc_margin_spacing, _
    rc2.ntop + %odtc_margin_spacing, tcimages( @ldisptr.itemid).ztext, len( tcimages( @ldisptr.itemid).ztext)
    'draw icon if any...
    if tcimages( @ldisptr.itemid).hicon then drawiconex @ldisptr.hdc, rc2.nleft + tabborderthickness + %odtc_margin_spacing, rc2.ntop + %odtc_margin_spacing, _
    tcimages( @ldisptr.itemid).hicon, 16, 16, 0, byval 0, %di_normal
    else
    'tabs are horizontal and at the top
    if isfalse (@ldisptr.itemstate and %ods_selected) then rc.ntop = rc.ntop - tabborderthickness
    select case as long @ldisptr.itemid
    case 0
    'special case for first tab...
    if (@ldisptr.itemstate and %ods_selected) then
    'if selected, need to draw one less pixel at bottom
    rc.nbottom = rc.nbottom - 1
    else
    'if not selected, need to paint background where border is not drawn
    rc.nleft = rc.nleft - tabborderthickness
    end if
    case ubound( gpage)
    'special case for last tab...
    if tctabborder = 0 then
    'initial drawing, set tctabborder and set label maintain background color
    tctabborder = rc.nright + %odtc_tab_cntrl_horz_offset
    'assume that last tab is not the default when tab control is initialized...
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), tctabborder, rc.ntop + %odtc_tab_cntrl_vert_offset, tcdlgborder, tabheight + tabborderthickness , 0
    else
    'adjust tctabborder depending upon selection state
    if (@ldisptr.itemstate and %ods_selected) then
    tctabborder = rc.nright + tabborderthickness * 3 + 1
    else
    tctabborder = rc.nright + tabborderthickness * 2 + 1
    rc.nright = rc.nright + tabborderthickness
    end if
    end if
    end select
    if (@ldisptr.itemstate and %ods_selected) then
    rc.nbottom = rc.nbottom + tabborderthickness * 2
    rc2.ntop = rc2.ntop - tabborderthickness
    end if
    if (j and %tcs_hottrack) then
    getcursorpos pt
    screentoclient getdlgitem( cbhndl, %idc_systabcontrol32_1), pt
    if ptinrect( rc, pt.x, pt.y) then
    i = getcolorfor( currentdisplaymode).txhighlighted
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if
    else
    i = getcolorfor( currentdisplaymode).txdefault
    end if

    fillrect @ldisptr.hdc, rc, htcbrush
    setbkmode @ldisptr.hdc, %transparent
    settextcolor @ldisptr.hdc, i

    textout @ldisptr.hdc, rc2.nleft + tabborderthickness + %odtc_icon_width + %odtc_text_offset_from_icon + %odtc_margin_spacing, _
    rc2.ntop + %odtc_margin_spacing, tcimages( @ldisptr.itemid).ztext, len( tcimages( @ldisptr.itemid).ztext)
    'draw icon if any...
    if tcimages( @ldisptr.itemid).hicon then drawiconex @ldisptr.hdc, rc2.nleft + tabborderthickness + %odtc_margin_spacing, rc2.ntop + %odtc_margin_spacing, _
    tcimages( @ldisptr.itemid).hicon, 16, 16, 0, byval 0, %di_normal
    end if
    end if

    case %wm_size
    'get current dialog size
    getclientrect cbhndl, rc

    'adjust rect for tab control
    rc.ntop = %odtc_tab_cntrl_vert_offset
    rc.nleft = %odtc_tab_cntrl_horz_offset
    rc.nright = rc.nright - rc.nleft - %odtc_tab_cntrl_horz_offset
    rc.nbottom = rc.nbottom - rc.ntop - %odtc_tab_cntrl_vert_offset
    movewindow getdlgitem( cbhndl, %idc_systabcontrol32_1), rc.nleft, rc.ntop, rc.nright, rc.nbottom, 0

    'get styles for tab control
    j = getwindowlong( getdlgitem( cbhndl, %idc_systabcontrol32_1), %gwl_style)

    if (j and %tcs_right) and (j and %tcs_vertical) then
    'tabs are vertical and to the right side

    'adjust label to the bottom of last tab
    tcdlgborder = rc.nbottom + %odtc_tab_cntrl_vert_offset
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), rc.nright - tabheight - tabborderthickness + %odtc_tab_cntrl_vert_offset, tctabborder, rc.nright, tcdlgborder, 0

    'adjust rect for child dialogs
    rc.ntop = rc.ntop + tabborderthickness
    rc.nleft = rc.nleft + tabborderthickness
    rc.nright = rc.nright - tabheight - tabborderthickness * 3 + 1
    rc.nbottom = rc.nbottom - tabborderthickness * 2
    elseif (j and %tcs_vertical) then
    'tabs are vertical and to the left side

    'adjust label to the bottom of last tab
    tcdlgborder = rc.nbottom + %odtc_tab_cntrl_vert_offset
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), rc.nleft, tctabborder, tabheight + tabborderthickness, tcdlgborder, 0

    'adjust rect for child dialogs
    rc.ntop = rc.ntop + tabborderthickness
    rc.nleft = rc.nleft + tabheight + tabborderthickness * 2
    rc.nright = rc.nright - tabheight - tabborderthickness * 3
    rc.nbottom = rc.nbottom - tabborderthickness * 2
    elseif (j and %tcs_bottom) then
    'tabs are horizontal and at the bottom

    'adjust label to the right of last tab
    tcdlgborder = rc.nright + %odtc_tab_cntrl_horz_offset
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), tctabborder, rc.nbottom - tabheight - tabborderthickness + %odtc_tab_cntrl_vert_offset, tcdlgborder, tabheight + tabborderthickness, 0

    'adjust rect for child dialogs
    rc.ntop = rc.ntop + tabborderthickness
    rc.nleft = rc.nleft + tabborderthickness
    rc.nright = rc.nright - tabborderthickness * 2
    rc.nbottom = rc.nbottom - tabheight - tabborderthickness * 3 'three borders : 2 for frame and 1 between tab & window
    else
    'tabs are horizontal and at the top

    'adjust label to the right of last tab
    tcdlgborder = rc.nright + %odtc_tab_cntrl_horz_offset
    movewindow getdlgitem( cbhndl, %idc_tab_overlay_label), tctabborder, rc.ntop, tcdlgborder, tabheight + tabborderthickness, 0

    'adjust rect for child dialogs
    rc.ntop = rc.ntop + tabheight + tabborderthickness * 2
    rc.nleft = rc.nleft + tabborderthickness
    rc.nright = rc.nright - tabborderthickness * 2
    rc.nbottom = rc.nbottom - tabheight - tabborderthickness * 3
    end if
    for i = 0 to ubound( gpage())
    movewindow gpage( i), rc.nleft, rc.ntop, rc.nright, rc.nbottom, 0
    next
    invalidaterect cbhndl, byval 0, 1

    case %wm_notify
    pnmhdr = cblparam

    select case @pnmhdr.idfrom
    case %idc_systabcontrol32_1
    ' get the current tab page number (zero based)
    control send cbhndl, %idc_systabcontrol32_1, %tcm_getcursel, 0, 0 to result

    select case @pnmhdr.code
    case %tcn_selchanging
    dialog show state gpage(result), %sw_hide
    case %tcn_selchange
    dialog show state gpage(result), %sw_show
    end select
    end select

    case %wm_displaychange
    j = iif&( cbwparam > 8, 1, 0)
    if j <&g
    Bernard Ertl
    InterPlan Systems

  • #2
    Previous post got mangled during migration to the vBulletin forum, so I'm re-posting per request:
    Code:
    #PBFORMS Created
    '************************************************************************
    '* ODTabControl                                                         *
    '*     by Bernard Ertl                                                  *
    '*     July 21, 2002                                                    *
    '*                                                                      *
    '* CREDITS:                                                             *
    '* This code builds upon the Tab Control sample for PBForms.            *
    '*                                                                      *
    '* I adapted code from Jules Marchildon & Peter Lameijn found here:     *
    '* http://www.powerbasic.com/support/forums/Forum4/HTML/003846.html     *
    '*                                                                      *
    '* RotateText function courtesy of Borje Hagsten.                       *
    '*                                                                      *
    '* DESCRIPTION:                                                         *
    '* This code shows how to use tab controls with custom background color *
    '* and icons.                                                           *
    '*                                                                      *
    '* Note: If you use a vertical style tab, you should draw your own icons*
    '*       already rotated 90 or 270 degrees.                             *
    '*                                                                      *
    '* Tested OK on Win95 & Win98.  Use at your own risk.                   *
    '*                                                                      *
    '* RESTRICTIONS:                                                        *
    '*   - Code assumes tabs and not buttons                                *
    '*   - Code requires %TCS_MULTILINE OR %TCS_RAGGEDRIGHT in order to set *
    '*     the proper padding to allow for icons.  I have been unable to get*
    '*     TabCtrl_SetPadding to work with other style combinations.        *
    '*   - Code requires dialog size large enough to maintain a singleline  *
    '*     tab control.  This code does NOT draw multiple tab lines         *
    '*     correctly.                                                       *
    '************************************************************************
    
    #COMPILE EXE
    #DIM ALL
    
    '--------------------------------------------------------------------------------
    '   ** Includes **
    '--------------------------------------------------------------------------------
    #PBFORMS Begin Includes
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #IF NOT %DEF(%COMMCTRL_INC)
        #INCLUDE "COMMCTRL.INC"
    #ENDIF
    #INCLUDE "PBForms.INC"
    #PBFORMS End Includes
    '--------------------------------------------------------------------------------
    
    
    
    '--------------------------------------------------------------------------------
    '   ** Constants **
    '--------------------------------------------------------------------------------
    #PBFORMS Begin Constants
    %IDD_DIALOG1            = 101
    %IDD_DIALOG2            = 102
    %IDD_DIALOG3            = 103
    %IDD_DIALOG4            = 104
    %IDD_DIALOG5            = 105
    %IDD_DIALOG6            = 106
    %IDC_SYSTABCONTROL32_1  = 1001
    %IDC_TEXTBOX1           = 1011
    %IDC_TEXTBOX2           = 1012
    %IDC_TEXTBOX3           = 1013
    %IDC_TEXTBOX4           = 1014
    %IDC_TEXTBOX5           = 1015
    %IDC_LABEL1             = 1016
    %IDC_TAB_OVERLAY_LABEL  = 1016
    #PBFORMS End Constants
    
    'Owner Drawn Tab Control Constants
    %ODTC_ICON_WIDTH            = 16
    %ODTC_MARGIN_SPACING        = 3    'Matches Win98 default tab height
    %ODTC_TEXT_OFFSET_FROM_ICON = 4
    %ODTC_MAX_STRING            = 40   'Number of bytes for ASCIIZ tab strings
    
    %ODTC_TAB_CNTRL_HORZ_OFFSET  = 5   '#pixels between dialog border and tab border
    %ODTC_TAB_CNTRL_VERT_OFFSET  = 5   '#pixels between dialog border and tab border
    '--------------------------------------------------------------------------------
    
    
    
    '--------------------------------------------------------------------------------
    '   ** Types **
    '--------------------------------------------------------------------------------
    TYPE TCImageType
       zText         AS ASCIIZ * %ODTC_MAX_STRING
       hIcon         AS DWORD
    END TYPE
    
    TYPE ColorSet
       BkFace            AS LONG  'Color for raised button face
       BkFaceSunken      AS LONG  'Color for depressed button face
       BkHighlight       AS LONG  'Color for highlighted items
       BkHighlightSunken AS LONG  'Color for depressed face on higlighted items
       TxDefault         AS LONG  'Default color for text
       TxGrayed          AS LONG  'Color for grayed text
       TxHighlighted     AS LONG  'Color for highlighted text
    END TYPE
    '--------------------------------------------------------------------------------
    
    
    
    '--------------------------------------------------------------------------------
    '   ** Globals **
    '--------------------------------------------------------------------------------
    GLOBAL GetColorFor()      AS ColorSet
    GLOBAL CurrentDisplayMode AS LONG
    GLOBAL gPage()            AS DWORD
    GLOBAL TabHeight          AS LONG
    GLOBAL TabBorderThickness AS LONG
    GLOBAL TCImages()         AS TCImageType  'Maintain image info for each tab
    '--------------------------------------------------------------------------------
    
    
    
    '--------------------------------------------------------------------------------
    '   ** Declarations **
    '--------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG2Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG3Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG4Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG5Proc()
    DECLARE CALLBACK FUNCTION ShowDIALOG6Proc()
    DECLARE FUNCTION SampleTabCtrl(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL _
        lCount AS LONG) AS LONG
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG3(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG4(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG5(BYVAL hParent AS DWORD) AS LONG
    DECLARE FUNCTION ShowDIALOG6(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS Declarations
    '--------------------------------------------------------------------------------
    
    
    '--------------------------------------------------------------------------------
    '   ** Support Procs **
    '--------------------------------------------------------------------------------
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Simple Font rotation in PB by Borje Hagsten, July 2000
    ' Public Domain
    ' http://www.powerbasic.com/support/forums/Forum4/HTML/002447.html
    '
    ' Modified for ODTabControl by Bernard Ertl
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    SUB RotateText(BYVAL hWnd&, BYVAL degr%, BYVAL Txt$, BYVAL x&, BYVAL y&, BYVAL TxColor&)
    
      LOCAL lFont AS LOGFONT, rc AS RECT
      LOCAL hDc   AS LONG, hfont AS LONG, newfont AS LONG
      LOCAL ncm   AS NONCLIENTMETRICS
    
      IF degr% = 0 THEN degr% = 360
    
      ncm.cbSize = LEN( NONCLIENTMETRICS)
      SystemParametersInfo %SPI_GETNONCLIENTMETRICS, SIZEOF( ncm), BYVAL VARPTR(ncm), 0
      lFont = ncm.lfMenuFont
    
      lFont.lfescapement  = degr% * 10                         '<- Set Angle
      lFont.lforientation = degr% * 10
      lFont.lfOutPrecision = %OUT_TT_PRECIS
      lFont.lfClipPrecision =%CLIP_DEFAULT_PRECIS
      lFont.lfFaceName = "Times New Roman"                     '<- Font Name
      'NOTE: MS Sans Serif does not rotate...
    
      'create font and assign handle to a variable
      hFont = CreateFontIndirect( BYVAL VARPTR(lFont))
    
      hDC = getDc(hWnd&)
        newfont = selectobject(hDC, hfont)
    
        SetBkMode hDC, %TRANSPARENT
        SetTextColor hDC, TxColor&
    
        TextOut hDC, x&, y&, BYVAL STRPTR(Txt$), LEN(Txt$)     '<- Print text
    
        DeleteObject SelectObject(hDC, newfont)
      ReleaseDC hWnd&, hDC
    
    END SUB
    '--------------------------------------------------------------------------------
    
    
    
    '--------------------------------------------------------------------------------
    FUNCTION PBMAIN()
    
        LOCAL dm AS DEVMODE
        DIM GetColorFor( 1)
    
        'Set colors for 256 color mode
        GetColorFor(0).BkFace            = RGB( 128, 128, 0)
        GetColorFor(0).BkFaceSunken      = RGB( 128, 128, 0) '%YELLOW does not make good 3D effect
        GetColorFor(0).BkHighlight       = RGB( 128, 0, 0)
        GetColorFor(0).BkHighlightSunken = RGB( 128, 0, 0)   '%RED does not make good 3D effect
        GetColorFor(0).TxDefault         = GetSysColor( %COLOR_MENUTEXT)
        GetColorFor(0).TxGrayed          = &H00505050  'Dark Gray
        GetColorFor(0).TxHighlighted     = %YELLOW
    
        'Set colors for 16 bit/High Color or better
        GetColorFor(1).BkFace            = RGB( 200, 200, 152)
        GetColorFor(1).BkFaceSunken      = RGB( 220, 220, 188)
        GetColorFor(1).BkHighlight       = RGB( 173, 173, 101)
        GetColorFor(1).BkHighlightSunken = RGB( 187, 187, 128)
        GetColorFor(1).TxDefault         = GetSysColor( %COLOR_MENUTEXT)
        GetColorFor(1).TxGrayed          = GetSysColor( %COLOR_GRAYTEXT)
        GetColorFor(1).TxHighlighted     = %BLUE
    
        dm.dmSize = LEN( DEVMODE)
        EnumDisplaySettings BYVAL 0, %ENUM_CURRENT_SETTINGS, dm
        CurrentDisplayMode = IIF&( dm.dmBitsPerPel > 8, 1, 0)
    
        PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES)
    
        ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    
    
    '--------------------------------------------------------------------------------
    '   ** CallBacks **
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
        REGISTER I AS LONG, J AS LONG
    
        STATIC hTCBrush    AS LONG  ' Maintain a custom background color brush for Tab Control
        STATIC TCDlgBorder AS LONG  ' Remember the 'coordinate' of the right edge of the parent dialog
        STATIC TCTabBorder AS LONG  ' Remember the 'coordinate' of the right edge of the last tab
    
        LOCAL hTab    AS LONG
    
        LOCAL lDISPtr AS DRAWITEMSTRUCT PTR
        LOCAL mminfo  AS MINMAXINFO PTR
        LOCAL pNMHDR  AS NMHDR PTR
        LOCAL Result  AS LONG
        LOCAL rc      AS RECT
        LOCAL rc2     AS RECT
        LOCAL pt      AS POINTAPI
    
        LOCAL ptrrc AS RECT PTR
    
        SELECT CASE CBMSG
            CASE %WM_INITDIALOG
                'Initialize custom brush for painting tab control
                hTCBrush = CreateSolidBrush( GetColorFor( CurrentDisplayMode).BkFace)
    
                'Get current dialog size
                GetClientRect CBHNDL, rc
    
                'Adjust RECT for tab control
                rc.nTop     = %ODTC_TAB_CNTRL_VERT_OFFSET
                rc.nLeft    = %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nRight   = rc.nRight - %ODTC_TAB_CNTRL_HORZ_OFFSET * 2
                rc.nBottom  = rc.nBottom - %ODTC_TAB_CNTRL_VERT_OFFSET * 2
                hTab = GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1)
                MoveWindow  hTab, rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
    
                'Add padding to account for icon width
                TabCtrl_SetPadding hTab, %ODTC_ICON_WIDTH , %ODTC_MARGIN_SPACING
    
                'Set Global dimensioning variables
                TabCtrl_GetItemRect hTab, 1, rc2
                'Assume X & Y borders are same thickness....
                TabBorderThickness = GetSystemMetrics( %SM_CYEDGE)
    
                'Get styles for tab control
                J = GetWindowLong( hTab, %GWL_STYLE)
                'Adjust position & sizes of child dialogs
                IF (J AND %TCS_RIGHT) AND (J AND %TCS_VERTICAL) THEN
                   'Tabs are vertical and to the right side
                   TabHeight = rc2.nRight - rc2.nLeft
                   'Adjust upper left corner and height & width for child dialogs
                   rc.nTop    = rc.nTop    + TabBorderThickness
                   rc.nLeft   = rc.nLeft   + TabBorderThickness
                   rc.nRight  = rc.nRight  - TabHeight - TabBorderThickness * 3 + 1
                   rc.nBottom = rc.nBottom - TabBorderThickness * 2
                   'Set DlgBorder for label
                   TCDlgBorder = rc.nBottom + %ODTC_TAB_CNTRL_VERT_OFFSET
                ELSEIF (J AND %TCS_VERTICAL) THEN
                   'Tabs are vertical and to the left side
                   TabHeight = rc2.nRight - rc2.nLeft
                   'Adjust upper left corner and height & width for child dialogs
                   rc.nTop    = rc.nTop    + TabBorderThickness
                   rc.nLeft   = rc.nLeft   + TabHeight + TabBorderThickness * 2
                   rc.nRight  = rc.nRight  - TabHeight - TabBorderThickness * 3
                   rc.nBottom = rc.nBottom - TabBorderThickness * 2
                   'Set DlgBorder for label
                   TCDlgBorder = rc.nBottom + %ODTC_TAB_CNTRL_VERT_OFFSET
                ELSEIF (J AND %TCS_BOTTOM) THEN
                   'Tabs are horizontal and at the bottom
                   TabHeight = rc2.nBottom - rc2.nTop
                   'Adjust upper left corner and height & width for child dialogs
                   rc.nTop    = rc.nTop    + TabBorderThickness
                   rc.nLeft   = rc.nLeft   + TabBorderThickness
                   rc.nRight  = rc.nRight  - TabBorderThickness * 2
                   rc.nBottom = rc.nBottom - TabHeight - TabBorderThickness * 3 'Three borders : 2 for frame and 1 between tab & window
                   'Set DlgBorder for label
                   TCDlgBorder = rc.nRight + %ODTC_TAB_CNTRL_HORZ_OFFSET
                ELSE
                   'Tabs are horizontal and at the top
                   TabHeight = rc2.nBottom - rc2.nTop
                   'Adjust upper left corner and height & width for child dialogs
                   rc.nTop    = rc.nTop    + TabHeight + TabBorderThickness * 2
                   rc.nLeft   = rc.nLeft   + TabBorderThickness
                   rc.nRight  = rc.nRight  - TabBorderThickness * 2
                   rc.nBottom = rc.nBottom - TabHeight - TabBorderThickness * 3
                   'Set DlgBorder for label
                   TCDlgBorder = rc.nRight + %ODTC_TAB_CNTRL_HORZ_OFFSET
                END IF
                FOR I = 0 TO UBOUND( gPage())
                   MoveWindow  gPage( I), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
                NEXT
    
            CASE %WM_GETMINMAXINFO
                mminfo = CBLPARAM
                IF (GetWindowLong( GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), %GWL_STYLE) AND %TCS_VERTICAL) THEN
                   'Set the minimum dialog height to maintain single line tab
                   @mminfo.ptMinTrackSize.y = TCTabBorder + %ODTC_TAB_CNTRL_VERT_OFFSET + GetSystemMetrics( %SM_CYSIZEFRAME) * 2 + GetSystemMetrics( %SM_CYCAPTION) + TabBorderThickness + 1
                ELSE
                   'Set the minimum dialog width to maintain single line tab
                   @mminfo.ptMinTrackSize.x = TCTabBorder + %ODTC_TAB_CNTRL_HORZ_OFFSET + GetSystemMetrics( %SM_CXSIZEFRAME) * 2 + TabBorderThickness + 1
                END IF
    
            CASE %WM_DRAWITEM
                IF CBWPARAM = %IDC_SYSTABCONTROL32_1 THEN
                   lDISPtr = CBLPARAM
    
                   TabCtrl_GetItemRect @lDISPtr.hwndItem, @lDISPtr.ItemId, rc
                   rc2 = rc
    
                   'Get styles for tab control
                   J = GetWindowLong( GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), %GWL_STYLE)
                   IF (J AND %TCS_RIGHT) AND (J AND %TCS_VERTICAL) THEN
                      'Tabs are vertical and to the right side
                      IF ISFALSE (@lDISPtr.ItemState AND %ODS_SELECTED) THEN rc.nRight = rc.nRight + TabBorderThickness
                      SELECT CASE AS LONG @lDISPtr.ItemId
                         CASE 0
                            IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                               rc.nLeft = rc.nLeft + 1
                            ELSE
                               rc.nTop = rc.nTop - TabBorderThickness
                            END IF
                         CASE UBOUND( gPage)
                            IF TCTabBorder = 0 THEN
                               'Initial drawing
                               TCTabBorder = rc.nBottom + TabBorderThickness * 2 + 1
                               MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), rc.nLeft + %ODTC_TAB_CNTRL_HORZ_OFFSET, TCTabBorder, TabHeight + TabBorderThickness, TCDlgBorder, 0
                            ELSE
                               IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                                  TCTabBorder = rc.nBottom + TabBorderThickness * 3 + 1
                               ELSE
                                  TCTabBorder = rc.nBottom + TabBorderThickness * 2 + 1
                                  rc.nBottom = rc.nBottom + TabBorderThickness
                               END IF
                            END IF
                      END SELECT
                      IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                         rc.nLeft = rc.nLeft - TabBorderThickness * 4
                         rc2.nRight = rc2.nRight + TabBorderThickness
                         rc2.nLeft  = rc2.nLeft  + TabBorderThickness
                      END IF
    
                      FillRect  @lDISPtr.hDC, rc, hTCBrush
                      SetBkMode @lDISPtr.hDC, %TRANSPARENT
                      IF (J AND %TCS_HOTTRACK) THEN
                         GetCursorPos pt
                         ScreenToClient GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), pt
                         IF PtInRect( rc, pt.x, pt.y) THEN
                            I = GetColorFor( CurrentDisplayMode).TxHighlighted
                         ELSE
                            I = GetColorFor( CurrentDisplayMode).TxDefault
                         END IF
                      ELSE
                         I = GetColorFor( CurrentDisplayMode).TxDefault
                      END IF
    
                      RotateText @lDISPtr.hWndItem, 270, TCImages( @lDISPtr.ItemId).zText, rc2.nRight - %ODTC_MARGIN_SPACING - TabBorderThickness, rc2.nTop + TabBorderThickness + %ODTC_ICON_WIDTH + %ODTC_TEXT_OFFSET_FROM_ICON + %ODTC_MARGIN_SPACING, I
                      'Draw icon if any...
                      IF TCImages( @lDISPtr.ItemId).hIcon THEN DrawIconEx @lDISPtr.hDC, rc2.nLeft - TabBorderThickness + %ODTC_MARGIN_SPACING, rc2.nTop + %ODTC_MARGIN_SPACING + TabBorderThickness, _
                                                                          TCImages( @lDISPtr.ItemId).hIcon, 16, 16, 0, BYVAL 0, %DI_NORMAL
                   ELSEIF (J AND %TCS_VERTICAL) THEN
                      'Tabs are vertical and to the left side
                      IF ISFALSE (@lDISPtr.ItemState AND %ODS_SELECTED) THEN rc.nLeft = rc.nLeft - TabBorderThickness
                      SELECT CASE AS LONG @lDISPtr.ItemId
                         CASE 0
                            IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                               rc.nRight = rc.nRight - 1
                            ELSE
                               rc.nTop = rc.nTop - TabBorderThickness
                            END IF
                         CASE UBOUND( gPage)
                            IF TCTabBorder = 0 THEN
                               'Initial drawing
                               TCTabBorder = rc.nBottom + TabBorderThickness * 2 + 1
                               MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), rc.nLeft + %ODTC_TAB_CNTRL_HORZ_OFFSET, TCTabBorder, TabHeight + TabBorderThickness, TCDlgBorder, 0
                            ELSE
                               IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                                  TCTabBorder = rc.nBottom + TabBorderThickness * 3 + 1
                               ELSE
                                  TCTabBorder = rc.nBottom + TabBorderThickness * 2 + 1
                                  rc.nBottom = rc.nBottom + TabBorderThickness
                               END IF
                            END IF
                      END SELECT
                      IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                         rc.nRight = rc.nRight + TabBorderThickness * 2
                         rc2.nLeft = rc2.nLeft - TabBorderThickness
                      END IF
    
                      FillRect  @lDISPtr.hDC, rc, hTCBrush
                      SetBkMode @lDISPtr.hDC, %TRANSPARENT
                      IF (J AND %TCS_HOTTRACK) THEN
                         GetCursorPos pt
                         ScreenToClient GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), pt
                         IF PtInRect( rc, pt.x, pt.y) THEN
                            I = GetColorFor( CurrentDisplayMode).TxHighlighted
                         ELSE
                            I = GetColorFor( CurrentDisplayMode).TxDefault
                         END IF
                      ELSE
                         I = GetColorFor( CurrentDisplayMode).TxDefault
                      END IF
    
                      RotateText @lDISPtr.hWndItem, 90, TCImages( @lDISPtr.ItemId).zText, rc2.nLeft + %ODTC_MARGIN_SPACING, rc2.nBottom - TabBorderThickness - %ODTC_ICON_WIDTH - %ODTC_TEXT_OFFSET_FROM_ICON - %ODTC_MARGIN_SPACING, I
    
                      'Draw icon if any...
                      IF TCImages( @lDISPtr.ItemId).hIcon THEN DrawIconEx @lDISPtr.hDC, rc2.nLeft + %ODTC_MARGIN_SPACING, rc2.nBottom - TabBorderThickness - %ODTC_ICON_WIDTH - %ODTC_MARGIN_SPACING, _
                                                                          TCImages( @lDISPtr.ItemId).hIcon, 16, 16, 0, BYVAL 0, %DI_NORMAL
                   ELSEIF (J AND %TCS_BOTTOM) THEN
                      'Tabs are horizontal and at the bottom
                      IF ISFALSE (@lDISPtr.ItemState AND %ODS_SELECTED) THEN rc.nBottom = rc.nBottom + TabBorderThickness
                      SELECT CASE AS LONG @lDISPtr.ItemId
                         CASE 0
                            'Special case for first tab...
                            IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                               'If selected, need to draw one less pixel at top
                               rc.nTop = rc.nTop + 1
                            ELSE
                               'If not selected, need to paint background where border is not drawn
                               rc.nLeft = rc.nLeft - TabBorderThickness
                            END IF
                         CASE UBOUND( gPage)
                            'Special case for last tab...
                            IF TCTabBorder = 0 THEN
                               'Initial drawing, set TCTabBorder and set label maintain background color
                               TCTabBorder = rc.nRight + TabBorderThickness * 2 + 1
                               'Assume that last tab is NOT the default when tab control is initialized...
                               MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), TCTabBorder, rc.nTop + %ODTC_TAB_CNTRL_VERT_OFFSET, TCDlgBorder, TabHeight + TabBorderThickness , 0
                            ELSE
                               'adjust TCTabBorder depending upon selection state
                               IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                                  TCTabBorder = rc.nRight + TabBorderThickness * 3 + 1
                               ELSE
                                  TCTabBorder = rc.nRight + TabBorderThickness * 2 + 1
                                  rc.nRight = rc.nRight + TabBorderThickness
                               END IF
                            END IF
                      END SELECT
                      IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                         rc.nTop = rc.nTop - TabBorderThickness * 2
                         rc2.nTop = rc2.nTop + TabBorderThickness
                      END IF
                      IF (J AND %TCS_HOTTRACK) THEN
                         GetCursorPos pt
                         ScreenToClient GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), pt
                         IF PtInRect( rc, pt.x, pt.y) THEN
                            I = GetColorFor( CurrentDisplayMode).TxHighlighted
                         ELSE
                            I = GetColorFor( CurrentDisplayMode).TxDefault
                         END IF
                      ELSE
                         I = GetColorFor( CurrentDisplayMode).TxDefault
                      END IF
    
                      FillRect  @lDISPtr.hDC, rc, hTCBrush
                      SetBkMode @lDISPtr.hDC, %TRANSPARENT
                      SetTextColor @lDISPtr.hDC, I
    
                      TextOut @lDISPtr.hDC, rc2.nLeft + TabBorderThickness + %ODTC_ICON_WIDTH + %ODTC_TEXT_OFFSET_FROM_ICON + %ODTC_MARGIN_SPACING, _
                              rc2.nTop + %ODTC_MARGIN_SPACING, TCImages( @lDISPtr.ItemId).zText, LEN( TCImages( @lDISPtr.ItemId).zText)
                      'Draw icon if any...
                      IF TCImages( @lDISPtr.ItemId).hIcon THEN DrawIconEx @lDISPtr.hDC, rc2.nLeft + TabBorderThickness + %ODTC_MARGIN_SPACING, rc2.nTop + %ODTC_MARGIN_SPACING, _
                                                                          TCImages( @lDISPtr.ItemId).hIcon, 16, 16, 0, BYVAL 0, %DI_NORMAL
                   ELSE
                      'Tabs are horizontal and at the top
                      IF ISFALSE (@lDISPtr.ItemState AND %ODS_SELECTED) THEN rc.nTop = rc.nTop - TabBorderThickness
                      SELECT CASE AS LONG @lDISPtr.ItemId
                         CASE 0
                            'Special case for first tab...
                            IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                               'If selected, need to draw one less pixel at bottom
                               rc.nBottom = rc.nBottom - 1
                            ELSE
                               'If not selected, need to paint background where border is not drawn
                               rc.nLeft = rc.nLeft - TabBorderThickness
                            END IF
                         CASE UBOUND( gPage)
                            'Special case for last tab...
                            IF TCTabBorder = 0 THEN
                               'Initial drawing, set TCTabBorder and set label maintain background color
                               TCTabBorder = rc.nRight + %ODTC_TAB_CNTRL_HORZ_OFFSET
                               'Assume that last tab is NOT the default when tab control is initialized...
                               MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), TCTabBorder, rc.nTop + %ODTC_TAB_CNTRL_VERT_OFFSET, TCDlgBorder, TabHeight + TabBorderThickness , 0
                            ELSE
                               'adjust TCTabBorder depending upon selection state
                               IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                                  TCTabBorder = rc.nRight + TabBorderThickness * 3 + 1
                               ELSE
                                  TCTabBorder = rc.nRight + TabBorderThickness * 2 + 1
                                  rc.nRight = rc.nRight + TabBorderThickness
                               END IF
                            END IF
                      END SELECT
                      IF (@lDISPtr.ItemState AND %ODS_SELECTED) THEN
                         rc.nBottom = rc.nBottom + TabBorderThickness * 2
                         rc2.nTop = rc2.nTop - TabBorderThickness
                      END IF
                      IF (J AND %TCS_HOTTRACK) THEN
                         GetCursorPos pt
                         ScreenToClient GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), pt
                         IF PtInRect( rc, pt.x, pt.y) THEN
                            I = GetColorFor( CurrentDisplayMode).TxHighlighted
                         ELSE
                            I = GetColorFor( CurrentDisplayMode).TxDefault
                         END IF
                      ELSE
                         I = GetColorFor( CurrentDisplayMode).TxDefault
                      END IF
    
                      FillRect  @lDISPtr.hDC, rc, hTCBrush
                      SetBkMode @lDISPtr.hDC, %TRANSPARENT
                      SetTextColor @lDISPtr.hDC, I
    
                      TextOut @lDISPtr.hDC, rc2.nLeft + TabBorderThickness + %ODTC_ICON_WIDTH + %ODTC_TEXT_OFFSET_FROM_ICON + %ODTC_MARGIN_SPACING, _
                              rc2.nTop + %ODTC_MARGIN_SPACING, TCImages( @lDISPtr.ItemId).zText, LEN( TCImages( @lDISPtr.ItemId).zText)
                      'Draw icon if any...
                      IF TCImages( @lDISPtr.ItemId).hIcon THEN DrawIconEx @lDISPtr.hDC, rc2.nLeft + TabBorderThickness + %ODTC_MARGIN_SPACING, rc2.nTop + %ODTC_MARGIN_SPACING, _
                                                                          TCImages( @lDISPtr.ItemId).hIcon, 16, 16, 0, BYVAL 0, %DI_NORMAL
                   END IF
                END IF
    
           CASE %WM_SIZE
                'Get current dialog size
                rc.nRight  = LOWRD( CBLPARAM)
                rc.nBottom = HIWRD( CBLPARAM)
    
                'Adjust RECT for tab control
                rc.nTop  = %ODTC_TAB_CNTRL_VERT_OFFSET
                rc.nLeft = %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nRight  = rc.nRight - rc.nLeft - %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nBottom = rc.nBottom - rc.nTop - %ODTC_TAB_CNTRL_VERT_OFFSET
                MoveWindow  GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
    
                'Get styles for tab control
                J = GetWindowLong( GetDlgItem( CBHNDL, %IDC_SYSTABCONTROL32_1), %GWL_STYLE)
    
                IF (J AND %TCS_RIGHT) AND (J AND %TCS_VERTICAL) THEN
                   'Tabs are vertical and to the right side
    
                   'Adjust label to the bottom of last tab
                   TCDlgBorder = rc.nBottom + %ODTC_TAB_CNTRL_VERT_OFFSET
                   MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), rc.nRight - TabHeight - TabBorderThickness + %ODTC_TAB_CNTRL_VERT_OFFSET, TCTabBorder, rc.nRight, TCDlgBorder, 0
    
                   'Adjust RECT for child dialogs
                   rc.nTop    = rc.nTop    + TabBorderThickness
                   rc.nLeft   = rc.nLeft   + TabBorderThickness
                   rc.nRight  = rc.nRight  - TabHeight - TabBorderThickness * 3 + 1
                   rc.nBottom = rc.nBottom - TabBorderThickness * 2
                ELSEIF (J AND %TCS_VERTICAL) THEN
                   'Tabs are vertical and to the left side
    
                   'Adjust label to the bottom of last tab
                   TCDlgBorder = rc.nBottom + %ODTC_TAB_CNTRL_VERT_OFFSET
                   MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), rc.nLeft, TCTabBorder, TabHeight + TabBorderThickness, TCDlgBorder, 0
    
                   'Adjust RECT for child dialogs
                   rc.nTop    = rc.nTop    + TabBorderThickness
                   rc.nLeft   = rc.nLeft   + TabHeight + TabBorderThickness * 2
                   rc.nRight  = rc.nRight  - TabHeight - TabBorderThickness * 3
                   rc.nBottom = rc.nBottom - TabBorderThickness * 2
                ELSEIF (J AND %TCS_BOTTOM) THEN
                   'Tabs are horizontal and at the bottom
    
                   'Adjust label to the right of last tab
                   TCDlgBorder = rc.nRight + %ODTC_TAB_CNTRL_HORZ_OFFSET
                   MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), TCTabBorder, rc.nBottom - TabHeight - TabBorderThickness + %ODTC_TAB_CNTRL_VERT_OFFSET, TCDlgBorder, TabHeight + TabBorderThickness, 0
    
                   'Adjust RECT for child dialogs
                   rc.nTop    = rc.nTop    + TabBorderThickness
                   rc.nLeft   = rc.nLeft   + TabBorderThickness
                   rc.nRight  = rc.nRight  - TabBorderThickness * 2
                   rc.nBottom = rc.nBottom - TabHeight - TabBorderThickness * 3 'Three borders : 2 for frame and 1 between tab & window
                ELSE
                   'Tabs are horizontal and at the top
    
                   'Adjust label to the right of last tab
                   TCDlgBorder = rc.nRight + %ODTC_TAB_CNTRL_HORZ_OFFSET
                   MoveWindow  GetDlgItem( CBHNDL, %IDC_TAB_OVERLAY_LABEL), TCTabBorder, rc.nTop, TCDlgBorder, TabHeight + TabBorderThickness, 0
    
                   'Adjust RECT for child dialogs
                   rc.nTop    = rc.nTop    + TabHeight + TabBorderThickness * 2
                   rc.nLeft   = rc.nLeft   + TabBorderThickness
                   rc.nRight  = rc.nRight  - TabBorderThickness * 2
                   rc.nBottom = rc.nBottom - TabHeight - TabBorderThickness * 3
                END IF
                FOR I = 0 TO UBOUND( gPage())
                   MoveWindow  gPage( I), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
                NEXT
                InvalidateRect CBHNDL, BYVAL 0, 1
    
            CASE %WM_NOTIFY
                pNMHDR = CBLPARAM
    
                SELECT CASE @pNMHDR.idFrom
                    CASE %IDC_SYSTABCONTROL32_1
                        ' Get the current tab page number (zero based)
                        CONTROL SEND CBHNDL, %IDC_SYSTABCONTROL32_1, %TCM_GETCURSEL, 0, 0 TO Result
    
                        SELECT CASE @pNMHDR.code
                            CASE %TCN_SELCHANGING
                                DIALOG SHOW STATE gPage(Result), %SW_HIDE
                            CASE %TCN_SELCHANGE
                                DIALOG SHOW STATE gPage(Result), %SW_SHOW
                        END SELECT
                END SELECT
    
           CASE %WM_DISPLAYCHANGE
               J = IIF&( CBWPARAM > 8, 1, 0)
               IF J <> CurrentDisplayMode THEN
                  CurrentDisplayMode = J
                  'Release old brushes
                  DeleteObject hTCBrush
                  'Get new brushes
                  hTCBrush = CreateSolidBrush( GetColorFor( J).BkFace)
                  DIALOG SET COLOR CBHNDL, GetColorFor( J).TxDefault, GetColorFor( J).BkFace
                  CONTROL SET COLOR CBHNDL, %IDC_TAB_OVERLAY_LABEL, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
                  FOR I = 0 TO UBOUND( gPage())
                     DIALOG SET COLOR  gPage( I), GetColorFor( J).TxDefault, GetColorFor( J).BkFace
                  NEXT
                  'Force redraw of main dialog
                  DIALOG REDRAW CBHNDL
               END IF
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_SYSTABCONTROL32_1
                END SELECT
    
            CASE %WM_DESTROY
                'Release old brushes
                DeleteObject hTCBrush
    
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG2Proc()
    
        LOCAL rc AS RECT
    
        SELECT CASE CBMSG
           CASE %WM_SIZE
                'Get current dialog size
                GetClientRect CBHNDL, rc
    
                'Adjust RECT for textbox control
                rc.nTop  = %ODTC_TAB_CNTRL_VERT_OFFSET
                rc.nLeft = %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nRight  = rc.nRight - rc.nLeft - %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nBottom = rc.nBottom - rc.nTop - %ODTC_TAB_CNTRL_VERT_OFFSET
                MoveWindow  GetDlgItem( CBHNDL, %IDC_TEXTBOX1), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_TEXTBOX1
    
                END SELECT
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG3Proc()
    
        LOCAL rc AS RECT
    
        SELECT CASE CBMSG
           CASE %WM_SIZE
                'Get current dialog size
                GetClientRect CBHNDL, rc
    
                'Adjust RECT for textbox control
                rc.nTop  = %ODTC_TAB_CNTRL_VERT_OFFSET
                rc.nLeft = %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nRight  = rc.nRight \ 2 - %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nBottom = rc.nBottom - rc.nTop - %ODTC_TAB_CNTRL_VERT_OFFSET
                MoveWindow  GetDlgItem( CBHNDL, %IDC_TEXTBOX2), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_TEXTBOX2
    
                END SELECT
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG4Proc()
    
        LOCAL rc AS RECT
    
        SELECT CASE CBMSG
           CASE %WM_SIZE
                'Get current dialog size
                GetClientRect CBHNDL, rc
    
                'Adjust RECT for textbox control
                rc.nTop  = %ODTC_TAB_CNTRL_VERT_OFFSET
                rc.nLeft = rc.nRight \ 2
                rc.nRight  = rc.nRight - rc.nLeft - %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nBottom = rc.nBottom - rc.nTop - %ODTC_TAB_CNTRL_VERT_OFFSET
                MoveWindow  GetDlgItem( CBHNDL, %IDC_TEXTBOX3), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_TEXTBOX3
    
                END SELECT
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG5Proc()
    
        LOCAL rc AS RECT
    
        SELECT CASE CBMSG
           CASE %WM_SIZE
                'Get current dialog size
                GetClientRect CBHNDL, rc
    
                'Adjust RECT for textbox control
                rc.nTop  = %ODTC_TAB_CNTRL_VERT_OFFSET
                rc.nLeft = %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nRight  = rc.nRight - rc.nLeft - %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nBottom = rc.nBottom \ 2 - rc.nTop
                MoveWindow  GetDlgItem( CBHNDL, %IDC_TEXTBOX4), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_TEXTBOX4
    
                END SELECT
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG6Proc()
    
        LOCAL rc AS RECT
    
        SELECT CASE CBMSG
           CASE %WM_SIZE
                'Get current dialog size
                GetClientRect CBHNDL, rc
    
                'Adjust RECT for textbox control
                rc.nTop  = rc.nBottom \ 2
                rc.nLeft = %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nRight  = rc.nRight - rc.nLeft - %ODTC_TAB_CNTRL_HORZ_OFFSET
                rc.nBottom = rc.nBottom - rc.nTop - %ODTC_TAB_CNTRL_VERT_OFFSET
                MoveWindow  GetDlgItem( CBHNDL, %IDC_TEXTBOX5), rc.nLeft, rc.nTop, rc.nRight, rc.nBottom, 0
    
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_TEXTBOX5
    
                END SELECT
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** Sample Code **
    '--------------------------------------------------------------------------------
    FUNCTION SampleTabCtrl(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lCount AS _
        LONG) AS LONG
    
        LOCAL tTC_Item    AS TC_ITEM
        LOCAL szBuf       AS ASCIIZ * 32
        LOCAL i           AS LONG
        LOCAL hCtl        AS DWORD
    
        CONTROL HANDLE hDlg, lID TO hCtl
    
        tTC_Item.Mask       = %TCIF_TEXT
        tTC_Item.iImage     = -1
        tTC_Item.pszText    = VARPTR(szBuf)
    
        'Initialize global data for text & icon storage
        DIM TCImages( 0: lCount-1)
        TCImages( 0).hIcon = LoadIcon(0, BYVAL %IDI_EXCLAMATION)
        TCImages( 1).hIcon = LoadIcon(0, BYVAL %IDI_HAND)
        TCImages( 2).hIcon = LoadIcon(0, BYVAL %IDI_APPLICATION)
        TCImages( 3).hIcon = LoadIcon(0, BYVAL %IDI_QUESTION)
        TCImages( 4).hIcon = LoadIcon(0, BYVAL %IDI_ASTERISK)
    
        FOR i = 0 TO lCount - 1
            szBuf = "Tab " + FORMAT$(i)  '
            TCImages( i).zText = szBuf
            TabCtrl_InsertItem hCtl, i, tTC_Item
        NEXT i
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    
    
    '--------------------------------------------------------------------------------
    '   ** Dialogs **
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    'Tab control orientations:
    '#1 [horizontal tab at top]    - use current style
    '#2 [horizontal tab at bottom] - add %TCS_BOTTOM to #1
    '#3 [vertical tab at left]     - add %TCS_VERTICAL to #1
    '#4 [vertical tab at right]    - add %TCS_VERTICAL OR %TCS_RIGHT to #1
    #PBFORMS Begin Dialog %IDD_DIALOG1->->
        LOCAL hDlg AS DWORD
    
    
        DIALOG NEW hParent, "Owner Drawn Tab Control Example", , , 480, 250, _
            %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU _
            OR %WS_MINIMIZEBOX OR %WS_VISIBLE OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
            %DS_SETFONT OR %WS_SIZEBOX OR %WS_MAXIMIZEBOX, %WS_EX_WINDOWEDGE OR _
            %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
            %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD "SysTabControl32", hDlg, %IDC_SYSTABCONTROL32_1, _
            "SysTabControl321", 6, 10, 234, 135, %WS_CHILD OR %WS_VISIBLE OR _
            %WS_TABSTOP OR %TCS_MULTILINE OR %TCS_RAGGEDRIGHT OR _
            %TCS_HOTTRACK OR %TCS_OWNERDRAWFIXED OR %WS_CLIPSIBLINGS, %WS_EX_LEFT OR _
            %WS_EX_LTRREADING
        CONTROL ADD LABEL, hDlg, %IDC_TAB_OVERLAY_LABEL, "", 40, 150, 135, 15
    
    #PBFORMS End Dialog
    
        SampleTabCtrl hDlg, %IDC_SYSTABCONTROL32_1, 5
    
        DIM gPage(0:4) AS GLOBAL DWORD
        gPage(0) = ShowDIALOG2(hDlg)
        gPage(1) = ShowDIALOG3(hDlg)
        gPage(2) = ShowDIALOG4(hDlg)
        gPage(3) = ShowDIALOG5(hDlg)
        gPage(4) = ShowDIALOG6(hDlg)
    
        LOCAL z AS LONG
        FOR z = 0 TO 4
           DIALOG SHOW STATE gPage(z), IIF&(z = 0, %SW_SHOW, %SW_HIDE)
        NEXT
    
        DIALOG SET COLOR hDlg, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
        CONTROL SET COLOR hDlg, %IDC_TAB_OVERLAY_LABEL, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
        FUNCTION = lRslt
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS Begin Dialog %IDD_DIALOG2->->
        LOCAL hDlg AS DWORD
    
        DIALOG NEW hParent, "Page 1", 115, 122, 232, 123, %WS_CHILD OR %WS_VISIBLE _
            OR %DS_CONTROL 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 TEXTBOX, hDlg, %IDC_TEXTBOX1, "TextBox1", 5, 5, 220, 110, _
            %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_AUTOVSCROLL OR _
            %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING _
            OR %WS_EX_RIGHTSCROLLBAR
    
    #PBFORMS End Dialog
    
        DIALOG SET COLOR hDlg, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
    
        DIALOG SHOW STATE hDlg, %SW_HIDE
        DIALOG SHOW MODELESS hDlg, CALL ShowDIALOG2Proc
    
        FUNCTION = hDlg
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG3(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS Begin Dialog %IDD_DIALOG3->->
        LOCAL hDlg AS DWORD
    
        DIALOG NEW hParent, "Page 2", 115, 122, 232, 123, %WS_CHILD OR %WS_VISIBLE _
            OR %DS_CONTROL 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 TEXTBOX, hDlg, %IDC_TEXTBOX2, "TextBox2", 5, 5, 110, 110, _
            %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_AUTOVSCROLL OR _
            %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING _
            OR %WS_EX_RIGHTSCROLLBAR
    
    #PBFORMS End Dialog
    
        DIALOG SET COLOR hDlg, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
    
        DIALOG SHOW STATE hDlg, %SW_HIDE
        DIALOG SHOW MODELESS hDlg, CALL ShowDIALOG3Proc
    
        FUNCTION = hDlg
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG4(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS Begin Dialog %IDD_DIALOG4->->
        LOCAL hDlg AS DWORD
    
        DIALOG NEW hParent, "Page 3", 115, 122, 232, 123, %WS_CHILD OR %WS_VISIBLE _
            OR %DS_CONTROL 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 TEXTBOX, hDlg, %IDC_TEXTBOX3, "TextBox3", 115, 5, 110, 110, _
            %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_AUTOVSCROLL OR _
            %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING _
            OR %WS_EX_RIGHTSCROLLBAR
    
    #PBFORMS End Dialog
    
        DIALOG SET COLOR hDlg, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
    
        DIALOG SHOW STATE hDlg, %SW_HIDE
        DIALOG SHOW MODELESS hDlg, CALL ShowDIALOG4Proc
    
        FUNCTION = hDlg
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG5(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS Begin Dialog %IDD_DIALOG5->->
        LOCAL hDlg AS DWORD
    
        DIALOG NEW hParent, "Page 4", 115, 122, 232, 123, %WS_CHILD OR %WS_VISIBLE _
            OR %DS_CONTROL 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 TEXTBOX, hDlg, %IDC_TEXTBOX4, "TextBox4", 5, 5, 220, 55, _
            %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_AUTOVSCROLL OR _
            %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING _
            OR %WS_EX_RIGHTSCROLLBAR
    
    #PBFORMS End Dialog
    
        DIALOG SET COLOR hDlg, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
    
        DIALOG SHOW STATE hDlg, %SW_HIDE
        DIALOG SHOW MODELESS hDlg, CALL ShowDIALOG5Proc
    
        FUNCTION = hDlg
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG6(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS Begin Dialog %IDD_DIALOG6->->
        LOCAL hDlg AS DWORD
    
        DIALOG NEW hParent, "Page 5", 115, 122, 232, 123, %WS_CHILD OR %WS_VISIBLE _
            OR %DS_CONTROL 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 TEXTBOX, hDlg, %IDC_TEXTBOX5, "TextBox5", 5, 60, 220, 55, _
            %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_AUTOVSCROLL OR _
            %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING _
            OR %WS_EX_RIGHTSCROLLBAR
    
    #PBFORMS End Dialog
    
        DIALOG SET COLOR hDlg, GetColorFor( CurrentDisplayMode).TxDefault, GetColorFor( CurrentDisplayMode).BkFace
    
        DIALOG SHOW STATE hDlg, %SW_HIDE
        DIALOG SHOW MODELESS hDlg, CALL ShowDIALOG6Proc
    
        FUNCTION = hDlg
    END FUNCTION
    '--------------------------------------------------------------------------------
    Bernard Ertl
    InterPlan Systems

    Comment

    Working...
    X