MFC 功能包 - 添加新工具栏后工具栏加载在错误位置

发布于 2024-12-14 14:35:20 字数 658 浏览 5 评论 0原文

我有一个 MFC 功能包应用程序,其中包含多个工具栏 (CMFCToolbar),其位置在会话之间保存。

现在,我添加了一个新工具栏,并将一些按钮从其他工具栏移至新工具栏。

问题是,现在,当我第一次打开我的应用程序时,所有工具栏都显得严重错位(一个在菜单栏上,太多行等)。如果我移动它们并关闭应用程序,状态将在下一个会话中正确保存和检索。

我单步执行了代码,发现如果我在 CFrameImpl::OnLoadFrame() 中跳过对 CWinAppEx::LoadState() 的调用,则条形图将位于其“初始位置”,即它们在全新安装中出现的位置。因此,新的工具栏或从现有工具栏中删除按钮会干扰状态的负载。

那么关于如何正确加载状态有什么想法吗?或者如何防止仅在第一次执行时调用 LoadState()


注意:我认为这个问题可能与我的另一个未回答的问题类似:MFC 功能包 - 如何在不删除用户自定义的情况下添加加速器

I have an MFC Feature Pack app with several toolbars (CMFCToolbar) whose positions are saved between sessions.

Now I've added a new toolbar, and I've moved some buttons from other toolbars to the new one.

The problem is that now, when I first open my app, all the toolbars appear badly misplaced (one over the menu bar, too many rows, etc). If I move them and close the application the state is correctly saved and retrieved in the next session.

I've stepped through the code and found that If I skip the call to CWinAppEx::LoadState() in CFrameImpl::OnLoadFrame() the bars are positioned at their "initial position", i.e. where they would appear in a fresh install. So the new toolbar, or the deleting of buttons from existing ones, is interfering with the load of the state.

So any ideas on how to load the state correctly? Or how to prevent the call to LoadState() only in the first execution?


Note: I think the problem might be similar to this other unanswered question of mine: MFC Feature Pack - How to add accelerators without deleting user's customization

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文