mfc

How to enable or disable an event hander in MFC?

梦想的初衷 提交于 2020-01-17 08:18:06
问题 I have searched the web a lot but couldn't find exactly what I want! suppose that I have a class derived from CWnd . In fact, it is the class COpenGLControl here in codeguru customized by me for my own purposes. the event handler for the WM_MOUSEMOVE button is written as follows: void COpenGLControl::OnMouseMove(UINT nFlags, CPoint point) { int diffX = (int)(point.x - m_fLastX); int diffY = (int)(point.y - m_fLastY); m_fLastX = (float)point.x; m_fLastY = (float)point.y; // Left mouse button

How to get MFC serialization going without a CWinApp-derived class?

送分小仙女□ 提交于 2020-01-17 06:04:19
问题 I am writing a C++/CLI wrapper for an old MFC application, so far i have been able to read most of the data and convert the same into C# readable format. As of now i am only struggling with reading data and am worried will writing data back to old MFC code affect serialization ? Can you guys share/mention any other risks i might face while writing C++/CLI wrapper for MFC code ? Thanks for your inputs. this question is a continuation of "Redirecting data from MFC CArchive to boost::archive:

access right with OPC Client run as a windows service

拟墨画扇 提交于 2020-01-17 03:20:32
问题 I write a OPC client process in MFC, and everything is OK when I run it directly in VS2010. But when I install it as a windows services, problem comes. I still can connect to OPC Server, but after connected I check the status of the OPCServer with IOPCServer::GetStatus(), and it returns false! Is there something I need to watch out when I install the process as a windwos service?Or some settings of the OS need to set? (My OS is Win7) 来源: https://stackoverflow.com/questions/19908376/access

Why i can't compare CString in MFC

核能气质少年 提交于 2020-01-17 01:23:28
问题 This line. UpdateData(true); if( m_OldPassword.Compare(d.pass) && m_NewPassword.Compare(m_ConfirmPassword) ) m_OldPassword, m_NewPassword, m_ConfirmPassword is variable i added from EditControl m_OldPassword.Compare(d.pass) Result =true (tested) m_NewPassword.Compare(m_ConfirmPassword) Result = false. IMPLEMENT_DYNAMIC(ChangePassword, CDialog) ChangePassword::ChangePassword(CWnd* pParent /*=NULL*/) : CDialog(ChangePassword::IDD, pParent) , m_OldPassword(_T("")) , m_NewPassword(_T("")) , m

Why function Ellipse(…) are needed twice here to draw an ellipse?

这一生的挚爱 提交于 2020-01-16 17:28:53
问题 MFC: I read this code which is to draw an ellipse (not solid interior), but I cannot understand why function "pDC->Ellipse(...)" is needed twice here? (sol == 0, and do_what==DRAW_ELLIPSE) void CMy078207017Dlg::OnLButtonUp(UINT nFlags, CPoint point) { flag = 0; end = point; assist = point; if(p != NULL) { CDC* pDC = GetDC(); CPen pen; CBrush brush; getpen(pen, pDC, col, bol); if(do_what >= DRAW_LINE && do_what <= DRAW_RRECT) { p->p[0] = start; p->p[1] = end; } if(sol == 1) { getbrush(brush,

Why function Ellipse(…) are needed twice here to draw an ellipse?

非 Y 不嫁゛ 提交于 2020-01-16 17:28:17
问题 MFC: I read this code which is to draw an ellipse (not solid interior), but I cannot understand why function "pDC->Ellipse(...)" is needed twice here? (sol == 0, and do_what==DRAW_ELLIPSE) void CMy078207017Dlg::OnLButtonUp(UINT nFlags, CPoint point) { flag = 0; end = point; assist = point; if(p != NULL) { CDC* pDC = GetDC(); CPen pen; CBrush brush; getpen(pen, pDC, col, bol); if(do_what >= DRAW_LINE && do_what <= DRAW_RRECT) { p->p[0] = start; p->p[1] = end; } if(sol == 1) { getbrush(brush,

MFC: Address Bar control like Windows Explorer

南笙酒味 提交于 2020-01-16 05:51:06
问题 In my MFC app, I'm attempting to make a window that resembles the Windows 7 Open File dialog, but it browses a virtual/fake file system. It doesn't need to be pixel-perfect, but I'd like parity with the native OS dialog where possible. Probably the most challenging part is the address bar the runs along the top of an Open dialog. The address bar control is also atop all Windows Explorer windows. It shows the folder names that make up your path. It shows and hides buttons when moused over

VS2015中MFC界面使用OpenGL导入3DS模型(C++完整代码和源文件)

血红的双手。 提交于 2020-01-16 02:09:52
在Duilib中使用OpenGL导入3DS模型的说明见另一篇文章: https://blog.csdn.net/u012293114/article/details/103988648 0、实现思路 Created with Raphaël 2.2.0 开始(本文所建模型名称为DC10) 第1步:在SolidWorks中绘制三维模型,输出DC10.STL格式文件 第2步:将.STL文件导入3DSMax中确立纹理坐标,输出DC10.3DS格式文件 第3步:将DC10.3DS 文件再导入Deep Exploration中进行三维模型材质 、纹理的二次 处理,或直接输出DC10.cpp格式文件 第4步:新建MFC应用程序项目,将DC10.cpp文件加入到MFC项目中,使用OpenGL库函数进行渲染 结束 做了个简单的MFC界面,导入了DC10.3DS模型,控制模型自动缩放和旋转,效果如下所示,本篇文章将针对第4步进行详细记录,文章最后附有完整代码和源文件。 1、新建MFC应用程序 【应用程序类型】选择【基于对话框】,其他选项均默认,完成创建。 如出现以下提示,点击{编辑代码】,打开.rc文件 找到【DESIGNINFO】这段代码,注释掉或删除,然后保存 编译运行,如下图所示,MFC窗口建立完毕 在【资源视图】中找到对话框,选中【TODO:在此放置对话框控件】,删除,保存(需要关掉所有

Visual C++中的异常处理浅析

心已入冬 提交于 2020-01-16 00:23:37
Visual C++中的异常处理浅析 作者: 宋宝华 出处: 天极网 责任编辑: 方舟   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打开一个文件后,立马就开始进行读写操作,根本就不考虑文件是否正常打开了。这种习惯一定要改掉

VC++、MFC、COM和ATL的区别

有些话、适合烂在心里 提交于 2020-01-15 23:58:00
From: http://hi.baidu.com/huqingshuye/blog/item/c55bd12ca5fa1b5b4ec2263f.html 一、什么是MFC 微软基础类(Microsoft Foundation Classes),实际上是微软提供的,用于在C++环境下编写应用程序的一个框架和引擎,VC++是WinOS下开发人员使用的专业C++ SDK(SDK,Standard SoftWare Develop Kit,专业软件开发平台),MFC就是挂在它之上的一个输助软件开发包,MFC作为与VC++血肉相连的部分(注意C++和VC++的区别:C++是一种程序设计语言,是一种大家都承认的软件编制的通用规范,而VC++只是一个编译器,或者说是一种编译器+源程序编辑器的 IDE,WS,PlatForm, MFC同 BC++集成的VCL一样是一个非外挂式的软件包,类库,只不过MFC类是微软为VC++专配的)。MFC是Win API与C++的结合。 最后要明白MFC不只是一个功能单纯的界面开发系统,它提供的类绝大部分用来进行界面开发,关联一个窗口的动作,但它提供的类中有好多类不与一个窗口关联,即类的作用不是一个界面类,不实现对一个窗口对象的控制(如创建,销毁),而是一些在WinOS(用MFC编写的程序绝大部分都在WinOS中运行)中实现内部处理的类,如数据库的管理类等。 二