After studying Brew's development, I feel in my own range: there is no convenient code and the appropriate window mechanism, each project has to start all this idea, initially talk, throw the jade ~~ Keywords: Brew , Reusable, C , window management, event delivery example project: stockfa.sap
Source code:
// ------- BrewWin.h Begin ------- //
#include
Typedef unsigned int uint
Inline void * Operator new (uint size)
{
Return malloc (size);
}
Inline void Operator Delete (Void * Ptr)
{
Free (PTR);
}
Inline void * Operator new [] (uint size)
{
Return malloc (size);
}
Inline void Operator delete [] (void * ptr)
{
Free (PTR);
}
Class CWindow
{
Virtual firmconstruct (); // Initialization
Virtual finalrelease (); // final release
Virtual enable (Boolean Benable); // Currently displayed valid, otherwise release data and resources
Virtual redraw ();
Virtual Boolean Onevent (Aeeeevent EVT, UINT16 WPARAM, UINT32 DWPARAM);
}
Class CWndManage
{
// Management window
Add (CWindow * PWND);
REMOVE (CWindow * PWND);
REMOVEAll ();
MoveTotop (CWindow * PWND);
GetTopWnd (cwindow ** ppwnd);
// Express window
Show (CWindow * PWND, UINT16 NCMD);
// Event processing
Boolean Onevent (Aeeeevent EVT, UINT16 WPARAM, UINT32 DWPARAM); / / Forwarding Events to Current Window
// Basic function
}
// array
Template
Class Carray
{
T * m_at;
INT M_NSIZE;
Bool Add (T & T)
// ... Pay attention to allocation of the memory Brew environment
}
/ / ------- BrewWin.h End ------- //
// ------- Documents for specific projects
Class stocktrade: Public CWindow
{
/ / Save a field variable for recovery
// Implementation of virtual functions
}
Class stockfaapp: public CWndManage
{
/ / Adapt to the function, assignment, and release of BREW
//. . . slightly
// Call the basic function of CWndManage
/ / Other features data variables
}
I first came to the knife, welcome to criticize advice, it is grateful. . Tang Jian