在 CChildFrame 中创建的可停靠窗格在应用程序第二次运行时不可见。开始
我在 CChildFrame::OnCreate() 中创建了一些可停靠窗格 我第一次启动应用程序时会显示它们。 我第二次启动应用程序时,它们被创建,但分割窗口完全靠在客户端区域的侧面(底部和右侧),因此不可见。因此,我必须使用鼠标将分离器拉入客户区域,以便可停靠窗口再次可见。 如果我在我的应用程序中执行“文件”->“新建”,则会创建一个新的客户端窗口,并按应有的方式显示可停靠窗口。我认为这与在注册表中保存窗口布局有关,因为如果我更改 SetRegistryKey(_T("61sakjgsajkdg"));在我的应用程序的 CWinApp 派生类中。并重新运行,它们会在第一次时再次显示。 (但不是我第二次重新启动应用程序)。 如果我重新启动我的应用程序,如何保存这些可停靠窗口的布局。他们是可见的?否则我该如何阻止我的应用程序。用之前保存的布局覆盖窗口布局。与 LoadCustomState() 和 SaveCustomState() 有关吗?我找不到有关如何实现这些方法的任何信息。我在这里有一个演示项目的链接来演示我的意思:
http:// /www.4shared.com/file/237193472/c384f0f6/GUI60.html
有人可以告诉我如何在应用程序第二次启动时在我的 CChildFrame 类中显示这些可停靠窗口吗?
I have created some dockable panes in CChildFrame::OnCreate()
The first time i start the application they are shown.
The second time i start the application they are created but the splitterwindows are completly against the sides of the clients area (bottom and right), so not visible. So i have to use the mouse to pull the splitters into the clientarea so that the dockable windows become visible again.
If i do File->New in my app a new client window is created and showing the dockable windows as they should be. I Think this has something to do with saving the windows layout in the registry, because if i change SetRegistryKey(_T("61sakjgsajkdg")); in the CWinApp derived class of my app. and rerun they are shown again the first time. (but not the second time i restart the app).
How can i save the layout of those dockable windows as well, so if i restart my app. they are visible ? Or else how do i prevent my app. of overwritting the window layout with the one previously saved. Something to do with LoadCustomState() and SaveCustomState() ?, i could no find any info on howto implement those methods. I have here a link to the demo project to demonstrate what i mean:
http://www.4shared.com/file/237193472/c384f0f6/GUI60.html
Could someone tell me how to show those dockable windows in my CChildFrame class the second time the app starts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MFC 功能包中的新类都将其窗口状态保存在注册表中。
从声音来看,我认为您可能需要调用 CWinAppEx::SetRegistryBase( ) 在您调用
SetRegistryKey()
之后的InitInstance()
中。 MSDN 对此进行了描述(几乎没有详细说明原因)此处,在步骤 #4 中。The new classes in the MFC Feature Pack all have their window state saved in the registry.
From the sound of it, I think you probably need to call CWinAppEx::SetRegistryBase() in your
InitInstance()
after you callSetRegistryKey()
. MSDN describes it (with little to no detail on why) here in step #4.我认为 SaveState() 调用应该放在 CMainFrame::DestroyWindow() 方法中,以便在调用 SaveState() 时主框架的子窗口尚未被销毁。
我尝试在 CMainFrame 的析构函数中使用 SaveState(),一些断言不会通过,因为子窗格已经被销毁。
I think the SaveState() call should be put in the CMainFrame::DestroyWindow() method, so that Main Frame's child windows are not yet destroyed when the SaveState() is called.
I tried to use the SaveState() in the destructor of CMainFrame, some assertions won't pass because the child panes are already destroyed.
我在 InitInstance 中将其更改为 :
。
。
。
if (!ProcessShellCommand(cmdInfo))
返回假;
。
。
AND 在:
CMainFrame::~CMainFrame()
{
theApp.SaveState((CMainFrame*)AfxGetMainWnd(),_T("Settings4"));
我
不知道这是否是这样做的方法,但它现在有效。
对此的任何评论都非常受欢迎。
I changed it a bit in InitInstance to :
.
.
.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
.
.
AND in:
CMainFrame::~CMainFrame()
{
theApp.SaveState((CMainFrame*)AfxGetMainWnd(),_T("Settings4"));
}
I dont know if this is the way to do it, but it is working for now.
Any comments on this are more than welcome.