standard pb toolbar with radio and toggle buttons
Posted: Mon Mar 29, 2004 2:35 pm
you have to adapt the following a little, but it shows the concept:
now just create a normal toolbar and add buttons... parameters are samples, replace as needed
i'll add a complete working example if anyone wants it
Code: Select all
Structure TBBUTTONINFO
cbSize.l
dwMask.l
idCommand.l
iImage.l
fsState.b
fsStyle.b
cx.w
lParam.l
pszText.l
cchText.l
EndStructure
;
#TBIF_IMAGE = $01
#TBIF_TEXT = $02
#TBIF_STATE = $04
#TBIF_STYLE = $08
#TBIF_LPARAM = $10
#TBIF_COMMAND = $20
#TBIF_SIZE = $40
#TB_SETBUTTONINFOA = 1024+66
Procedure x_toolbartogglebutton(toolbar_h.l, buttonid.l, image_h.l, state.l)
;
; *** add a toggle (check) button to a toolbar
;
; in: toolbar_h.l - handle of the toolbar
; buttonid.l - buttonid and message send when pressed
; image_h.l - windows handle of image
; state.l - 0 not pressed 1 pressed
; retval: none
; out: none
;
; it's a bit of a kludge :-) first add a regular button
;
ToolBarImageButton(buttonid,image_h)
;
; then use sendmessage_() to change its type and status
;
buttoninfo.TBBUTTONINFO
buttoninfo\cbSize = SizeOf(buttoninfo)
buttoninfo\dwMask = #TBIF_STYLE
buttoninfo\fsStyle = #TBSTYLE_CHECK
SendMessage_(toolbar_h, #TB_SETBUTTONINFOA, buttonid, @buttoninfo)
SendMessage_(toolbar_h, #TB_CHECKBUTTON, buttonid, state)
EndProcedure
Procedure x_toolbarradiobutton(toolbar_h.l, buttonid.l, image_h.l, state.l)
;
; *** add a radio button (group) to a toolbar
;
; see x_toolbarcheckbutton
;
ToolBarImageButton(buttonid,image_h)
buttoninfo.TBBUTTONINFO
buttoninfo\cbSize = SizeOf(buttoninfo)
buttoninfo\dwMask = #TBIF_STYLE
buttoninfo\fsStyle = #TBSTYLE_CHECKGROUP
SendMessage_(toolbar_h, #TB_SETBUTTONINFOA, buttonid, @buttoninfo)
SendMessage_(toolbar_h, #TB_CHECKBUTTON, buttonid, state)
EndProcedure
Code: Select all
tb_main_h = CreateToolBar(#w_main,w_main_whnd)
x_toolbarradiobutton(tb_main_h,#m_main_refresh_0_1,i_icon_0_1_h,0)
x_toolbarradiobutton(tb_main_h,#m_main_refresh_1,i_icon_1_h,1)
x_toolbarradiobutton(tb_main_h,#m_main_refresh_10,i_icon_10_h,0)
x_toolbarradiobutton(tb_main_h,#m_main_refresh_60,i_icon_60_h,0)
ToolBarSeparator()
x_toolbartogglebutton(tb_main_h,#m_main_refresh_no_scroll,i_icon_no_scroll_h,0)
ToolBarImageButton(#m_main_refresh_refresh,i_icon_refresh_h)
ToolBarSeparator()
ToolBarImageButton(#m_main_file_quit,i_icon_exit_h)