BCX_TOOLBAR function
Purpose: BCX_TOOLBAR
creates a toolbar control.
Syntax: hCtl = BCX_TOOLBAR(hWndParent, _ CtlID%, _ NumBtns%, _ Text$, _ BtnStyles, _ HBITMAP, _ ImgIndex, _ BtnWidth , _ BtnHeight, _ [, WinStyle%] _ [,Exstyle%]) Parameters:
|
Remarks:
BCX_TOOLBAR
can use either a bitmap or imagelist.
This is detected automatically. This makes it easier to use highcolor images
and allows using an imagelist with any number of images. Loading a list is easy as:
CONST GetImageListFile(A,B) = ImageList_LoadImage(NULL, _ A, _ B, _ 0, _ RGB(255, 0, 255), _ IMAGE_BITMAP, _ LR_CREATEDIBSECTION|LR_LOADFROMFILE)
The RGB value is what ever color you want to be transparent.
DIM RAW Imlist AS HIMAGELIST Imlist = GetImageListFile("FileName.bmp",32) '"filename", width of image
To make it easier to place separators in a toolbar that only contain bitmaps you can insert a minus sign as te first character to suppress the text labels but still insert separators, for example,
tbText$ = "-OPEN|SAVE||NEW||EXIT"
Example 1: The minimal needed for a standard button bar with text labels
HWND = BCX_TOOLBAR(HWND,ID,4,"OPEN|SAVE|SETUP|QUIT")
Example 2: The minimal needed for a standard button bar with text labels and built in windows icons.
tbText$ = "||Open|Save||New|Options|About||Exit" SET ImIdx[] STD_FILEOPEN, _ STD_FILESAVE, _ STD_COPY, _ STD_FILENEW, _ STD_HELP, _ STD_DELETE, _ IDB_STD_SMALL_COLOR END SET HWND = BCX_TOOLBAR(Form1, ID, 6, tbText$, 0, HINST_COMMCTRL, ImIdx)
Example 3: Here is a complete example using the BCX_TOOLBAR
function.
'Toolbar control for BCX by Mike Henning Dec 2004 'Modified for the BCX Help file by P.Kort. $BCXVERSION "5.05.06" $TURBO 256 GUI "BcxToolbar", PIXELS GLOBAL Form1 AS HWND GLOBAL hToolBar AS HWND ENUM ID_Form1 ID_Toolbar END ENUM SET ImIdx[] STD_FILEOPEN, _ STD_FILESAVE, _ STD_COPY, _ STD_FILENEW, _ STD_HELP, _ STD_DELETE, _ IDB_STD_SMALL_COLOR END SET '----------------------------------------------------------------------------- SUB FORMLOAD RAW tbText$ tbText$ = "||Open|Save|Copy|New|About|Delete" Form1 = BCX_FORM("BCX Toolbar demo", 53, 43, 800, 600) hToolBar = BCX_TOOLBAR(Form1, ID_Toolbar, 6, tbText$, 0, HINST_COMMCTRL, ImIdx) MoveWindow(Form1, 0, 0, 600, 400, TRUE) SetClassLong(Form1, GCL_STYLE, CS_OWNDC) CENTER(Form1) ShowWindow(Form1, SW_SHOW) END SUB '----------------------------------------------------------------------------- BEGIN EVENTS SELECT CASE CBMSG '--------------------------- CASE WM_EXITSIZEMOVE '--------------------------- REFRESH(hWnd) '--------------------------- CASE WM_SIZE '--------------------------- IF wParam <> SIZE_MINIMIZED THEN SendMessage(hToolBar, Msg, wParam, lParam) END IF CASE WM_COMMAND IF CBCTL = ID_Toolbar + 1 THEN 'open MSGBOX "No : 1", "1", MB_ICONINFORMATION END IF IF CBCTL = ID_Toolbar + 4 THEN 'New MSGBOX "No : 4","New", MB_ICONINFORMATION END IF IF CBCTL = ID_Toolbar + 5 THEN 'About MSGBOX "No : 5","About", MB_ICONINFORMATION END IF CASE WM_CLOSE DestroyWindow(Form1) EXIT FUNCTION END SELECT END EVENTS