Page principale | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Composants | Déclarations | Pages associées

MySubClassing.h

Aller à la documentation de ce fichier.
00001 /* SubClassing ***************************************************************
00002         Cette class permet de sous-classer plusieur fois une fenetre
00003 
00004         Ex.:
00005         typedef struct { int x,y; char name[1024]; }  TInfo1;
00006         typedef struct { COLORREF rgb; BOOL isTransparent; } TInfo2;
00007 
00008         LRESULT MyNewCallBack2 (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam,ULONG ptrContext)
00009         {
00010                 TInfo2 *info = (TInfo2 *)ptrContext;
00011                 switch (message)
00012                         //...
00013         }
00014 
00015         LRESULT MyNewCallBack1 (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam,ULONG ptrContext)
00016         {
00017                 TInfo1 *info = (TInfo1 *)ptrContext;
00018                 switch (message)
00019                         //...
00020         }
00021         
00022         void main()
00023         {   //...
00024                 TInfo1 info1;
00025                 TInfo2 info2;
00026                 CMySubClassing sub;
00027                 sub= hWnd;
00028                 sub.Set(newCallBack1,&info1);
00029                 sub.Set(newCallBack2,&info2);
00030                 //...
00031         }
00032 ************************************************************************ */
00033 
00034 #if !defined(AFX_MYSUBCLASSING_H__B19BE954_67F7_440E_8025_C08A1AFE37B7__INCLUDED_)
00035 #define AFX_MYSUBCLASSING_H__B19BE954_67F7_440E_8025_C08A1AFE37B7__INCLUDED_
00036 
00037 #if _MSC_VER > 1000
00038 #pragma once
00039 #endif // _MSC_VER > 1000
00040 
00041 #include "MyList.h"
00042 
00043 typedef LRESULT (*PTR_FONCTION_CALLBACK) (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam,ULONG ptrContext,BOOL *isEnd);
00044 
00045 class CElemCallback
00046 {
00047         public:
00048                 PTR_FONCTION_CALLBACK m_callBack;
00049                 ULONG m_ptrContext;
00050 
00051                 CElemCallback()
00052                 {
00053                         m_callBack = 0;
00054                         m_ptrContext = 0;
00055                 }
00056 
00057                 void operator=(CElemCallback &elem)
00058                 {
00059                         m_callBack = elem.m_callBack;
00060                         m_ptrContext = elem.m_ptrContext;
00061                 }
00062 };
00063 
00064 class CElemSubClassing
00065 {
00066         public:
00067                 HWND m_hWndControl;
00068                 ULONG m_oldCallBack;
00069                 MyList<CElemCallback> m_lElemCallBack;
00070 
00071                 CElemSubClassing() 
00072                 {
00073                         m_hWndControl = 0;
00074                         m_oldCallBack = 0;
00075                         m_lElemCallBack.SuprAll();
00076                 }
00077 
00078                 void operator=(CElemSubClassing &elem)
00079                 {
00080                         m_hWndControl = elem.m_hWndControl;
00081                         m_oldCallBack = elem.m_oldCallBack;
00082                         m_lElemCallBack = elem.m_lElemCallBack;
00083                 }
00084 };
00085 
00086 /* Structure de doonnée: *****************************************************
00087         m_lElemSubClassing[](CElemSubClassing)
00088           m_hWndControl         (HWND)
00089           m_oldCallBack         (ULONG)
00090           m_lElemCallBack[]     (CElemCallback)
00091                 m_callBack              (PTR_FONCTION_CALLBACK)
00092                 m_ptrContext    (ULONG)
00093 *************************************************************************** */
00094 
00095 class CMySubClassing  
00096 {
00097         private:
00098                 BOOL m_isSubclassing;
00099                 
00100         public:
00101                 CElemSubClassing *m_elemSubClassingCurrent;
00102 
00103                 CMySubClassing();
00104                 virtual ~CMySubClassing();
00105 
00106                 void operator=(HWND hWnd);
00107 
00108                 void Set(PTR_FONCTION_CALLBACK newCallBack,ULONG ptrContext);
00109                 void Delete ();
00110 };
00111 
00112 #endif // !defined(AFX_MYSUBCLASSING_H__B19BE954_67F7_440E_8025_C08A1AFE37B7__INCLUDED_)

Généré le Thu Apr 8 18:58:43 2004 pour SFC par doxygen 1.3.6