Tab Controls..

Started by Exploration Gaming , June 09, 2013, 08:15:43 PM

Previous topic - Next topic

Exploration Gaming

Is there a way to change the background color of Tab controls? I added a control on a dialog, created the pages for the tab control, but the tab itself is totally white. When the pages are added to the tab there is a white trim/edge shown on the left side and bottom of the tab control.

I've tried the FF_CONTROL_SETCOLOR, and SetBkColor on the control but no luck.. Any ideas?
Explorations RPG System
"RPG Makers come & Go, But Explorations is Forever!"
http://www.explore-rpg.com

Peter Heffernan

After searching I used some code from the PB site written by Jordi Vallès and placed this into the FRMMAINFORM_CUSTOM function:

This code seems to be OK but do check it yourself before using it. You will also have to set the 'tab' control 'WindowStyles' to TCS_OWNERDRAWFIXED

Function FRMMAINFORM_CUSTOM ( _
                            hWndForm      As Dword, _  ' handle of Form
                            wMsg          As Long,  _  ' type of message
                            wParam        As Dword, _  ' first message parameter
                            lParam        As Long   _  ' second message parameter
                            ) As Long

  Local ps     As PAINTSTRUCT
  Local gRect  As GRADIENT_RECT
  Dim vert(1)  As TRIVERTEX   
  Local clrFg  As Long
  Local lDISPtr As DRAWITEMSTRUCT Ptr 
  Local lZStr   As Asciiz * %MAX_PATH
  Select Case wMsg
    Case %WM_DRAWITEM
      Select Case wparam
        Case IDC_FRMMAINFORM_TABCONTROL1 '
          lDisPtr = lParam
          lZStr = Ff_Tabcontrol_Gettext (HWND_FRMMAINFORM_TABCONTROL1, @lDisPtr.ItemId)
          Beginpaint @lDisPtr.hwndItem, ps
'common to selected or not
            vert(0).x      = @lDisPtr.rcItem.nLeft
            vert(0).y      = @lDisPtr.rcItem.nTop
            vert(1).x      = @lDisPtr.rcItem.nRight
            vert(1).y      = @lDisPtr.rcItem.nBottom
            gRect.UpperLeft  = 0
            gRect.LowerRight = 1

            If @lDisPtr.ItemState = %ODS_SELECTED Then
               vert(0).Red    = &h7000
               vert(0).Green  = &h7000
               vert(0).Blue   = &h7000
               vert(1).Red    = &hf000
               vert(1).Green  = &hf000
               vert(1).Blue   = &hf000
               clrFg = Rgb(&he0,0,0)
            Else
               vert(0).Red    = &hf000
               vert(0).Green  = &hf000
               vert(0).Blue   = &hf000
               vert(1).Red    = &h8000
               vert(1).Green  = &h8000
               vert(1).Blue   = &h8000
               clrFg = Rgb(&h80,0,0)
            End If
            Gradientfill @lDisPtr.hDC, vert(0), 2, gRect, 1, %GRADIENT_FILL_RECT_V
            Setbkmode @lDisPtr.hDC, %TRANSPARENT
            Settextcolor @lDisPtr.hDC, clrFg
            Drawtext @lDisPtr.hDC, lZStr, Len(lZStr), @lDisPtr.rcItem, %DT_SINGLELINE Or %DT_CENTER  Or %DT_VCENTER 
          Endpaint @lDisPtr.hwndItem, ps   
    End Select 
  End Select
End Function