Windows Programming/Classes Hierarchy

From Wikibooks, open books for an open world
Jump to navigation Jump to search

MFC Classes Hierarchy

[edit | edit source]

CObject

[edit | edit source]

The root/base class for most of the MFC library. Some of the features it makes available to the programmer are serialization support, run-time class information, and object diagnostic output. Any derived class from CObject, can exploit these features.

Class CObject in AFX.H

Field Summary

static const AFX_CORE_DATA CRuntimeClass classCObject 
          

Constructor Summary

protected  CObject() 
          
private  CObject( const CObject& objectSrc ) 
          
 virtual ~CObject() 


Method Summary

void PASCAL operator delete( void* p ) 
          
virtual CRuntimeClass* GetRuntimeClass() const 
          
BOOL IsKindOf( const CRuntimeClass* pClass ) const 
          
BOOL IsSerializable() const 
          
void* PASCAL operator new( size_t, void* p ) 
          
void* PASCAL operator new( size_t nSize ) 
          
virtual void Serialize( CArchive& ar )

CCmdTarget

[edit | edit source]

CWinThread

[edit | edit source]

CWinApp

[edit | edit source]

CListCtrl

[edit | edit source]

This class encapsulates the functionality of a list view control, which is a control that displays a collection of items, each consisting of an icon and a label.

Class CListCtrl in AFXCMN.H


CObject

  |
  +--CCmdTarget
        |
        +--CWnd
              |
              +--CListCtrl

class CListCtrl extends CWnd

Fields inherited from class CWnd

m_hWnd, wndTop, wndBottom, wndTopMost, wndNoTopMost, m_hWndOwner, m_nFlags, m_pfnSuper, m_nMsgDragList, m_nModalResult, m_pDropTarget, m_pCtrlCont, m_pCtrlSite, messageMap 

Fields inherited from class CCmdTarget

messageMap, commandMap, dispatchMap, connectionMap, interfaceMap, eventsinkMap, m_dwRef, m_pOuterUnknown, m_xInnerUnknown, m_xDispatch, m_bResultExpected, m_xConnPtContainer 

Fields inherited from class CObject

classCObject

CToolBar

[edit | edit source]

This class encapsulates the functionality of a control bars that have a row of bitmapped buttons and/or separators. CToolBar objects are usually embedded members of frame-window objects derived from the class CFrameWnd or MDIFrameWnd.

CTreeCtrl

[edit | edit source]

CException

[edit | edit source]

CArray

[edit | edit source]

CFile

[edit | edit source]

CGdiObject

[edit | edit source]

CFont

[edit | edit source]

CHttpArgList

[edit | edit source]

Subclassing

[edit | edit source]

standard technique for customizing the behavior of a class

Window Subclassing

[edit | edit source]

Window message route

[edit | edit source]

The mechanism by which MFC routes messages is also called the Message Map system that was created to wrap the old C API and reduce the level of complexity for programmers.

// a Message Map example

BEGIN_MESSAGE_MAP( ClNOMainFrameWnd, CFrameWnd )
  ON_WM_SYSCOMMAND()
  ON_WM_CREATE()
  ON_WM_SIZE()
  ON_WM_CLOSE()
  ON_WM_MEASUREITEM()
  ON_WM_INITMENUPOPUP()
  ON_WM_MENUCHAR()
  ON_WM_DESTROY()

  ON_REGISTERED_MESSAGE( D_WM_REQUEST, OnMsgReqToShowWnd )

  ON_COMMAND( ID_APP_TRAYCLICK, OnTrayClick )
  ON_MESSAGE( C_WM_TIPACTION, OnTipOfTheDayAction )

END_MESSAGE_MAP()

Message map

[edit | edit source]

The message map macros:

ON_COMMAND and ON_BN_CLICKED
the ON_COMMAND and ON_BN_CLICKED are the same, MFC command and control macro is preset to handle the Windows message WM_COMMAND and the notification routing mechanism uses the command ID to decide where to route to. Notifications with control notification code of zero (BN_CLICKED) are interpreted as commands.
ON_UPDATE_COMMAND_UI
the ON_UPDATE_COMMAND_UI macro.

Component Object Model (COM)

[edit | edit source]