BCX_SPLITTER function

Purpose: BCX_SPLITTER, used with BCX_SETSPLITPOS, creates a child window containing a horizontal or vertical splitter control. When BCX_SPLITTER is invoked, the global variables (case sensitive) SplitBarFG and SplitBarBG, are defined automatically. SplitBarFG defines the foreground color of the splitter bar and is initialized with a default value RGB(0,0,255). SplitBarBG defines the background color of the splitter bar and is initialized with a default value RGB(212,212,212). For an implementation example see the demo below.


 Syntax:

 hCtl = BCX_SPLITTER(hWndParent, _
                         CtlID%  _
                  [, SplitType%] _ 
                   [, BarStyle%] _ 
                       [, Xpos%] _ 
                       [, Ypos%] _ 
                      [, Width%] _ 
                     [, Height%])

 Parameters:

  • hCtl The return value is a HWND data type handle to the child window containing the the splitter control, if the function succeeds. The hCtl handle is the bottom window if the window has been split horizontally. If the window has been split vertically then the hCtl handle is to the right window. If the function fails, the return value is NULL.
  • hWndParent is the HWND data type handle to parent window containing the child window with the the splitter control. When the child window has been split horizontally hWndParent is the top window. If the child window has been split vertically, hWndParent refers to the left window.
  • hCtlID% specifies the identifier of the window created by the splitter control. The identifier is an integer value used by the split-off window to notify its parent about events. The identifier must be unique for each window split from a parent window.
  • SplitType% [OPTIONAL] uses the compiler defined constants HS_HORIZONTAL, value 0, or HS_VERTICAL, value 1, to specify whether the split is vertical or horizontal.
  • BarStyle% [OPTIONAL] if set to TRUE, BCX_SPLITTER uses the new style, if set to FALSE, BCX_SPLITTER uses the old style.
  • Xpos% [OPTIONAL] specifies the initial horizontal position of the splitter control being created. Xpos% is the x-coordinate of the upper-left corner of the splitter control being created relative to the upper-left corner of the parent window's client area.
  • Ypos% [OPTIONAL] specifies the initial vertical position of the splitter control being created. Ypos% is the initial y-coordinate of the upper-left corner of the splitter control being created relative to the upper-left corner of the parent window's client area.
  • Width% [OPTIONAL] specifies the width, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels, of the splitter control being created.
  • Height% [OPTIONAL] specifies the height, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels , of the splitter control being created.

Example:

 $BCXVERSION "5.08"
 
 GUI "ColorSplitterDemo", PIXELS
 
 ENUM
   IDC_Edit1 = 50
   IDC_Edit2
   IDC_List1
   IDC_Split1
   IDC_Split2
   IDC_Button
   IDC_ComboFG
   IDC_ComboBG
 END ENUM
 
 CONST ComboStyle = WS_BORDER | WS_TABSTOP |WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST
 
 GLOBAL Form1  AS HWND
 GLOBAL Edit1  AS CONTROL
 GLOBAL Edit2  AS CONTROL
 GLOBAL List1  AS CONTROL
 GLOBAL Split1 AS CONTROL
 GLOBAL Split2 AS CONTROL
 GLOBAL Button AS CONTROL
 GLOBAL ComboExFG AS CONTROL
 GLOBAL ComboExBG AS CONTROL
 
 
 SUB FORMLOAD
 
   Form1   = BCX_FORM("BCX Splitter Demo", 0, 0, 640, 480)
 
   Split1  = BCX_SPLITTER(Form1,IDC_Split1, HS_VERTICAL,1)
   List1   = BCX_LISTVIEW("Listview1", Split1, IDC_List1, 0, 0, 10, 10,0,WS_EX_CLIENTEDGE)
   Split2  = BCX_SPLITTER(Split1, IDC_Split2, HS_HORIZONTAL, TRUE)
   Edit1   = BCX_RICHEDIT("", Split2, IDC_Edit1, 0, 0, 10, 10)
   Edit2   = BCX_INPUT("", Split2,IDC_Edit2, 0, 0, 200, 240)
 
   Button   = BCX_BUTTON("EXIT DEMO", Form1, IDC_Button, 5, 5)
   ComboExFG = BCX_CONTROL(WC_COMBOBOXEX, Form1,"", IDC_ComboFG, 180, 5 , 175, 180, ComboStyle, 0)
   ComboExBG = BCX_CONTROL(WC_COMBOBOXEX, Form1,"", IDC_ComboBG, 360, 5 , 175, 180, ComboStyle, 0)
   MakeColorCombobox(ComboExFG)
   MakeColorCombobox(ComboExBG)
   SNDMSG(ComboExFG, CB_SETCURSEL,  9, 0)
   SNDMSG(ComboExBG, CB_SETCURSEL, 23, 0)
 
   MODSTYLE(List1,LVS_SHOWSELALWAYS ,LVS_EDITLABELS)
   BCX_SETSPLITPOS(Split2,80)
   BCX_SETSPLITPOS(Split1,25)
 
   '-----------------------------------------------------------------
   '  This should be called if the splitter will follow the form size
   '-----------------------------------------------------------------
   MoveWindow(Form1, 0, 0, 640, 480, TRUE)
 
   '-----------------------------------------------------
   '  Removes CS_VREDRAW and CS_HREDRAW to reduce flicker
   '-----------------------------------------------------
   SetClassLong(Form1,GCL_STYLE,CS_OWNDC)
 
 
   CENTER(Form1)
   SHOW(Form1)
 
   LOCAL lvItem AS LV_ITEM
 
   lvItem.mask = LVIF_TEXT
 
   lvItem.pszText =(LPSTR)"splitter movement"
   ListView_InsertItem(List1, &lvItem)
   lvItem.pszText =(LPSTR)"traditional style"
   ListView_InsertItem(List1, &lvItem)
   lvItem.pszText =(LPSTR)"splitter uses the"
   ListView_InsertItem(List1, &lvItem)
   lvItem.pszText =(LPSTR)"This      --->"
   ListView_InsertItem(List1, &lvItem)
   ListView_SetColumnWidth(List1,0,125)
 
   BCX_SET_TEXT Edit2,"The HORIZONTAL SPLITTER above uses the new splitter bar"
   EDITLOADFILE(Edit1, APPEXEPATH$ + "ColorSplitterDemo.bas")
 
 END SUB
 
 BEGIN EVENTS
   SELECT CASE CBMSG
 
     '---------------------------
     CASE WM_COMMAND
     '---------------------------
     IF HIWORD(wParam) = CBN_SELCHANGE THEN
       DIM RAW cursel = SNDMSG((HWND)lParam,CB_GETCURSEL,0,0)
       IF cursel <> CB_ERR AND cursel < 32 THEN
         IF CBCTL = IDC_ComboFG THEN
           SplitBarFG = QBCOLOR(cursel)
         ELSEIF CBCTL = IDC_ComboBG THEN
           SplitBarBG = QBCOLOR(cursel)
         END IF
         SetFocus(Edit1)
       END IF
     END IF
     IF CBCTL=IDC_Button THEN DestroyWindow(Form1)
 
     '---------------------------
     CASE WM_EXITSIZEMOVE
     '---------------------------
     REFRESH(hWnd)
 
     '---------------------------
     CASE WM_SIZE
     '---------------------------
     DIM RAW rc AS RECT
     DIM STATIC Zoomed
 
     IF wParam <> SIZE_MINIMIZED THEN
       GetClientRect(hWnd, &rc)
       MoveWindow(Split1, 0, 36, rc.right-rc.left,(rc.bottom-rc.top)-36, FALSE)
       IF Zoomed THEN REFRESH(hWnd) : Zoomed = 0
     END IF
     IF wParam = SIZE_MAXIMIZED THEN Zoomed = TRUE
 
   END SELECT
 END EVENTS
 
 SUB MakeColorCombobox(hWnd AS HWND)
   DIM RAW cbei   AS COMBOBOXEXITEM
   DIM RAW g_himl AS HIMAGELIST
   DIM RAW iCnt
 
   SHAREDSET pszText[] AS LPSTR
     " 0 Black",
     " 1 Blue",
     " 2 Green",
     " 3 Cyan",
     " 4 Red",
     " 5 Magenta",
     " 6 Brown",
     " 7 Light Gray",
     " 8 Gray",
     " 9 Light Blue",
     "10 Light Green",
     "11 Light Cyan",
     "12 Light Red",
     "13 Light Magenta",
     "14 Light Yellow",
     "15 Bright White",
     "16 Soft Black",
     "17 Soft Blue",
     "18 Soft Green",
     "19 Soft Cyan",
     "20 Soft Red",
     "21 Soft Magenta",
     "22 Soft Yellow",
     "23 Soft White",
     "24 Soft Gray",
     "25 Soft Light Blue",
     "26 Soft Light Green",
     "27 Soft Light Cyan",
     "28 Soft Light Red",
     "29 Soft Light Magenta",
     "30 Soft Light Yellow",
     "31 Soft Bright White"
     '"User Defined"
   END SET
   g_himl = ImageList_Create(24, 16, ILC_COLOR24|ILC_MASK, 0, 33)
   ' Assign the image list to the ComboBoxEx control
   SNDMSG(hWnd,CBEM_SETIMAGELIST,0,(LPARAM)g_himl)
 
   'Initialize the COMBOBOXEXITEM struct.
   'Set the mask common to all items.
   CLEAR(cbei)
   cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE
   FOR iCnt = 0 TO 31
     ImageList_AddMasked(g_himl, RoundRectBmp(QBCOLOR(iCnt)), RGB(254,0,254))
 
     cbei.iItem          = iCnt
     cbei.pszText        = pszText[iCnt]
     cbei.iImage         = iCnt
     cbei.iSelectedImage = iCnt
 
     IF SNDMSG(hWnd,CBEM_INSERTITEM,0,&cbei) = -1 THEN EXIT FOR
   NEXT
   SNDMSG(hWnd,CB_SETCURSEL,0,0)    'Set Default
 END SUB
 
 
 FUNCTION RoundRectBmp(cl AS COLORREF) AS HBITMAP
   DIM STATIC custbmp AS HBITMAP
   DIM RAW    oldobj  AS HGDIOBJ
   DIM RAW    hdc     AS HDC
   DIM AUTO   bi      AS BITMAPINFO
 
   IF custbmp THEN DeleteObject(custbmp)
 
   bi.bmiHeader.biSize        = SIZEOF(BITMAPINFOHEADER)
   bi.bmiHeader.biWidth       = 24
   bi.bmiHeader.biHeight      = 16
   bi.bmiHeader.biPlanes      = 1
   bi.bmiHeader.biBitCount    = 24
   bi.bmiHeader.biCompression = BI_RGB
 
   hdc     = CreateCompatibleDC(NULL)
   custbmp = CreateDIBSection(hdc, &bi,DIB_RGB_COLORS, NULL, NULL, 0)
   oldobj  = SelectObject(hdc,custbmp)
   'fill with mask color
   BCX_RECTANGLE(0, 0, 0, 24, 16, RGB(254, 0, 254), TRUE, hdc)
 
   'Draw black outline and fill with color
   BCX_ROUNDRECT(0, 0, 2, 24, 14, 4, 2, cl, TRUE, hdc)
   BCX_ROUNDRECT(0, 0, 1, 24, 15, 4, 2, RGB(0,0,0), FALSE, hdc)
 
   SelectObject(hdc,oldobj)
   DeleteDC(hdc)
   FUNCTION = custbmp
 END FUNCTION