Class member functions as callback functions in MFC
To use them that way, declare the functions as static.
Check this for more info.
Mathematics and Computer Programming
http://epsilondelta.wordpress.com/
Converting INTEGER to CHAR in MFC
int i =100;
char test[20];
atoi(i, test,10);
AfxMessageBox(test);
Steve Jobs' Magic Kingdom
Business Week
Instance of current MFC application
To get the instance handle to the current MFC application,
hInstance = AfxGetInstanceHandle() ;
GetFileVersionInfo error
Trying to integrate a C++ MFC project with an existing Win32 C project. GetFileVersionInfoSize throws up the following errors:
PicomCD error LNK2001: unresolved external symbol _GetFileVersionInfoA@16
PicomCD error LNK2001: unresolved external symbol _GetFileVersionInfoSizeA@8
PicomCD error LNK2001: unresolved external symbol _VerQueryValueA@16
This is removed by including the following line in the cpp file:
#pragma comment(lib, "version.lib")
MFC error LNK 2005:
already defined in .obj
whenever I try to use extern keywords to access global variables defined in another file of the project.
trying to integrate C code written in Win32 to MFC C++
To Solve (quickest method)
Project > Properties > Linker > Command Line > Additional Options > Type /FORCE
LPUINT error
Trying to integrate a C++ MFC project into an existing Win32 project in C.
The following error is thrown up wherever LPUINT is present
syntax error : identifier 'LPUINT'
To remove the error , we need to go to the stdafx.h file in the MFC project and comment out
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
Commenting out the above portion, now makes the project run fine.
CListCtrl in MFC
2 ways to use list controls in MFC:
- Directly embed CListCtrl object in the dialog class
- Indirectly by using the CListView class
CListView makes it easy to integrate with the document/view architecture.
CListCtrl& ctlList = GetListCtrl();
Callback Mask - set of bit values flags which specify the item states for which the application stores the current data
applies to all of the control's items, and is 0 by default
During CListView, the control is created in the view's OnCreate handler function
Using CListCtrl directly is done through the ClassWizard method. ( the not so intuitive classwizard in VC 7 ....phew! )
Using classwizard, add a member variable and declare map handler functions
CImageList - to create one or more image lists
How to create Firefox extensions
Interesting
Open Source Flash player
GNASH
An example MFC program
//hello.cpp
#include
// Declare the application class
class CHelloApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
// Create an instance of the application class
CHelloApp HelloApp;
// Declare the main window class
class CHelloWindow : public CFrameWnd
{
CStatic* cs;
public:
CHelloWindow();
};
// The InitInstance function is called each
// time the application first executes.
BOOL CHelloApp::InitInstance()
{
m_pMainWnd = new CHelloWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
// The constructor for the window class
CHelloWindow::CHelloWindow()
{
// Create the window itself
Create(NULL,
"Hello World!",
WS_OVERLAPPEDWINDOW,
CRect(0,0,200,200));
// Create a static label
cs = new CStatic();
cs->Create("hello world",
WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(50,80,150,150),
this);
}
The program is doing three things:
1. Creating the application object
Every program has a single application object that handles the initialization details of Windows and MFC
2. The application then creates a single window on the screen to act as the main application window
3. Inside the window, the application creates a single static text label containing the words 'hello world"
1. Declare the application class
2. Create an instance of the application class
3. Declare the main window class
4. InitInstance function is called each time the application first executes
5. Constructor for the window class
1. Create the window
2. Create the static label
Welcome to Mars Express, only a 3hr trip
ScotsmanSlashdotNewScientist
Revenge of the dotcom poster boy
Wired