CBaseWin.h

 /*

SimpleFC

These classes are intended to be a starting point for anyone to write their
own foundation 'type' classes or widgets. Just remember that any additional
class should directly or indirectly inherit from CBaseWin.

This is a powerful starting point to writing windows apps without MFC.

Written by Mike C. Nov 30 2005.
governortyrran@hotmail.com

*/

/*

- CBaseWin -

Base Object. This handles the HWND object and redirects messages to derived
classes. Lowest level base class.

Utilization:

Derive from this class.

*/

#ifndef __VV__CBASEWIN
#define __VV__CBASEWIN

#if _MSC_VER > 1000
#pragma once
#endif

/* DEPENDENCIES ------------------------------------------------------------- */
#include "windows.h"
/* DEPENDENCIES END --------------------------------------------------------- */

/* FORWARD DECLARATORS ------------------------------------------------------ */
class CBaseWin;
/* FORWARD DECLARATORS END -------------------------------------------------- */

/* MACRO DEFINITIONS -------------------------------------------------------- */
#define __CBASEWIN__EXTRABYTES 4 //(32-bit)
#define __CBASEWIN__CLASSNAME _T("CWINBASE PROC ROUTED WIN")
#define __CBASEWIN__DEFNAME _T("CWINBASE Window")
#define __CBASEWIN__ID 0xCFABEACD //whatever we want, just make it 32-bit
/* MACRO DEFINTIIONS END ---------------------------------------------------- */

/* FUNCTIONS ---------------------------------------------------------------- */
LRESULT CALLBACK CBaseWinProc(HWND hWnd, MSG uMsg, WPARAM wParam, LPARAM lParam);
/* FUNCTIONS END ------------------------------------------------------------ */

/* STRUCTURES --------------------------------------------------------------- */
/* STRUCTURES END ----------------------------------------------------------- */

/* CLASS BODY --------------------------------------------------------------- */
class CBaseWin
{
public:
CBaseWin(VOID); //register
virtual ~CBaseWin(VOID); //unregister

//release any left-over memory
virtual VOID Release(VOID); 

//create window and set extra bytes and id
virtual BOOL Create(LPCTSTR szWinName, DWORD dwStyles, HWND hWndParent,
INT x, INT y, INT cx, INT cy);

virtual BOOL Resize(INT cx, INT cy);

//internal proc - even though we should already have hWnd as the
//member var m_hWnd, we can do a check to verify proper redirection
//if hWnd and m_hWnd dont match there are issues.
virtual LRESULT WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

private:
ATOM RegisterWinExBytes(HINSTANCE hInstance,
WNDPROC WndProc, TCHAR *szWinClassName, INT nExtraBytes);
public:
HWND m_hWnd;  //public for quick access
};
/* CLASS BODY END ----------------------------------------------------------- */

#include "CBaseWin.cpp"

#endif

Project Homepage: