如何优雅的写UI——(2)MFC下基于CFormView的文档视图程序

在MFC中可以创建多种类型的窗口程序,如对话框程序、单文档结构程序(非文档/视图结构)、单文档(文档/视图结构)以及多文档视图结构程序等。

在编写一般的小工具时,我们的首选显然是对话框程序,不过基于对话框的程序不支持视图类,有些功能实现起来会麻烦许多。此时我们可以使用CFormView作为基类来创建单文档(非文档/视图结构)和单文档(文档/视图结构)的程序。

一、使用MFC向导创建程序

如何优雅的写UI——(2)MFC下基于CFormView的文档视图程序

(1)单文档(文档/视图结构)

如何优雅的写UI——(2)MFC下基于CFormView的文档视图程序

(2)不需要状态栏和工具栏

如何优雅的写UI——(2)MFC下基于CFormView的文档视图程序

(3)使用CFormView作为基类

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkQAAAGdCAYAAADzOWwgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAB0RSURBVHhe7d0LkF11neDxX3cnTZAFR1EUCbs6kwYTQs2MomMScXxtOQmwxnUn4ywKO+tsWgslAct1cEFnSGqASg0kuNTYvaWjsDuuWV2zNZLW8bHuaBJQUayEhKQjw0segUDIux/J3XPOPaf79iNJhzSB9P/zsf70veece/v+O+D91v+c22natm1bLRP5OHjwYBw4cCD6+/uLceH/7A8AgIngp5efEpMnT45JkyZFS0tLNDc3F6OpqSmannzyySKI8hiqgqivr68Y7/pGxOPXvrF8GgCAE9OZS++PNf++NVpbW4dEURFD2WiuVofykatu53EEADBR5Is+1QJQNaruac4PaIygamf+FQBgosiDqBqNMZSPIStE1ajCCABgomgMoap1qvsDQZSrblc7AQAmisYIqkbVPkUQ5aoNjQMAYKIYLYSqMXANUaVx5/PVt/H78VzHonjqcx+Kxz/+R/HIpX8Yj3zkffH03/xl9HZvLI8CADh+8rYZHkTV7VGvIcpHfsDzUfvNj6K5NWLK786KSa84JVpOmxItU1ri5N99c/RNao3tP/9peSQAwPEzPIQa7xcrRLlqQ+N4PmoP/Cz2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yuEH3yHeUuAIA0FCtEn+i4O7q/fE19hegL/1TuAgBIw+A1RB++wQoRAJCk5n/eE/Ho5vui7fVn1LfM+PO4/c+m128DACSg+UtXXBE3fvf18fvnlFsAABLT/FtTz433XdIX/+NzN8eq/3tfPPjUnugtdvUV/wQAmOiaP770yrjkkmvi1us/HOdFd/zD314Tn7q6MzZs31weAgAwsTWfUt6I1jOi7V3z45OfuzW+cPPCmHn6zHIHAMDE5i93BQCSJ4gAgOQJIgAgeYIIAEieIAIAkieIAIDkCSIAIHmCCABIniACAJIniACA5AkiACB5gggASJ4gAgCSJ4gAgOQJIgAgeYIIAEieIAIAkieIAIDkCSIAIHmCCABIniACAJIniACA5AkiACB5gggASJ4gAgCSJ4gAgOQJIgAgeYIIAEieIAIAkieIAIDkCSIAIHmCCABIniACAJIniACA5I0SRH2x6e+uja890FfeBwCY2Jpj23fjP//xpfGxj30srrjiirjyyk/Ff1u/N+7tuLY8BABgYquvEL3hI3H9F78Yt912W9x6661x8803x0033VTsAgCY6AZPmT37w1hWrBBdGVdffXV85jOfKXcAAExsg0H0infHp2+7LW64+qPxn665MW666fPlDgCAia08ZTY1zihuRJxy1uui77t/HVd/7K/KLQAAE1u5QnRX3FFdVP2pJfGVX+yMvniuvgsAYIJrjh2PRpzxR/GRIRdVXxMfPPvs8hAAgImteds/b44zzqpOmAEApKf5lz84I97+ptby7qC+/vIGAMAE13zXhR+Ktw30UHd87cqPxn+87DPRddo7y20AABNb8+cvmVrezLXFn976pfjy7V+Om6+aU24DAJjYBn8PEQBAogQRAJA8QQQAJE8QAQDJE0QAQPIEEQCQPEEEACRPEAEAyRNEAEDyBBEAkDxBBAAk75BBVKvVylsAABNL3jmNrTNqEIkhAGCiqSKosXOq20UQCSAAIGVFEDU1NRV3AABSNOopM4EEAEw0ed9Uo1LdPuRF1aIIAJiohodRc3Vn+A4AgImkap3G5qluH/IaotG2AQCcqKr4aRyVgVNmhzsIAOBE19zcPGrv5KM4ZZaPSrGxfAAAwERRNc+oY+fOnbX89xAdPHgwDhw4EH19fdHb2xs9PT3xjq8fiBvPvjve8573lE8FAHBimTp1apy59P5YfdG+mDJlSrS2tsakSZOK0dLSUoymXbt2jQiifORB9Pav9cXj176xfDoAgBNTHkTf/Te9cdJJJ8XkyZOLkQdRflZsSBDlIw+i/v7+YuSrRG+7Y1/5NAAAJ7Yf/NuDQ2KoWiEqLhXavXt3LV8dqlaJqiDKR7ValIdSNfJjGo9v/FoNAIDjqfF6oOpa6PxrtQKUx09jCDXGULFCtGfPniKIqqhpjJ8qjKoQqr5WEdR4OyeIAIAXQxVDucYgaoyeKoyq29W+4vi9e/cOCaLqdmMYVfdHO04QAQAvtsMFUePtKoIaYygfRRBVUdP4tTGA8pHfr/ZXx1RfGwcAwAutsTmqEKqiqBoDsdNwe3gI5aM4ft++fdlz1mNmeOhU8VON0Y4ZbQAAHE+NIdQ4quBp/No4Bvbt378/a5h6yDRGzmgBNNr+xpGrvgIAHC952FRfG0cVPdXtIRHUuL+npydrmJGR0xhCo+0fPnLVVwCAF1Jjc+RBM/zraGN4HA1+bYr/Dz47tetqZkU9AAAAAElFTkSuQmCC" alt="" />

(4)使用向导创建好的程序窗口

二、程序初始化设置

在这个由MFC向导创建的程序窗口中有些功能或许是我们不想要的,比如视图标题、视图凹陷效果、菜单栏、鼠标拖动窗口边框调整窗口大小等。

1. 不显示视图标题、禁止以拖动方式调整窗口大小、禁用菜单栏

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
cs.style &= ~FWS_ADDTOTITLE; /* 不显示视图标题 */
cs.style &= ~WS_THICKFRAME; /* 禁止以拖动方式调整窗口大小 */
cs.hMenu = NULL;
return TRUE;
}

2. 去除视图凹陷效果

BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
cs.style &= ~WS_BORDER; /* 去除视图凹陷效果 */ return CFormView::PreCreateWindow(cs);
}

3. 修改程序窗口标题

BOOL CTestApp::InitInstance()
{ .... .... .... m_pMainWnd->SetWindowText( L"测试程序" ); /* 修改程序窗口标题 */ // 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// 仅当具有后缀时才调用 DragAcceptFiles
// 在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
return TRUE; }

结果:

如何优雅的写UI——(2)MFC下基于CFormView的文档视图程序

下一篇我会教大家如何动态创建好看的选项卡

代码:tab.zip

上一篇:通过google chrome操作JavaScript中Console


下一篇:mfc创建文档视图过程