Skip to main content
GameDev.net gamedev.net
🔒 Locked

MFC Tutorials

Started by xg0blin May 11, 2003 at 2:08 AM 5 replies 500+ views
Original Post
xg0blin
xg0blin
I have been programming with the Win32 api for about a year now. I''d like to move on to MFC, and first learn to hand code it so I learn how it really works, and I can''t seem to find a tutorial that covers hand coding of MFC. I have a hand coded example that looks like this:
  
#include <afxwin.h>

class CMyApp: public CWinApp
{
	public:
		virtual BOOL InitInstance(void);
};

class CMyWnd: public CFrameWnd
{
	public:
		CMyWnd()
		{
			Create(0, "Hello World, MFC");
		}
};

BOOL CMyApp::InitInstance(void)
{
	m_pMainWnd = new CMyWnd;
	m_pMainWnd->ShowWindow(m_nCmdShow);
	return TRUE;
}

CMyApp MyApp;
  
But what if I want to add buttons, or edit boxes or whatever to my windows? I''ve tried a few different things with the CButton class, but have yet to get it to work. Anyone know of a good place to look, because I can''t find anything.
xg0blin
xg0blin
Those are both fine sites, but neither does strict hand coding. The best I have found using hand coding is an opengl site using mfc. Of course, it doesn''t cover common controls and common dialogs and such.
xg0blin
xg0blin
Ok, I got it, to put a pushbutton in, I could just the old win32 way.


  
#include <afxwin.h>

class CMyApp: public CWinApp
{
protected:
HWND Button1;

public:
virtual BOOL InitInstance(void);
};

class CMyWnd: public CFrameWnd
{
public:
CMyWnd()
{
Create(0, "Hello World, MFC");
}
};

BOOL CMyApp::InitInstance(void)
{
m_pMainWnd = new CMyWnd;
Button1 = CreateWindow("BUTTON", "PushMe", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 10, 10, 100, 100,
m_pMainWnd->m_hWnd, NULL, m_hInstance, NULL);
m_pMainWnd->ShowWindow(m_nCmdShow);
return TRUE;
}

CMyApp MyApp;


This works just fine. Thank you for your suggestions.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.