I am trying to build a TOOLBAR with several standard buttons & several buttons I have
built. I am using the format in EXAMBLE1/COMMCTRLS. I have no problem drawing the
standard buttons. I have loaded my BITMAP and obtained its handle. If I modify the
CreateToolbarEx hBMInst argument to 0 and the wBMID to that handle I can load my
button. I cannot seem to do both, I have tried to make hBMInst & wBMID arguments 0 in
the CreateToolbarEx call & use the TBA structure. Once again it works OK for the standard
but when I try to make both those fields 0/handle I merely get a blank button.
Any help would be appreciated
Posted on 2004-01-12 15:21:23 by bobr_bak
Maybe post some code and we will be able to help a bit better. Did you add the new bitmap to the available button images on the toolbar using TB_ADDBITMAP ?
Posted on 2004-01-12 15:36:54 by donkey
Here's my code to build a toolbar & place a standard button in it. It works great!
INVOKE CreateToolbarEx,hWnd,WS_CHILD OR WS_VISIBLE,300,1,0,0,ADDR TBB,1,16,16,16,\
16,SIZEOF TBB
MOV HTB,EAX
INVOKE ShowWindow,HTB,SW_SHOW
MOV TBA.hInst,HINST_CMCTRL
MOV TBA.nID,IDB_STD_SMALL_COLOR
INVOKE SendMessage,HTB,TB_ADDBTMAP,1,ADDR TBA
MOV TBB.iBitmap,STD_FLEOPEN
MOV TBB.fsStyle,TBSTYLE_BUTTON
MOV TBB.fsState,TBSTATE_ENABLED
MOV TBB.idCommand,IDM_OPEN
INVOKE SendMessage,HTB,TB_ADDBUTTONS,1,ADDR TBB
Then when I try to add my own (I loaded the bitmap via LoadBitmap & its handle is HTBB)
MOV TBA.hInst,0
MOV EAX,HTBB
MOV TBA.nID,EAX
INVOKE SendMessage,HTB,TB_ADDBITMAP,1,ADDR TBA
MOV TBB.iBitmap,1
INVOKE SendMessage,HTB,TB_ADDBUTTONS,1,ADDR TBB
I get a button, but it is a standard button (if iBitmap is 1 it is STD_CUT ETC
Once again any help will be appreciated
Posted on 2004-01-13 15:11:12 by bobr_bak
Well, I can't help with CreateToolbarEx, I use CreateWindowEx for all controls but I can show you how I normally add images to a toolbar. I don't like the way Windows loads bitmaps for a toolbar so I usually end up doing it myself as a DIB section, that gives me control over things like transparency etc.. It was in order to be able to easily generate images for this type of loading that I wrote Toolbar Paint in the first place. I have never been satisfied with the default behavior of TB_ADDBITMAP.

;Set toolbar struct size

invoke SendMessage,hToolBar,TB_BUTTONSTRUCTSIZE,sizeof TBBUTTON,0

; Make sure the toolbar button images are transparent so load them separately
; 24 = height of image
; 256 = max buttons in iml (not the number in the image that is auto-calculated)
; 0 = transparency color (black in this case)
invoke ImageList_LoadImage, hInstance, IDR_TBBITMAP, 24, 256, 0, \
IMAGE_BITMAP, LR_CREATEDIBSECTION
push eax
invoke ImageList_SetBkColor,eax,CLR_NONE
pop eax
invoke SendMessage,hToolBar,TB_SETIMAGELIST,0,eax

invoke SendMessage,hToolBar,TB_SETINDENT,8,0
;Set toolbar buttons
invoke SendMessage,hToolBar, TB_ADDBUTTONS, nDisplayBtns, addr tbrbtns
Posted on 2004-01-13 15:46:39 by donkey