TB_GETBUTTON does not populate tooltip button information struct
See original GitHub issueHi, I have created a Windows Forms application with a toolbar component which has 3 buttons. I would like to use SendMessage with TB_GETBUTTON message to fetch the first button information. Here is my code:
var tb = new ComCtl32.TBBUTTON();
var buttonCount = User32.SendMessage(mainToolbar.Handle, (uint)ComCtl32.ToolbarMessage.TB_BUTTONCOUNT, (IntPtr)0, 0);
var getButton = User32.SendMessage(mainToolbar.Handle, ComCtl32.ToolbarMessage.TB_GETBUTTON, 0, ref tb);
lblButtonCount.Text = buttonCount.ToString();
lblSuccess.Text = (getButton.ToInt32() != 0).ToString();
lblDWData.Text = tb.dwData.ToString();
lblFSStyle.Text = tb.fsStyle.ToString();
lblFSState.Text = tb.fsState.ToString();
lbliBitmap.Text = tb.iBitmap.ToString();
When I observe tb struct. all properties are zero and have not been populated even though getButton variable is 1 which means success.
The output looks like this:
I created my own class (in naïve implementation) that looks like this:
public sealed class Win32
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public extern static int SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public extern static unsafe int SendMessage(IntPtr hwnd, int msg, int wParam, void* lParam);
}
And when I use this class in the same form like this:
var tb = new ComCtl32.TBBUTTON();
var buttonCount = Win32.SendMessage(mainToolbar.Handle, (int)ComCtl32.ToolbarMessage.TB_BUTTONCOUNT, 0, 0);
unsafe
{
var getButton = Win32.SendMessage(mainToolbar.Handle, (int)ComCtl32.ToolbarMessage.TB_GETBUTTON, 0, &tb);
lblButtonCount.Text = buttonCount.ToString();
lblSuccess.Text = (getButton != 0).ToString();
lblDWData.Text = tb.dwData.ToString();
lblFSStyle.Text = tb.fsStyle.ToString();
lblFSState.Text = tb.fsState.ToString();
lbliBitmap.Text = tb.iBitmap.ToString();
}
It is populating the struct correctly:
Am I missing anything here? Thanks.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
TBBUTTON struct not working with SendMessage
I thought you had a means of accessing the button once you had the name. After a quick review, it appears that you...
Read more >How to Display Tooltips for Buttons - Win32 apps
Set the tooltip text as the iString member of the TBBUTTON structure for each button. You must also send a TB_SETMAXTEXTROWS message and...
Read more >How to Setup a Tooltip page link to a Button inste...
Solved: Hi, I have a requirement where i need to display a Tooltip page which contains info on the page that is being...
Read more >Tooltip stuck when surrounding a disabled button #231
I think it's related to disabled buttons not firing mouse events. As a workaround you can wrap the button with an other element....
Read more >Tooltips · Bootstrap v5.0
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-bs-attributes for local title ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Found the problem. I’ve committed the fix and it will go out in the next week into NuGet and within minutes on AppVeyor.
Thanks. I’ll look at the zip and what’s changed since 3.2.21.