如何在win32中更改工具栏按钮的位图?

发布于 2024-08-29 05:20:45 字数 412 浏览 5 评论 0原文

我在窗口中使用 ReBar 创建了一个带有一些控件的工具栏。谁能告诉我,

  1. 如果我(仅)知道它的 ID,如何获取 buttons/combobox/etc (不是窗口中的普通按钮)的 HWND ?
  2. 如果我知道资源的 id,如何获取 HBITMAP?
  3. 如何将位图设置到控制器?

    SendDlgItemMessageW(hWnd, nId, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);

这不适用于工具栏,不是吗?我找不到办法,请帮助我。谢谢...

问候

编辑: 请问有人吗? :(

编辑: 好的。看来这几天大家都很忙。 :( 顺便说一句,这是一个错误的问题吗?

I have created a toolbar with some controls on it using ReBar within a window. Can anyone please tell me,

  1. How to get the HWND of a buttons/combobox/etc (not normal buttons in a window) if I know (only) the Id of it ?
  2. How to obtain the HBITMAP if I know the id of the resource ?
  3. How to set the bitmap to the controller ?

    SendDlgItemMessageW(hWnd, nId, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);

This isn't working for toolbars, isn't it ? I couldn't find a way to do it, please help me. Thank you...

Regards

EDIT:
Anyone please ? :(

EDIT:
Ok. it seems everyone is busy these days. :( Btw, is it a wrong question ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

万劫不复 2024-09-05 05:20:45

您可以下载 ControlSpy 并在那里尝试来感受一下。
我检查了 Rebar,发现 RB_SETBANDINFO(在 Messages 下)可能就是您正在寻找的内容。

You could download ControlSpy and try it in there to get a feel for it.
I checked the Rebar and saw that RB_SETBANDINFO (under Messages) could be what you are looking for.

失眠症患者 2024-09-05 05:20:45

GetDlgItem 与 Rebar 的效果一样好就像对话框一样。

您可以将 GetDlgItem 函数用于任何父子窗口对,而不仅仅是对话框。只要hDlg参数指定了父窗口并且子窗口具有唯一标识符(由创建子窗口的CreateWindow或CreateWindowEx函数中的hMenu参数指定),GetDlgItem就会返回子窗口的有效句柄。 p>

您可以使用 LoadImage 从资源加载位图并返回 HBITMAP。

最后,SendMessage(hWndButton, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hBitmap);

GetDlgItem will work just as well with a Rebar as it does with a Dialog.

You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes. As long as the hDlg parameter specifies a parent window and the child window has a unique identifier (as specified by the hMenu parameter in the CreateWindow or CreateWindowEx function that created the child window), GetDlgItem returns a valid handle to the child window.

You can use LoadImage to load a bitmap from a resource and return the HBITMAP.

Finally, SendMessage(hWndButton, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hBitmap);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文