龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

Visual C++ 编程经验(上)(2)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
1.打开MainFrm.cpp文件,使用工具条上的函数下拉列表框找到OnCreate()函数。按照下述程序注释掉创建工具条和状态条部分的语句。 int CMainFrame::OnCreate(LPCREAT

1.打开MainFrm.cpp文件,使用工具条上的函数下拉列表框找到OnCreate()函数。按照下述程序注释掉创建工具条和状态条部分的语句。

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CFrameWnd::OnCreate(lpCreateStruct) == -1)

return -1;

//在此处开始加注释符号

/*if (!m_wndToolBar.Create(this) ||!m_wnd ToolBar.LoadToolBar(IDR_MAINFRAME))

{

TRACE0(“Failed to create toolbar ");

return -1;// fail to create

}

if (!m_wndStatusBar.Create(this) ||!m_wndStatus Bar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT)))

{

TRACE0(“Failed to create status bar ");

return -1;// fail to create

}

// TODO: Remove this if you don´t want tool tips or a resizeable toolbar

m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

// TODO: Delete these three lines if you don´t want the toolbar to be dockable

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&m_wndToolBar);

//此处结束注释

*/

return 0;

}

2.在MainFrm.cpp文件中,使用工具条上的函数下拉列表框,找到PreCreateWindow()函数。把cs.style设置成如下形式,即不加载系统菜单。

// Create a window without min/max buttons,system menu, or sizable border

cs.style =WS_OVERLAPPED |WS_BORDER;

3. 在主应用程序,即含有定义theApp全程变量的.cpp文件中,使用工具条上的函数下拉列表框,找到InitInstance()函数。在“pDocTemplate = new CSingleDocTemplate”一句中,用NULL替换IDR_MAINFRAME。如下段程序所示。

BOOL CYourMainApp::InitInstance()

{

//.....此处略去一部分无关语句

CSingleDocTemplate* pDocTemplate;

pDocTemplate = new CSingleDocTemplate(

NULL,

//用NULL替换IDR_MAINFRAME

RUNTIME_CLASS(CNoBarDoc),

RUNTIME_CLASS(CMainFrame),

// main SDI frame window

RUNTIME_CLASS(CNoBarView));

AddDocTemplate(pDocTemplate);

//.....此处略去一部分无关语句

}

4. 找到Visual C++编辑器的工具条上的编译方式下拉列表框,选择Win32 Release,生成Release版本的应用程序。

至此,我们就得到了不含菜单、工具条和状态条结构的应用程序。

精彩图集

赞助商链接