home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / MODULE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  6.4 KB  |  192 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1993 by Borland International
  3. //   include\owl\module.h
  4. //   Definition of class TModule.  TModule defines the
  5. //   basic behavior for OWL libraries and applications.
  6. //----------------------------------------------------------------------------
  7. #if !defined(__OWL_MODULE_H)
  8. #define __OWL_MODULE_H
  9.  
  10. #if !defined(__OWL_OWLDEFS_H)
  11.   #include <owl\owldefs.h>
  12. #endif
  13. #if !defined(__OWL_POINT)
  14.   #include <owl\point.h>
  15. #endif
  16. #if !defined(__OWL_EVENTHAN_H)
  17.   #include <owl\eventhan.h>
  18. #endif
  19. #if !defined(__OWL_EXCEPT_H)
  20.   #include <owl\except.h>
  21. #endif
  22.  
  23. class _OWLCLASS TWindow;
  24. class _OWLCLASS TDialog;
  25.  
  26. //
  27. //  class TModule
  28. //  ----- -------
  29. //
  30. class _OWLCLASS TModule : public TEventHandler, public TStreamableBase {
  31.   public:
  32.     class _OWLCLASS_RTL TXInvalidModule : public TXOwl {
  33.       public:
  34.         TXInvalidModule();
  35.         TXOwl* Clone();
  36.         void Throw();
  37.     };
  38.  
  39.     //
  40.     // Constructors & destructor
  41.     //
  42.     TModule(const char far* name, BOOL shouldLoad = TRUE);
  43.     TModule(const char far* name, HINSTANCE hInstance);
  44.     TModule(const char far* name, HINSTANCE hInstance, const char far* cmdLine);
  45.     virtual ~TModule();
  46.  
  47.     //
  48.     // Finish-up initialization of a module
  49.     //
  50.     void          InitModule(HINSTANCE hInstance, const char far* cmdLine);
  51.  
  52.     operator      HINSTANCE() const {return HInstance;}
  53.     BOOL operator ==(const TModule& other) const
  54.                     {return HInstance == other.HInstance;}
  55.     BOOL          IsLoaded() const {return HInstance > HINSTANCE(32);}
  56.  
  57.     //
  58.     // Get & set members. Use these instead of directly accessing members
  59.     //
  60.     const char far* GetName() const {return Name;}
  61.     void          SetName(const char far* name);
  62.  
  63.     HINSTANCE     GetInstance() const {return HInstance;}
  64.     void          SetInstance(HINSTANCE hInstance);
  65.  
  66.     //
  67.     // Module wide error handler. Called when fatal exceptions are caught.
  68.     //
  69.     virtual int   Error(xmsg& x, unsigned captionResId, unsigned promptResId=0);
  70.  
  71.     //
  72.     // Windows HINSTANCE related API functions encapsulated
  73.     //
  74.     int           GetModuleFileName(char far* buff, int maxChars)
  75.                     {return ::GetModuleFileName(HInstance, buff, maxChars);}
  76.  
  77.     FARPROC       GetProcAddress(const char far* fcnName) const
  78.                     {return ::GetProcAddress(HInstance, fcnName);}
  79.  
  80.   #if !defined(__WIN32__)
  81.     int           GetModuleUsage() const {return ::GetModuleUsage(HInstance);}
  82.     int           GetInstanceData(void* data, int len) const
  83.                     {return ::GetInstanceData(HInstance, (BYTE*)data, len);}
  84.   #endif
  85.  
  86.     HRSRC         FindResource(TResId id, const char far* type) const
  87.                     {return ::FindResource(HInstance, id, type);}
  88.     HGLOBAL       LoadResource(HRSRC hRsrc) const
  89.                     {return ::LoadResource(HInstance, hRsrc);}
  90.     DWORD         SizeofResource(HRSRC hRsrc) const
  91.                     {return ::SizeofResource(HInstance, hRsrc);}
  92.  
  93.   #if !defined(__WIN32__)
  94.     int           AccessResource(HRSRC hRsrc) const
  95.                     {return ::AccessResource(HInstance, hRsrc);}
  96.     HGLOBAL       AllocResource(HRSRC hRsrc, DWORD size) const
  97.                     {return ::AllocResource(HInstance, hRsrc, size);}
  98.     RSRCHDLRPROC  SetResourceHandler(const char far* type, RSRCHDLRPROC loadProc) const
  99.                     {return ::SetResourceHandler(HInstance, type, loadProc);}
  100.   #endif
  101.  
  102.     int           LoadString(UINT id, char far* buf, int maxChars) const;
  103.     HBITMAP       LoadBitmap(TResId id) const
  104.                     {return ::LoadBitmap(HInstance, id);}
  105.     BOOL          GetClassInfo(const char far* name, WNDCLASS far* wndclass) const
  106.                     {return ::GetClassInfo(HInstance, name, wndclass);}
  107.     HACCEL        LoadAccelerators(TResId id) const
  108.                     {return ::LoadAccelerators(HInstance, id);}
  109.     HMENU         LoadMenu(TResId id) const
  110.                     {return ::LoadMenu(HInstance, id);}
  111.     HCURSOR       LoadCursor(TResId id) const
  112.                     {return ::LoadCursor(HInstance, id);}
  113.     HICON         LoadIcon(const char far* name) const
  114.                     {return ::LoadIcon(HInstance, name);}
  115.   #if !defined(__WIN32__)
  116.     HCURSOR       CopyCursor(HCURSOR hCursor) const
  117.                     {return ::CopyCursor(HInstance, hCursor);}
  118.     HICON         CopyIcon(HICON hIcon) const
  119.                     {return ::CopyIcon(HInstance, hIcon);}
  120.   #else
  121.     HICON         CopyIcon(HICON hIcon) const {return ::CopyIcon(hIcon);}
  122.   #endif
  123.                     
  124.   protected:    
  125.     char far* Name;
  126.     HINSTANCE HInstance;
  127.  
  128.   private:    
  129.     BOOL      ShouldFree;
  130.     
  131.     //
  132.     // hidden to prevent accidental copying or assignment
  133.     //
  134.     TModule(const TModule&);
  135.     TModule& operator =(const TModule&);
  136.     friend ostream& _OWLFUNC operator <<(ostream& os, const TModule& m);
  137.  
  138.   //
  139.   // Obsolete members for Owl 1 compatibility
  140.   //
  141.   public:
  142.     char far* lpCmdLine;    // Use argv & argc for portability
  143.     TStatus   Status;       // Use exceptions
  144.  
  145.     TWindow*  ValidWindow(TWindow* win) {return win;}
  146.     TWindow*  MakeWindow(TWindow* win);
  147.     int       ExecDialog(TDialog* dialog);
  148.  
  149.     virtual void  Error(int errorCode);
  150.  
  151.     HWND      GetClientHandle(HWND hWnd);
  152.     TWindow*  GetParentObject(HWND hWndParent);
  153.  
  154.     BOOL      LowMemory() {return FALSE;}
  155.     void      RestoreMemory() {}
  156.  
  157.   DECLARE_STREAMABLE(_OWLCLASS, TModule, 1);
  158. };
  159.  
  160. //
  161. // Global pointer to the current module
  162. //
  163. extern TModule* Module;
  164.  
  165. //
  166. // Exported pointers from OWL modules, implemented in GLOBAL.CPP
  167. //
  168. class _OWLCLASS TDocTemplate;
  169. extern "C" {      // unmanagled to allow loading via LoadLibrary
  170.  
  171. TDocTemplate** _export PASCAL GetDocTemplateHead(int version);
  172.  
  173. TModule** _export PASCAL GetModulePtr(int version);
  174.  
  175. }
  176.  
  177. //
  178. // Public functions in appdict.cpp that manage the application dictionary--
  179. // updating app dictionary & getting the current application
  180. //
  181. class _OWLCLASS TApplication;
  182. void          _OWLFUNC AddApplicationObject(TApplication* app);
  183. void          _OWLFUNC DeleteApplicationObject();
  184. TApplication* _OWLFUNC GetApplicationObject();
  185.  
  186. //
  187. // Main entry point for an Owl application
  188. //
  189. int OwlMain(int argc, char* argv[]);
  190.  
  191. #endif  // __OWL_MODULE_H
  192.