Category Archives: MFC

IE7 compatibility issue

An application used wininet.dll works properly on system with IE6 installed, but failed to allocate 800MB memory on system with IE7 installed. The address space is fragmented by the following 2 DLLs 3d930000 3da01000   WININET  C:\WINDOWS\system32\WININET.dll 3dfd0000 3e015000   iertutil C:\WINDOWS\system32\iertutil.dll … Continue reading

Posted in CPP, MFC | Leave a comment

minimal MFC window

#define _WIN32_WINNT  0x0501 #include <afxwin.h> struct CMainFrame : public CFrameWnd { CMainFrame() { Create(NULL, “Onega’s mini MFC Application”); } void CMainFrame::OnPaint() { CRect rect; GetClientRect (&rect); CPaintDC dc(this); CString msg = “Compile command: cl minimfc.cpp /link /subsystem:windows”; dc.DrawText(msg, &rect, DT_SINGLELINE … Continue reading

Posted in CPP, GUI, MFC, Uncategorized | Leave a comment

ATL, MFC and scoped_any

I am glad to found Achieve More Reliable Resource Management with Our Custom C++ Classes, but when using it in a unit test project, I got weird compile error. The error points to line 238 of scoped_any.h DECLARE_SMART_ANY_TYPEDEFS(scoped) and according … Continue reading

Posted in MFC | Leave a comment

Reusing CWinApp derived MFC class in Console application

Once I have to integrate a MFC GUI application into a console application. The MFC has a global "theApp" object, but I also want to change something before its ctor was called, so I moved "theApp" from global to local … Continue reading

Posted in MFC | Leave a comment

Code snippet Using WMI via C++/CLI

#include "stdafx.h"#using <>using namespace System;using namespace System::Management;  int main(array<System::String ^> ^args){    Console::WriteLine(L"Query processor count via CLI by Onega");    ConnectionOptions^ options = gcnew ConnectionOptions();    //options->Password = L"";    //options->Username = L"";    //options->Authority = "NTLMDomain:" ;    options->Impersonation = ImpersonationLevel::Impersonate;     ManagementScope^ scope … Continue reading

Posted in MFC | 1 Comment

VC++ 9.0 Express edition web setup

It depends on proxy settings of IE, but does not understand pac (proxy automatic configuration file) settings.

Posted in MFC | Leave a comment

LoadIcon() failed in Ctor of CDialog derived class

Once I encountered an application that raise runtime error in Ctor of a CDialog derived class at the following line: m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); After revisiting the program, I found that there is a global variable of this dialog class, this … Continue reading

Posted in MFC | Leave a comment