使用新位图修改 CreateToolbarEx 函数时的内存分配问题
我正在尝试修改一些使用 CreateToolbarEx 函数的旧代码(c++),试图使用新的位图并将我们的 24x24 像素工具栏按钮替换为更华丽的 36x36 按钮。我正在使用的函数如下:
m_hToolbarWnd = CreateToolbarEx(m_hPagerWnd, ws, ID_TOOLBAR, NUMBERTOOLBARBITMAPS, hInst, IDB_TOOLBAR, tbInitButtons, m_ncButtons, 24, 24, 24, 24, sizeof(TBBUTTON));
我可以通过将“24”更改为“36”来扩展当前工具栏按钮的大小,但是如果我将 IDB_TOOLBAR 更改为新的工具栏位图并运行程序,我会遇到指向 CreateToolbarEx 函数的内存访问读取冲突。我是否遗漏了有关位图如何获取内存分配或创建单个按钮的信息?新工具栏的尺寸为 1584x36 像素(44 个按钮)。
I'm trying to modify some old code (c++) that uses the CreateToolbarEx function, in an attempt to use a new bitmap and replace our 24x24 pixel toolbar buttons with flashier 36x36 ones. The function I'm using is as follows:
m_hToolbarWnd = CreateToolbarEx(m_hPagerWnd, ws, ID_TOOLBAR, NUMBERTOOLBARBITMAPS, hInst, IDB_TOOLBAR, tbInitButtons, m_ncButtons, 24, 24, 24, 24, sizeof(TBBUTTON));
I'm able to expand the size of the current toolbar buttons by changing the '24's to '36', but if I change IDB_TOOLBAR to the new toolbar bitmap and run the program I hit a memory access read violation pointing to the CreateToolbarEx function. Am I missing something on how the bitmap is getting its memory allocation or creating the individual buttons? The new toolbar is 1584x36 pixels (44 buttons).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是旧的,但希望我找到的解决方案能够帮助别人。我忽略了一个事实,即我正在从 16 位颜色位图更改为 24 位,而我无法让 CreateToolbarEx 来处理这一点。相反,我必须调用 CreateWindowEx 并为其创建和设置图标 ImageList。工作代码:
This is old, but hopefully the solution I found will help someone. I had overlooked the fact that I was changing from a 16-bit color bitmap to 24-bit, which I was unable to get CreateToolbarEx to handle. Instead, I had to call CreateWindowEx and create and set the icon ImageList for it. Working code: