News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Toolbar

Started by ragdog, May 12, 2011, 01:40:47 PM

Previous topic - Next topic

ragdog

Hi

I want to change a toolbar button (rebar) i have try to use TB_GETBUTTONINFO (for retrive the idCommand)
and set new ID ,TEXT....
without good result

2 if the button what i change
This works

LOCAL tbb   :TBBUTTON
invoke SendMessage,edi,TB_GETBUTTON,2,ADDR tbb
mov eax,tbb.idCommand
.if eax==10047


But this not

LOCAL tbi :TBBUTTONINFO
                       invoke SendMessage,edi,TB_GETBUTTONINFO,2,ADDR tbi
mov eax,tbi.idCommand
.if eax==10047
       mov tbi.idCommand,9999
                              mov tbi.cbSize, SIZEOF TBBUTTONINFO
                               mov tbi.dwMask, TBIF_TEXT
                               mov tbi.pszText, offset szText
                             invoke SendMessage, edi, TB_SETBUTTONINFO,2, ADDR tbi
.endif


Thanks in forward for all help

dedndave

mov tbi.idCommand,9999
why are you changing the ID ?
are you trying to change the one that's there, or adding a new one ?

ragdog

Quotewhy are you changing the ID ?

one button two function
i try to change the one button to give this button a new id and a new Text

dedndave

well - i don't think that'll work   :P
it thinks you are talking about a button that does not exist

mineiro

Hello Sr ragdog, I played with this one a bit, and I changed the button ID and Text like you sayd in your second post. But to get the ID of another button in TB I used your first aproach.

.data
teste db "testing",00h

.code
;...
LOCAL tbb   :TBBUTTON   ;not used, only if you like to get  ID of another button based in their index
LOCAL tbi:TBBUTTONINFO
LOCAL BIG_BUFFER[256]:BYTE    ;for hold the text of button


.ELSEIF MENSAGEM == WM_COMMAND
mov edx,Wparam
movzx eax,dx
shr edx,16
.if eax == 10047      ;button pressed?

; invoke SendMessage,Manipulador_barra_ferramentas,TB_GETBUTTON,3,ADDR tbb
mov tbi.cbSize,sizeof TBBUTTONINFOA
mov tbi.dwMask,TBIF_COMMAND or TBIF_TEXT
mov tbi.idCommand,10047        ;direct way or read below
mov byte ptr tbi.fsState,TBSTATE_ENABLED
mov  byte ptr tbi.fsStyle, BTNS_BUTTON or BTNS_SHOWTEXT
LEA eax, BIG_BUFFER
mov tbi.pszText, eax
mov tbi.cchText, sizeof BIG_BUFFER
mov tbi.lParam,0
invoke SendMessage,Manipulador_barra_ferramentas,TB_GETBUTTONINFO,10047,addr tbi
; mov eax,tbb.idCommand          ;indirect way, using tbb to fill idCommand
; mov tbi.idCommand,eax
; invoke SendMessage,Manipulador_barra_ferramentas,TB_GETBUTTONINFO,eax,addr tbi
;return the index of button in eax, zero based
mov eax,tbi.idCommand ;save it for future use
mov ecx,tbi.pszText ;save it for future use
mov tbi.idCommand,9999
mov tbi.pszText,offset teste
invoke SendMessage,Manipulador_barra_ferramentas,TB_SETBUTTONINFO,10047,addr tbi
.endif

I used a tool to help me with this one, is "controlspy", you can find it in MS site.

mineiro

I have cleaned the source file posted before to be more compreensive. Atachment follows.


mineiro

Sorry for the multiple posts, I don't know if the attachment file before is lost.
I played more with this one, and you can change the ID of some button in toolbar if you know their index. You can get the index by sending TB_COMMANDTOINDEX.

      invoke SendMessage,hToolBar,TB_SETCMDID,index,newid

The strange thing is that have a message TB_GETBUTTONTEXT but not to set the text, don't have tested wm_settext or thing like this. If have one way, so we don't need to create a structure tbi.

ragdog

Hi sorry that i post to late
i have allready solved

Thanks for your time and works and for this info TB_SETCMDID

Greets,

ragdog

Hi

I have to a exist toolbar a button how can i show a tooltip for this button?


mov tbb.iBitmap,eax
mov eax,IDAddIn
mov tbb.idCommand,eax
mov tbb.fsState,TBSTATE_ENABLED
mov tbb.fsStyle,TBSTYLE_BUTTON + BTNS_SHOWTEXT
mov tbb.dwData,0
mov tbb.iString, CTEXT("ToolTip")


invoke SendMessage,hTbrView,TB_BUTTONSTRUCTSIZE,sizeof TBBUTTON,0
invoke SendMessage,hTbrView,TB_INSERTBUTTON,-1,addr tbb

mineiro

You need answer the WM_NOTIFY, and check to see if the notification is TTN_NEEDTEXT.
In the previous posted example, the ID of button in toolbar is equal of ID of the string in resource (stringtable), this is why I have used only ecx.

.data
testing db "testing",00h

.code
.ELSEIF MESSAGE == WM_NOTIFY
mov ebx,ParamL
mov eax,[ebx].NMHDR.code
.IF eax == TTN_NEEDTEXT  ;so we must show some tooltip text
mov ecx,[ebx].NMHDR.idFrom  ;what button is sending this message to us?
.IF ecx == ID_of_some_button
mov ebx,ParamL
mov eax,offset testing  ;a offset to our new tooltip string
mov [ebx].TOOLTIPTEXT.lpszText,eax
.endif
mov eax,FALSE
ret
.endif

After you have created the ToolBar, you can send a message to set the delay time of the tooltip.

invoke SendMessage,handle_of_toolbar,TTM_SETDELAYTIME,TTDT_INITIAL,0
invoke SendMessage,handle_of_toolbar,TTM_SETDELAYTIME,TTDT_RESHOW,0

ragdog

Ok thanks :U

I have thinking that works without a Notify messages ::)

mineiro

I have done some tests in the previous posted example; removed the TBSTYLE_TOOLTIPS of toolbar, and removed the WM_NOTIFY message from code, and have tried to show an tooltip when I pass mouse over the toolbar and worked Sr ragdog.

.data
TooltipClassName db "Tooltips_class32",0
tip TOOLINFO <>
handle_ti dd ?
.code
;insert after your create the toolbar
invoke CreateWindowEx,WS_EX_TOPMOST,offset TooltipClassName,0,WS_POPUP or TTS_ALWAYSTIP or TS_BALLOON ,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hWnd,0,Instance,0
mov handle_ti,eax
mov tip.cbSize, sizeof TOOLINFO
push hWnd
pop tip.hWnd
mov tip.uFlags, TTF_IDISHWND or TTF_SUBCLASS
push handle_of_toolbar
pop tip.uId
mov tip.lpszText,offset sometext
mov tip.lParam,0
invoke GetClientRect,handle_of_toolbar,addr tip.rect    ;deal with this rect struct or put another message here to get the size of each button
invoke SendMessage,handle_ti,TTM_ADDTOOL,0,addr tip
invoke SendMessage,handle_of_toolbar,TB_SETTOOLTIPS,handle_ti,0

well, only to rectify, in previous post I commented:
   invoke SendMessage,handle_of_toolbar,TTM_SETDELAYTIME,TTDT_INITIAL,0
In true is not the handle_of_toolbar, is the handle_of_tooltip.

ragdog

Thanks mineiro

I have this solved with your solution an WM_Notify
This is ok for me