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:
|
Example:
$BCXVERSION
"5.08"
GUI
"ColorSplitterDemo"
,PIXELS
ENUM
IDC_Edit1=
50
IDC_Edit2 IDC_List1 IDC_Split1 IDC_Split2 IDC_Button IDC_ComboFG IDC_ComboBGEND
ENUM
CONST
ComboStyle=
WS_BORDER | WS_TABSTOP |WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLISTGLOBAL
Form1AS
HWNDGLOBAL
Edit1AS
CONTROLGLOBAL
Edit2AS
CONTROLGLOBAL
List1AS
CONTROLGLOBAL
Split1AS
CONTROLGLOBAL
Split2AS
CONTROLGLOBAL
ButtonAS
CONTROLGLOBAL
ComboExFGAS
CONTROLGLOBAL
ComboExBGAS
CONTROLSUB
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
lvItemAS
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_SELCHANGETHEN
DIM
RAW
cursel=
SNDMSG(
(
HWND)
lParam,CB_GETCURSEL,0
,0
)
IF
cursel <> CB_ERRAND
cursel <32
THEN
IF
CBCTL
=
IDC_ComboFGTHEN
SplitBarFG
=
QBCOLOR
(
cursel)
ELSEIF
CBCTL
=
IDC_ComboBGTHEN
SplitBarBG
=
QBCOLOR
(
cursel)
END
IF
SetFocus(
Edit1)
END
IF
END
IF
IF
CBCTL=
IDC_ButtonTHEN
DestroyWindow(
Form1)
'---------------------------
CASE
WM_EXITSIZEMOVE'---------------------------
REFRESH(
hWnd)
'---------------------------
CASE
WM_SIZE'---------------------------
DIM
RAW
rcAS
RECTDIM
STATIC ZoomedIF
wParam <> SIZE_MINIMIZEDTHEN
GetClientRect(
hWnd,&
rc)
MoveWindow(
Split1,0
,36
, rc.right-
rc.left,(
rc.bottom-
rc.top)
-
36
, FALSE)
IF
ZoomedTHEN
REFRESH(
hWnd)
: Zoomed=
0
END
IF
IF
wParam=
SIZE_MAXIMIZEDTHEN
Zoomed=
TRUEEND
SELECT
END
EVENTS
SUB
MakeColorCombobox(
hWndAS
HWND)
DIM
RAW
cbeiAS
COMBOBOXEXITEMDIM
RAW
g_himlAS
HIMAGELISTDIM
RAW
iCntSHAREDSET
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_SELECTEDIMAGEFOR
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=
iCntIF
SNDMSG(
hWnd,CBEM_INSERTITEM,0
,&
cbei)
=
-
1
THEN
EXIT
FOR
NEXT
SNDMSG(
hWnd,CB_SETCURSEL,0
,0
)
'Set Default
END
SUB
FUNCTION
RoundRectBmp(
clAS
COLORREF)
AS
HBITMAPDIM
STATIC custbmpAS
HBITMAPDIM
RAW
oldobjAS
HGDIOBJDIM
RAW
hdcAS
HDCDIM
AUTO
biAS
BITMAPINFOIF
custbmpTHEN
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
=
custbmpEND
FUNCTION