00001
00002
00003
00004 #ifndef MNCOMPONENT_H
00005 #define MNCOMPONENT_H
00006
00007
00008
00009
00010 #pragma warning(disable:4786)
00011
00012 #include <windows.h>
00013 #include <vector>
00014
00015 using namespace std;
00016
00021 #define AUTOSIZE -1
00022
00027 #define AUTOPOS -2
00028
00033 #define TRANS 0
00034
00041 class MNComponent
00042 {
00043 protected:
00044 MNComponent* parent;
00045 HWND hwnd;
00046 HINSTANCE hInstance;
00047 int showstate;
00048 int width;
00049 int height;
00050 int x;
00051 int y;
00052
00053 static TEXTMETRIC finfo;
00054
00062 struct CHILDCOMPONENT
00063 {
00064 MNComponent *com;
00065 HWND *hwnd;
00066 };
00067
00074 vector <BOOL (*)(MNComponent* , UINT, WPARAM, LPARAM)> listeners;
00075
00081 vector < CHILDCOMPONENT > clisteners;
00082
00083 public:
00087 virtual void RegisterComponent( HWND *hwnd, MNComponent* com );
00088
00092 virtual void RegisterChild( HWND *hwnd, MNComponent* com );
00093
00097 virtual void AddCallBack( BOOL (*callback)(MNComponent* , UINT, WPARAM, LPARAM) );
00098
00102 virtual LRESULT FireEvents( HWND hwnd, UINT message,
00103 WPARAM wParam, LPARAM lParam );
00104
00108 virtual LRESULT FireChildEvents( UINT message, WPARAM wParam,
00109 LPARAM lParam );
00110
00111
00115 virtual LRESULT SendEventToParent( UINT message, WPARAM wParam,
00116 LPARAM lParam );
00117
00121 virtual LRESULT SendEventToChild( HWND child, UINT message,
00122 WPARAM wParam, LPARAM lParam );
00123
00127 virtual LRESULT SendEventToChild( MNComponent* child, UINT message,
00128 WPARAM wParam, LPARAM lParam );
00129
00133 LRESULT SendMessage( UINT msg, WPARAM wParam, LPARAM lParam );
00134
00138 virtual BOOL Show();
00139
00143 virtual BOOL Hide();
00144
00148 virtual HWND GetHwnd();
00149
00153 virtual HINSTANCE GetInstance();
00154
00158 virtual void SetSize( int width, int height );
00159
00163 virtual void SetWidth( int width );
00164
00168 virtual void SetHeight( int height );
00169
00173 virtual int GetWidth();
00174
00178 virtual int GetHeight();
00179
00183 virtual void SetText( LPSTR label );
00184
00188 virtual void GetText( LPSTR buf, int buf_len );
00189
00193 virtual int GetX();
00194
00198 virtual int GetY();
00199
00203 virtual void SetX( int x );
00204
00208 virtual void SetY( int y );
00209
00213 virtual void SetPosition( int x, int y );
00214
00215 protected:
00219 void CreateControl( MNComponent *parent, LPSTR classname, LPSTR label,
00220 int width, int height, int x, int y, int style,
00221 int exstyle );
00222
00226 void GetCharSize();
00227
00228
00232 friend LRESULT CALLBACK GlobalProc( HWND hwnd,
00233 UINT message,
00234 WPARAM wParam,
00235 LPARAM lParam);
00236 };
00237
00238
00244 struct REGCOMPONENT
00245 {
00246 HWND *hwnd;
00247 MNComponent *com;
00248 };
00249
00250 #endif