Listing 6: The ttest1_window_manager and ttest1_window classes
class ttest1_window_manager: public tmdi_manager{
public:
ttest1_window_manager (HINSTANCE hInstance,
tmdi_frame_window *parent,
LPCSTR menu_name,LPCSTR class_name);
virtual void set_global_ptr (void);
virtual tmdi_child_window *new_child_window
(HWND hwnd,LPCSTR title_name); };
class ttest1_window: public tmdi_child_window {
public:
ttest1_window(HWND hwnd,
tmdi_manager *the_manager,LPCSTR title_name);
virtual int OnRun (void);
virtual int respond_wm_command (WPARAM wParam,LPARAM);
virtual int respond_wm_close (void);
ttest1_window::~ttest1_window(); };
ttest1_window_manager *the_test1_window_manager = 0;
LRESULT CALLBACK _export Test1WndProc (HWND hwnd,
UINT message,WPARAM wParam,LPARAM lParam) {
return
(LRESULT CALLBACK) (the_test1_window_manager->
handle_message (hwnd, message, wParam, lParam)); }
ttest1_window_manager::ttest1_window_manager
(HINSTANCE hInstance,tmdi_frame_window *parent,
LPCSTR menu_name,LPCSTR class_name):
tmdi_manager (hInstance,parent,
(LRESULT CALLBACK)Test1WndProc,0,menu_name,
"Test 1 Window",class_name){}
void ttest1_window_manager::set_global_ptr (void) {
the_test1_window_manager = this; }
tmdi_child_window *ttest1_window_manager::
new_child_window (HWND hwnd,LPCSTR ) {
char *window_title = new char[40];
sprintf (window_title,"Test 1 Window #%d",
window_list->get_count()+1);
return new ttest1_window(hwnd,this,window_title);}
ttest1_window::ttest1_window(HWND hwnd,
tmdi_manager *the_manager,LPCSTR title_name)
: tmdi_child_window(hwnd,the_manager,title_name){
the_title = title_name;
SetWindowText (hwindow,the_title); }
int ttest1_window::OnRun () {
MessageBox (NULL,"Run Window 1",
"Test Window 1",MB_ICONINFORMATION |
MB_OKCANCEL);
return 1; }
int ttest1_window::respond_wm_command (WPARAM wParam,
LPARAM) {
switch (wParam) {
case MDI_RUN_TEST1:
return OnRun();
} // end switch
return tmdi_child_window::respond_wm_command (wParam,0L);}
int ttest1_window::respond_wm_close () {
// Override query for this window.
return 0; }
ttest1_window::~ttest1_window() {
delete (char*)the_title; }
// End of File