Visual Studio MFC 工具栏编辑器图标顺序不会更新
我一直在尝试在 Visual Studio 2010 的 MFC 项目中创建自定义工具栏。我一直在遵循 Ivan Horton 的 Beginning Visual C++ 2010 中的 Sketcher 教程。我遇到的问题是工具栏不更新以反映我创建的图标的顺序和间距。
我创建了一个小屏幕截图来演示该问题:
后台是 Visual Studio 工具栏编辑器,其中包含我所需的工具栏配置。前台是实际的应用程序,它不反映我设计的图标的间距或顺序。它确实反映了添加的新图标,并且图标工作正常,但我似乎无法让它们重新排序或适当地间隔它们自己。它们只是按照我创建它们的顺序附加到末尾。
我尝试过重新启动 VS 和 Windows 的基本技术,但没有成功。
有什么技巧可以让它玩得很好吗?如果缺少的话,是否有地方可以手动查看或编辑工具栏编辑器生成的代码?
I've been trying to create a custom toolbar in a MFC project in Visual Studio 2010. I've been following the Sketcher tutorial in Ivan Horton's Beginning Visual C++ 2010. The problem I'm running into is that the toolbar doesn't update to reflect the order and spacing of icons I have created.
I've created a small screenshot to demonstrate the problem:
In the background is the visual studio toolbar editor with my desired toolbar configuration. In the foreground is the actual app, which does not reflect the spacing or order of icons I've designed. It does reflect NEW icons being added, and the icons work fine, but I just can't seem to get them to re-order or appropriately space themselves. They just append to the end in whatever order I create them.
I've tried the rudimentary techniques of restarting both VS and windows, but to no avail.
Any tips on getting it to play nicely? Lacking that, is there somewhere to manually view or edit the code generated by the toolbar editor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于初学者来说,如果您在 VS.NET 2005 中创建 MFC SDI/MDI 项目,则不存在此类问题。它发生在 VS.NET 2008 和 2010 中。
事实上,您对标准工具栏的重新排列确实生效。它只是没有向您显示默认状态。恢复状态:点击工具栏末尾的小箭头按钮->添加或删除按钮 ->标准->重置工具栏。
虽然我不是 100% 确定为什么会发生这样的情况(像这样的设计或错误),但有一种方法可以解决它并且它有效:
将以下代码添加到
CMainFrame::LoadFrame(. ..)
我建议您联系 Microsoft 支持工程师,因为网络上的资源很少。
For starters, if you create an MFC SDI/MDI project in VS.NET 2005, there is no such issue. It happens in VS.NET 2008 and 2010.
In fact, your rearrangement of the standard toolbar does takes effect. It's just not showing you the default state. To restore the state: click the small arrow button at the end of toolbar -> Add or Remove Buttons -> Standard -> Reset Toolbar.
Though I'm not 100% sure why it happens like this(design like this or a bug), there is a way to work around it and it works:
Add following code to the end of
CMainFrame::LoadFrame(...)
I recommend you to contact Microsoft support engineers as there's little resource on the web.
原因可能是每当应用程序启动时工具栏状态就已经从注册表加载。因此框架读取工具栏状态并将新按钮添加到末尾。您的注册表中是否有工作区密钥,并且您是否在对工具栏进行更改时尝试将其删除?密钥应位于 HKEY_CURRENT_USER\Software\MyCompany\MyApp\Workspace 等位置。MyCompany
和 MyApp 的值通常在 InitInstance 中设置。始终调用 RestoreOriginalState() 会破坏代码以允许用户修改工具栏。
The reason could be that the toolbar state is already loaded from the registry whenever your application starts. So the framework reads the toolbar state and adds the new buttons to the end. Is there a Workspace key in your Registry and did you try to delete it anytime you make changes to the toolbar? The key should be at a location like HKEY_CURRENT_USER\Software\MyCompany\MyApp\Workspace
The values for MyCompany and MyApp are usually set in InitInstance. Always calling RestoreOriginalState() would break the code to allow user modifications to the toolbar.