home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / safctl / uty99ctl.h < prev   
Encoding:
C/C++ Source or Header  |  1994-05-17  |  5.4 KB  |  179 lines

  1. /*******************************************************************
  2. ********************************************************************
  3.  File Name  :  UTY99CTL.H
  4.  
  5.  Description:  SAFCtl3dV2 class
  6.  
  7.  Change Log :  05/01/94
  8.                KENWAL
  9.                New Program
  10.  
  11. ********************************************************************
  12. *******************************************************************/
  13.  
  14.  
  15. /*                                
  16. Use:
  17.    Use SAFCtl3dV2 instead of linking directly to ctl3dv2.dll.  This class
  18.    makes sure ctl3dv2 is loaded from the proper directory.  If ctl3dv2 is not
  19.    available your application will still run without the 3D effects.  
  20.    
  21.  MFC example:
  22.    In your CWinApp derived class, add a member variable of SAFCtl3dV2
  23.       public:
  24.         SAFCtl3dV2 m_3dDll;
  25.    In CMyWinApp::InitInstance function call SAFCtl3dV2::Auto
  26.       m_3dDll.Auto(m_hInstance);
  27.       
  28.    In your main window add a function to handle the WM_SYSCOLORCHANGE message.
  29.    Call the Ctl3dColorChange function.  
  30.       void CMainFrame::OnSysColorChange()
  31.       {
  32.          CFrameWnd::OnSysColorChange();
  33.          
  34.          ((CMyWinApp *)AfxGetApp())->m_3dDll.Ctl3dColorChange();
  35.       }
  36.               
  37.  MFC CFormView example
  38.    If you want a CFormView to have a 3D look override the OnInitialUpdate() function
  39.    and call Ctl3dSublcassDlg.
  40.       void CMyFormView::OnInitialUpdate()
  41.       {       
  42.          ((CMyApp *)AfxGetApp())->m_3dDll.Ctl3dSubclassDlg(m_hWnd, CTL3D_ALL);
  43.       
  44.          CFormView::OnInitialUpdate();
  45.       }
  46.  
  47.    
  48.  
  49.  
  50. Function Reference::
  51.  
  52. Constructors
  53.    SAFCtl3dV2()
  54.    
  55.    SAFCtl3dV2(BOOL bAuto)
  56.      bAuto - If TRUE the current task (GetCurrentTask) will be registered with 
  57.              Ctl3dv2 and auto subclassing will be turned on.  
  58.              
  59. Destructor
  60.    ~SAFCtl3dV2()
  61.      Calls Ctl3dUnregister if auto subclassing was turned on via the Constructor 
  62.      with a single BOOL argument or the Auto function was called.
  63.      Calls a FreeLibrary on ctl3dv2.dll if it was loaded.
  64.              
  65. Implementation   
  66.    BOOL Auto(HINSTANCE hInstApp = NULL)
  67.      Registers the application with Ctl3dv2 and turns on auto subclassing.  
  68.      If hInstApp is NULL the instance of the current task (GetCurrentTask) 
  69.      is used.
  70.      
  71.    BOOL Init()
  72.      Initialized SAFCtl3dV2's connection with Ctl3dv2.dll.  The function
  73.      safely loads ctl3dv2 from the windows\system directory.  If the dll
  74.      is not already located in the windows\system directory it will look for
  75.      it and install it before calling LoadLibrary.  
  76.      
  77.      You do not need to call this function.  SAFCtl3dV2 will make sure it is 
  78.      called. 
  79.      
  80.    SHORT GetLastError()
  81.      Returns the last error code. 
  82.   
  83.  
  84. */
  85.  
  86. #ifndef  __UTY99CTL_H 
  87.  #define __UTY99CTL_H
  88.  
  89. #ifndef _INC_WINDOWS
  90.  #include <windows.h>
  91. #endif
  92.  
  93. #include <ctl3d.h>
  94.  
  95. typedef short SHORT;
  96.                         
  97. //Error codes                        
  98. const SHORT CCTL3D_OK             = 0; 
  99. const SHORT CCTL3D_E_NOFUNCTION   = 1;
  100. const SHORT CCTL3D_E_OUTOFMEMORY  = 2;
  101. const SHORT CCTL3D_E_LOADFAIL     = 3;   
  102.  
  103. //function typedefs      
  104. typedef BOOL (WINAPI* PFNSUBCLASSDLG)(HWND, WORD);
  105. typedef BOOL (WINAPI* PFNSUBCLASSDLGEX)(HWND,DWORD );
  106. typedef WORD (WINAPI* PFNGETVER)(VOID);
  107. typedef BOOL (WINAPI* PFNENABLED)(VOID);
  108. typedef HBRUSH (WINAPI* PFNCTLCOLOREX)(UINT, WPARAM, LPARAM);
  109. typedef BOOL (WINAPI* PFNCOLORCHANGE)(VOID);
  110. typedef BOOL (WINAPI* PFNSUBCLASSCTL)(HWND);
  111. typedef LONG (WINAPI* PFNDLGFRAMEPAINT)(HWND, UINT, WPARAM, LPARAM );
  112. typedef BOOL (WINAPI* PFNAUTOSUBCLASS)(HINSTANCE);
  113. typedef BOOL (WINAPI* PFNREGISTER)(HINSTANCE );
  114. typedef BOOL (WINAPI* PFNUNREGISTER)(HINSTANCE );
  115.  
  116. //functions from helper dll's
  117. typedef BOOL (WINAPI* PFNTASKFINDHANDLE)(VOID FAR *, HTASK );
  118. typedef LONG (WINAPI* PFNLZCOPY)(HFILE, HFILE );
  119.  
  120.  
  121.                                                                
  122.  
  123. class  SAFCtl3dV2
  124. {
  125.  public:  
  126.    SAFCtl3dV2();
  127.    SAFCtl3dV2(BOOL bAuto);
  128.    ~SAFCtl3dV2();
  129.  
  130.    BOOL Auto(HINSTANCE hInstApp = NULL);
  131.    BOOL Init();  
  132.    SHORT GetLastError();
  133.       
  134.    BOOL WINAPI Ctl3dSubclassDlg(HWND, WORD);
  135.    BOOL WINAPI Ctl3dSubclassDlgEx(HWND, DWORD);
  136.    WORD WINAPI Ctl3dGetVer(void);
  137.    BOOL WINAPI Ctl3dEnabled(void);
  138.    HBRUSH WINAPI Ctl3dCtlColorEx(UINT wm, WPARAM wParam, LPARAM lParam);
  139.    BOOL WINAPI Ctl3dColorChange(void);
  140.    BOOL WINAPI Ctl3dSubclassCtl(HWND);
  141.    LONG WINAPI Ctl3dDlgFramePaint(HWND, UINT, WPARAM, LPARAM);
  142.    
  143.    BOOL WINAPI Ctl3dAutoSubclass(HINSTANCE);
  144.    
  145.    BOOL WINAPI Ctl3dRegister(HINSTANCE);
  146.    BOOL WINAPI Ctl3dUnregister(HINSTANCE);
  147.    
  148.  private:                                    
  149.  
  150.    BOOL _bInit;                  
  151.    SHORT _sError;
  152.    HINSTANCE _hinstDll;
  153.    HINSTANCE _hinstSelfAuto;
  154.    
  155.       
  156.    PFNSUBCLASSDLG _pfnCtl3dSubclassDlg;
  157.    PFNSUBCLASSDLGEX _pfnCtl3dSubclassDlgEx;
  158.    PFNGETVER _pfnCtl3dGetVer;
  159.    PFNENABLED _pfnCtl3dEnabled;
  160.    PFNCTLCOLOREX _pfnCtl3dCtlColorEx;
  161.    PFNCOLORCHANGE _pfnCtl3dColorChange;
  162.    PFNSUBCLASSCTL _pfnCtl3dSubclassCtl;
  163.    PFNDLGFRAMEPAINT _pfnCtl3dDlgFramePaint;
  164.    PFNAUTOSUBCLASS _pfnCtl3dAutoSubclass;
  165.    PFNREGISTER _pfnCtl3dRegister;
  166.    PFNUNREGISTER _pfnCtl3dUnregister;
  167.  
  168.    void GetFunctions();
  169.    void InitPrivate();
  170.    void AutoAuto();                   
  171.    HINSTANCE GetInstance();
  172.    LONG DoCopy(HFILE hfSrc, HFILE hfDest);
  173.  
  174. };
  175.  
  176.  
  177.  
  178.  
  179. #endif   //__UTY99CTL_H