mfc

Visual C++中的异常处理浅析[轉]

China☆狼群 提交于 2020-01-15 22:59:45
Visual C++ 提供了对 C 语言、 C++ 语言及 MFC 的支持,因而其涉及到的异常( exception )处理也包含了这三种类型,即 C 语言、 C++ 语言和 MFC 的异常处理。除此之外,微软对 C 和 C++ 的异常处理进行了扩展,提出了结构化异常处理( SEH )的概念,它支持 C 和 C++ (与之相比, MFC 异常处理仅支持 C++ )。 一个典型的异常处理包含如下几个 步骤 : (1)程序执行时发生错误; (2)以一个异常对象(最简单的是一个整数)记录错误的原因及相关信息; (3)程序检测到这个错误(读取异常对象); (4)程序决定如何处理错误; (5)进行错误处理,并在此后恢复/终止程序的执行。 C、C++、MFC及SEH在这几个步骤中表现出了不同的特点。本文将对这四种异常处理进行介绍,并对它们进行对比分析。本文例程的调试平台为Visual C++6.0 ,操作系统为 Windows XP ,所有程序均调试通过。 在进入正式的讲解之前,先说几句废话。许多的编程新手对异常处理视而不见,程序里很少考虑异常情况。一部分人甚至根本就不考虑,以为程序总是能以正确的途径运行。譬如我们有的程序设计者调用fopen打开一个文件后,立马就开始进行读写操作,根本就不考虑文件是否正常打开了。这种习惯一定要改掉,纵使你再不愿意!这是软件健壮性的需要!异常处理不是浪费时间!

Change Order of the CTreeCtrl item by Drag and drop, MFC

给你一囗甜甜゛ 提交于 2020-01-15 10:55:09
问题 I have an application which has CTreeCtrl which shows all the folders of the specific drive, I want to change the order of the folder in the same CTreeCtrl by means of Drag n Drop. How can it be done. I have implemented the code for getting the folder name in the CTreeCtrl but wondering how can i change order by means of Drag & Drop. 回答1: Ther is sample code vailable at Codeproject. Just use google. 来源: https://stackoverflow.com/questions/20242298/change-order-of-the-ctreectrl-item-by-drag

LoadBitmap fails after multiple calls

梦想与她 提交于 2020-01-15 10:53:49
问题 In this function, after about 90 calls (it's called in a loop and the idea is to load in a separate image each time, but I have kept it to one image for simplicity).The global variables now changed to local ones. void CDLP_Printer_ControlDlg::DisplayBMPfromSVG(CString& strDsiplayFile) { HBITMAP hbmp_temp = (HBITMAP)::LoadImage(0, strDsiplayFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (!hbmp_temp) { //hbmp_temp = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)); ActionList

Extracting all .msg files from a .pst file

穿精又带淫゛_ 提交于 2020-01-15 10:31:26
问题 Note: I was asked to create an app that extracts .msg files from a .pst file preferably in MFC. I was informed that they have tried to use other 3rd party apps but they all failed (don't ask me how) so that's why they are asking me to create an app to do this. First question: I was told that MFC was the preferred language, so are there MFC libraries to support implementing this in MFC? If not, can C# do? Second question: If yes, which libraries to use? If not, which C# libraries to use? 回答1:

How do I get CIPAddressCtrl to support tabbing between tuple fields using period

本小妞迷上赌 提交于 2020-01-15 10:15:38
问题 You must actually be editing a tuple to get the dot to behave as desired. So if I want to change 10.0.1.10 to 10.0.1.11, I must type "10.0.1.11" because the dot does NOT behave like a TAB. I would like to type just "...11", but the dots are ignored until you are editing a tuple. Doh! Any ideas on how to make this work? 回答1: By default IP address control does not respond to '.' unless the cursor is at the end of the sub field edit control, only then, it will move to the next field. Override

Win32/MFC Get window rect from client rect

徘徊边缘 提交于 2020-01-15 08:27:07
问题 I know there is a function somewhere that will accept a client rect and it will convert it into a window rect for you. I just can't find / remember it! Does anyone know what it is? It will do something similar to: const CRect client(0, 0, 200, 200); const CRect window = ClientRectToWindowRect(client); SetWindowPos(...) 回答1: You're probably thinking of AdjustWindowRectEx(). Keep in mind, this is intended for use when creating a window - there's no guarantee that it will produce an accurate set

order of events when a window starts in Visual C++ MFC

大兔子大兔子 提交于 2020-01-15 08:01:49
问题 suppose that I have a class derived from CWnd that have the event handler functions OnPaint , OnCreate and OnSize . As you know all of them are occured when the window starts but I want to see what is the order between them. when I set a breakpoint in one of them, after ending the function, the control is not passed to another and goes to one of the MFC's built-in .cpp files for example wincore.cpp ? How can I understand the order? any links or teach me a way to prevent the control from going

Connect Pantheios logging in a DLL to the main application's logging

六眼飞鱼酱① 提交于 2020-01-15 07:30:38
问题 Here's the situation: I'm working on a MFC application and want to integrate some logging capabilities into it. I did some research and settled on Pantheios since it seems to be regarded as the best logging API out there. I had no problems getting simple logging up and running - I even threw in some callback stuff to change the formatting of the output. My application will be making use of several DLLs. These are DLLs that I am actively developing and would like to integrate logging into them

MFC双缓冲解决闪烁问题

时光毁灭记忆、已成空白 提交于 2020-01-15 03:27:10
  最近在写一个图像编辑软件,环境是MFC,但是MFC的视图刷新机制使得图像闪烁得非常厉害(图像缩放时尤其明显),在网上查了一些资料,最好的方法是用双缓冲的方式显示,这里总结一下。   双缓冲的原理可以这样形象的理解:把电脑屏幕看作一块黑板。首先我们在内存环境中建立一个“虚拟“的黑板,然后在这块黑板上绘制复杂的图形,等图形全部绘制完毕的时候,再一次性的把内存中绘制好的图形“拷贝”到另一块黑板(屏幕)上。采取这种方法可以提高绘图速度,极大的改善绘图效果。 主要实现代码如下: 1 CDC MemDC; // 首先定义一个内存显示设备对象 2 CBitmap MemBitmap; // 定义一个位图对象 3 MemDC.CreateCompatibleDC(NULL); // 创建兼容设备dc 4 MemBitmap.CreateCompatibleBitmap(pDC,W,H); 5 CBitmap * pOldBit = MemDC.SelectObject( & MemBitmap); 6 MemDC.FillSolidRect( 0 , 0 ,W,H,RGB( 255 , 255 , 255 )); // 填充初始颜色 7 cimg.DrawToHDC(MemDC.GetSafeHdc(),CRect( 0 , 0 ,W,H)); // 绘图到内存显示设备 8 9 pDC ->

error C2661: 'CObject::operator new' : no overloaded function takes 4 arguments

这一生的挚爱 提交于 2020-01-14 18:50:48
问题 I have a memory leak that I'm trying to hunt down in my mfc program. Typically I would do something like the following: header file // Leak Detection #if defined(WIN32) && defined(_DEBUG) #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #endif cpp file // Leak detection #if defined(WIN32) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) #ifdef DEBUG_NEW #undef DEBUG_NEW #endif #define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ ) #define new DEBUG_NEW #endif This