home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Samples / VfbEx / PalHook.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  1.5 KB  |  57 lines

  1. ////////////////////////////////////////////////////////////////
  2. // Copyright 1996 Microsoft Systems Journal. 
  3. // If this code works, it was written by Paul DiLascia.
  4. // If not, I don't know who wrote it.
  5. //
  6. #ifndef _PALMSGHOOK_H
  7. #define _PALMSGHOOK_H
  8.  
  9. #include "MsgHook.h"
  10.  
  11. //////////////////
  12. // Generic palette message handler makes handling palette messages easy.
  13. // To use:
  14. //
  15. // * Instaniate a CPalMsgHandler in your main frame and
  16. //   every CWnd class that needs to realize palettes (e.g., your view).
  17. // * Call Install to install.
  18. // * Call DoRealizePalette(TRUE) from your view's OnInitialUpdate fn.
  19. //
  20. class CPalMsgHandler : public CMsgHook 
  21. {
  22. protected:
  23.     CPalette* m_pPalette; // ptr to palette
  24.  
  25.     DECLARE_DYNAMIC(CPalMsgHandler);
  26.  
  27.     // These are similar to, but NOT the same as the equivalent CWnd fns.
  28.     // Rarely, if ever need to override.
  29.     //
  30.     virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);    
  31.     virtual void OnPaletteChanged(CWnd* pFocusWnd);
  32.     virtual BOOL OnQueryNewPalette();
  33.     virtual void OnSetFocus(CWnd* pOldWnd);
  34.  
  35.     // Override this if you realize your palette some other way
  36.     // (not by having a ptr to a CPalette).
  37.     //
  38.     virtual int  DoRealizePalette(BOOL bForeground);
  39.  
  40. public:
  41.     CPalMsgHandler();
  42.     ~CPalMsgHandler();
  43.  
  44.     // Get/Set palette obj
  45.     CPalette* GetPalette()            { return m_pPalette; }
  46.     void SetPalette(CPalette* pPal)    { m_pPalette = pPal; }
  47.  
  48.     // Call this to install the palette handler
  49.     BOOL Install(CWnd* pWnd, CPalette* pPal) 
  50.     {
  51.         m_pPalette = pPal;
  52.         return HookWindow(pWnd);
  53.     }
  54. };
  55.  
  56. #endif
  57.