【发布时间】:2014-01-02 11:03:57
【问题描述】:
我正在使用 MDI 应用程序。我想在框架窗口区域内创建一个属性表,如下图箭头所示:
我见过一些例子,我们可以在创建属性表后使用 ShowWindow() 函数,但它会创建不嵌入框架窗口的属性表。
我们能否像其他控件一样在框架窗口上创建属性表,如静态框等?
【问题讨论】:
标签: visual-c++ mfc
我正在使用 MDI 应用程序。我想在框架窗口区域内创建一个属性表,如下图箭头所示:
我见过一些例子,我们可以在创建属性表后使用 ShowWindow() 函数,但它会创建不嵌入框架窗口的属性表。
我们能否像其他控件一样在框架窗口上创建属性表,如静态框等?
【问题讨论】:
标签: visual-c++ mfc
如果您需要在视图中嵌入可调整大小的属性表,请查看 BCGSoft size(http://www.bcgsoft.com) - 最新版本的 BCGControlBar 显示了如何做到这一点:
http://www.bcgsoft.com/images/resizableform220.jpg
如果您只需要一个选项卡式 MDI 窗口,只需在 MFC AppWizard(VS 2008 或更高版本)中创建一个类似于 Visual Studio 的应用程序。
希望,这会有所帮助。
罗伯
【讨论】:
添加CMultiDocTemplate 实例解决了我的问题。这是代码sn-p。这是 ProjectName.cpp 文件的一部分:
BOOL CEmuDiagnosticsClientApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
//Added new code
{
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_STRING_LOGGINGWINDOW,
RUNTIME_CLASS(CEmuDiagnosticsClientDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CLoggingWindow));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
}
//End: Added new code
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
InitContextMenuManager();
InitKeyboardManager();
InitTooltipManager();
CMFCToolTipInfo ttParams;
ttParams.m_bVislManagerTheme = TRUE;
theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_STRING_SIGNALWINDOW,
RUNTIME_CLASS(CEmuDiagnosticsClientDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CSignalWindow)); //Changed Code
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there's a suffix
// In an MDI app, this should occur immediately after setting m_pMainWnd
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
在 //Added New code 部分,创建了一个新的CMultiDocTemplate 实例。 CLoggingWindow 是我想在框架窗口中显示的类。
另一个类CSignalWindow我也想在//更改代码区域显示修改。
要记住的事情:
-您要显示的对话框必须来自 CFormView,而不是 CDialog。
- 更改对话框属性:Border -> None、Style -> Child 和 所有其他属性为 false。
【讨论】: