-
2008-08-21
如何删除从CWnd或者CView派生类申请的内存。 - [MFC]
当我们销毁一个从CView派生对象是,会执行下面的过程。
一、CView的销毁
void CView::OnDestroy()
{
CFrameWnd* pFrame = GetParentFrame();
if (pFrame != NULL && pFrame->GetActiveView() == this)
pFrame->SetActiveView(NULL); // deactivate during death
CWnd::OnDestroy();
}
二、调用CWnd::OnDestroy(),该函数被调用之后,调用OnNcDestroy
void CWnd::OnDestroy()
{
#ifndef _AFX_NO_OCC_SUPPORT
// cleanup control container
delete m_pCtrlCont;
m_pCtrlCont = NULL;
#endif
// Active Accessibility
if (m_pProxy != NULL)
m_pProxy->SetServer(NULL, NULL);
if (m_pStdObject != NULL)
m_pStdObject->Release();
Default();
}
三、void CWnd::OnNcDestroy(),该函数是在销毁客户区域之后,被调用用来销毁非客户区域的函数,也是销毁
窗口之前最后调用的一个函数。该函数执行现场清理任务,最后调用需函数PostNcDestroy()
四、CView::PostNcDestroy()
// self destruction
void CView::PostNcDestroy()
{
// default for views is to allocate them on the heap
// the default post-cleanup is to 'delete this'.
// never explicitly call 'delete' on a view
delete this;
}
由此可见从CView派生的视图。我们在new之后,在销毁窗口时候仅仅需要调用DestroyWindow()函数即可。
void CWnd::PostNcDestroy()
{
// default to nothing
}
而由于CWnd的PosNcDestroy函数什么都没有做。所以从CWnd派生的类,在new之后,在销毁时需要
1.调用DestroyWindow()
2.delete obj -
2008-08-16
Window打印体系 - [MFC]
一、Windows 打印体系结构
1.获得打印机设备描述表
应用程序使用默认的打印机,则使用下面方法来创建设备描述表。
CDC dc;
CPrintDialog dlg(FALSE);
dlg.GetDefaults();
dc.Attach(dlg.GetPrinterDC);
2.标记打印开始
DOCINFO di;
::ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T("Budget Figures for the Current Fiscall Year");
dc.StarDco(&di):
3.打印
for(int i = 0; i <= nPageCount; i++)
{
dc.StartPage();
//
//Print page i
//
dc.EndPage();
}
4.结束打印
dc.EndDoc();
if(dc.StartDco(&di))
{
BOOL bContinue = TRUE;
for(int i = 1; i <= nPageCount && bContinue; i++)
{
dc.StartPage();
//initialize the device context
//print page i;
if(dc.EndPage() <= 0)
bContinue = FALSE;
}
if(bContinue)
dc.EndDoc();
else
dc.AbortDoc();
} -
2008-08-15
VS2005 解决"应用程序配置不正确,程序无法启动"问题 - [软件工程]
最近使用VS2005+codejock开发,需要做一个Release版本。当我把必要的mfc库,拷贝到exe目录下时。exe还是不能启动。
经过网上查找,看到一篇文章。“解决"应用程序配置不正确,程序无法启动"”
URL :http://www.cnblogs.com/wuhanhoutao/archive/2008/01/09/1031928.html
于是乎。我按照文章所讲的,将dl和mainfest文件。统统从VS2005的redis文件下,拷贝到exe目录下。
呵呵,居然exe可以运行了。
但是:1.肯定有些dll是当前exe不需要的。还需要将之删除。
2.manifest也许是必须的一个文件。
这篇文章是这样讲的。
在使用 VC++2005环境下生成的程序,放置到未安装VC环境的机器下后,有时候会出现程序无法执行的错误,其提示是:应用程序配置不正确,程序无法启动,重新安装应用程序可能解决问题。
实际上,重装是解决不了问题的,解决的一种方法是查看*exe.intermediate.manifest文件,比如文件的内容是:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.MFC' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
需要注意这个文件中的3个关键词:Microsoft.VC80.CRT,Microsoft.VC80.MFC和Microsoft.VC80.DebugCRT。寻找到...."Program Files"Microsoft Visual Studio 8"VC"redist文件夹下面,找到这些名称的子文件夹,拷贝它们下面所有的文件到希望发布的EXE文件下面,一起打包。这些文件也就是mfc80.dll,msvcr80.dll,msvcp80.dll和Microsoft.VC80.CRT.manifest等。此错误发生的原因是在目标机器上需要这些文件的支持。
谢谢该文章的作者。
-
导入是将本地的文件上传到服务器。例如如果想上传A文件夹下面的所有文件则
1.在A上右键,选择菜单"导入".
2.在弹出窗口的版本库中,输入存放文件的路径。https://server.xxx.test/truck/
3.确定.
导出是将服务器文件下载到本地。例如从服务器导出test文件加下面的所有文件
1.新建一个文件夹 A。
2.在 文件夹A的下面,右键,选择“导出”
3.在弹出窗口的版本库,中输入导出的路径。 https://server.xxx.test/
4.确定。
-
2008-08-01
svn文件目录
Dll设置
1.设置lib导入库
连接器->高级->导入库
添加: ../../MDT Interpretation Suite\bin\$(ConfigurationName)\$(TargetName).lib
2.设置dll
连接器->常规->输出文件
添加: ../../MDT Interpretation Suite\bin\$(ConfigurationName)\$(ProjectName).dll
测试DLL程序
dll项目与测试该dll项目处于同一个级别。
1.设置导入的 lib
连接器->输入->附加依赖项
debug:../..\MDTInterpretationSuite\bin\debug\MakeDll.lib
release:../..\MDTInterpretationSuite\bin\release\MakeDll.lib
2.包含头文件
测试程序中#include "..\MakeDll\MDTData.h"
3.设置exe
连接器->常规->输出文件
debug:../..\MDTInterpretationSuite\bin\debug\$(ProjectName).exe
release:../..\MDTInterpretationSuite\bin\release\$(ProjectName).exe







