Listing 4: Header for tmdi_manager and tmdi_child_window classes


#ifdef WIN_32
#define MDI_SETMENU_MSGPARAMS(menu,submenu)\
          (WPARAM)menu, (LONG)submenu
#define ACTIVATE_MDI_CHILD_WINDOW(hwnd,wParam,lParam)\
          (lParam == (LONG)hwnd)
#else   // 16-bit Windows
#define MDI_SETMENU_MSGPARAMS(menu,submenu)\
          0, MAKELONG(menu,submenu)
#define ACTIVATE_MDI_CHILD_WINDOW(hwnd,wParam,lParam)\
          ((BOOL)(wParam))
#endif
          
class tmdi_window: public twindow {
   public:
   // Base class for tmdi_manager and tmdi_child_window 
   tmdi_window (HINSTANCE hInstance,LRESULT CALLBACK
       window_proc,int window_extra,LPCSTR menu_name,
       LPCSTR title_name,LPCSTR class_name):twindow
       (hInstance,window_proc,window_extra,menu_name,
    title_name,class_name,0) {};
   virtual LRESULT CALLBACK default_window_proc(HWND hwnd,
       UINT message,WPARAM wParam,LPARAM lParam);};

#define MAX_NO_OF_ACTIVE_WINDOWS 20

// Complete declaration for this class given below
class tmdi_child_window;

typedef struct {
   HWND hwnd;
   tmdi_child_window *window;
   } child_window_struct;

class tmdi_manager: public tmdi_window {
   public:
   HWND hwndClient,hwndFrame;
   HMENU window_menu,window_submenu,frame_menu,
          frame_submenu;
   tmdi_frame_window *parent_frame;
   object_list *window_list;
   int active_index;
   tmdi_manager (HINSTANCE hInstance,
       tmdi_frame_window *parent,LRESULT CALLBACK
       window_proc,int window_extra,LPCSTR menu_name,
       LPCSTR title_name,LPCSTR class_name);
   virtual int respond_wm_create (HWND hwnd);
   virtual int respond_wm_destroy (HWND hwnd);
   virtual HWND get_active_hwnd (void);
   virtual int add_child_window (HWND hwnd,
      child_window_struct *child);
   virtual tmdi_child_window *new_child_window
      (HWND hwnd,LPCSTR title_name);
   virtual child_window_struct *get_child_window
      (HWND hwnd,int *index);
   virtual LRESULT CALLBACK handle_message(HWND hwnd,
      UINT message,WPARAM wParam,LPARAM lParam);
   void init_menu (HINSTANCE hinst,
      LPCSTR menu_rc_name,WPARAM window_submenu_pos);
   void set_frame_menu (HMENU the_frame_menu,
      HMENU the_frame_submenu);
   virtual ~tmdi_manager (); };

class tmdi_child_window: public tmdi_window {
   public:
   tmdi_manager *manager;
   tmdi_child_window (HWND hwnd,
      tmdi_manager *the_manager,LPCSTR title_name);
   virtual int respond_wm_mdiactivate (HWND hwnd,
      WPARAM wParam,LPARAM lParam);
   virtual int respond_wm_queryendsession (void);
   virtual int respond_wm_create (HWND hwnd);
   virtual int respond_wm_close (void); };
// End of File