hi all,

I am stuck at the point where I want to change a button's bitmap in a toolbar or I want to change any button's bitmap on the fly, I tried TB_CHANGEBITMAP to do that, but it failed,, maybe coz I set 2 imagelist, 1 for normal( or off state) and 1 for hot state.

not quite sure what I did wrong, maybe the coding part I did something wrong.....

:stupid:


does any have a clue how to change a bitmap in a toolbar on the fly???


thankx in adv,
Posted on 2003-01-11 04:18:32 by Yanda
anyone here available to help me yet?:o
Posted on 2003-01-11 11:35:10 by Yanda
Show your TB_CHANGEBUTTON code.
Posted on 2003-01-11 12:00:54 by comrade
sorry about that :(

what I want to do is that I create only 1 button in the toolbar and I want to make it act as 2 buttons.

like: it initialized as a Connect button with a connect image from the image list, but after I clicked on it, it than change to a disconnect button with a disconnect image from the image list.

I want to make it do exactly like the connect and disconnect button in mIRC's toolbar :grin:


here is the code:

........................
.ELSEIF (uMsg==WM_CREATE)
.....................

;after created the toolbar, set the normal and over image

;set the normal image
invoke SendMessage, hChildToolBar1, TB_SETIMAGELIST, 0, hImageList
;set the mouse over image
invoke SendMessage, hChildToolBar1, TB_SETHOTIMAGELIST, 0, hImageHotList

;only one button in the toolbar, but act as two,
;this button has two id, below WM_COMMAND code show how I did it

mov tbb.iBitmap, 0
;this button first initialized as a Connect button
mov tbb.idCommand, ID_CONNECT
mov tbb.fsStyle, TBSTYLE_BUTTON
invoke SendMessage, hToolBar, TB_ADDBUTTONS, 1, ADDR tbb
.ELSEIF (uMsg==WM_COMMAND)
mov eax, wParam
.IF (eax==ID_CONNECT)
xcall MessageBox, NULL, "changed id to ID_DISCONNECT with disconnect image", "toolbar", MB_OK+MB_ICONERROR
; not sure if I did this call correctly
invoke SendMessage, hToolBar, TB_CHANGEBITMAP, ID_CONNECT, 1

;change the button id to ID_DISCONNECT so it act as a disconnect button
; 0 is the index of first button in toolbar, and the only one
invoke SendMessage, hToolBar, TB_SETCMDID, 0, ID_DISCONNECT
.ELSEIF (eax==ID_DISCONNECT)
xcall MessageBox, NULL, "changed id to iD_CONNECT with connect image", "toolbar", MB_OK+MB_ICONERROR
;not sure if I did this call correctly also
invoke SendMessage, hToolBar, TB_CHANGEBITMAP, ID_DISCONNECT, 0

;change the button id to ID_CONNECT so it act as a connect button
; 0 is the index of first button in toolbar, and the only one
invoke SendMessage, hToolBar, TB_SETCMDID, 0, ID_CONNECT
.ENDIF
...............
Posted on 2003-01-12 01:18:01 by Yanda
........................

.ELSEIF (uMsg==WM_CREATE)
.....................

;after created the toolbar, set the normal and over image

;set the normal image
invoke SendMessage, hChildToolBar1, TB_SETIMAGELIST, 0, hImageList
;set the mouse over image
invoke SendMessage, hChildToolBar1, TB_SETHOTIMAGELIST, 0, hImageHotList

;only one button in the toolbar, but act as two,
;this button has two id, below WM_COMMAND code show how I did it

mov tbb.iBitmap, 0
;this button first initialized as a Connect button
mov tbb.idCommand, ID_CONNECT
mov tbb.fsStyle, TBSTYLE_BUTTON
invoke SendMessage, hToolBar, TB_ADDBUTTONS, 1, ADDR tbb
.ELSEIF (uMsg==WM_COMMAND)
mov eax, wParam
.IF (eax==ID_CONNECT)
xcall MessageBox, NULL, "changed id to ID_DISCONNECT with disconnect image", "toolbar", MB_OK+MB_ICONERROR
;change the button id to ID_DISCONNECT so it act as a disconnect button
; 0 is the index of first button in toolbar, and the only one
invoke SendMessage, hToolBar, TB_SETCMDID, 0, ID_DISCONNECT

; not sure if I did this call correctly
invoke SendMessage, hToolBar, TB_CHANGEBITMAP, ID_DISCONNECT, 1

.ELSEIF (eax==ID_DISCONNECT)
xcall MessageBox, NULL, "changed id to iD_CONNECT with connect image", "toolbar", MB_OK+MB_ICONERROR

;change the button id to ID_CONNECT so it act as a connect button
; 0 is the index of first button in toolbar, and the only one
invoke SendMessage, hToolBar, TB_SETCMDID, 0, ID_CONNECT

;not sure if I did this call correctly also
invoke SendMessage, hToolBar, TB_CHANGEBITMAP, ID_CONNECT, 0
.ENDIF
Posted on 2003-01-12 01:27:19 by comrade
hi comrade,

thankx alots, I finally find out where my problem is,, is local var, I declare the htoolbar handle in the stack,, thats y I couldn't get it work :(

I always fall for this trick :(



thankx alots anyways!:alright: :stupid:
Posted on 2003-01-12 03:31:06 by Yanda