home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Samples / vfTest / PalHook.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  1.5 KB  |  55 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. protected:
  22.     CPalette* m_pPalette; // ptr to palette
  23.  
  24.     DECLARE_DYNAMIC(CPalMsgHandler);
  25.  
  26.     // These are similar to, but NOT the same as the equivalent CWnd fns.
  27.     // Rarely, if ever need to override.
  28.     //
  29.     virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);    
  30.     virtual void OnPaletteChanged(CWnd* pFocusWnd);
  31.     virtual BOOL OnQueryNewPalette();
  32.     virtual void OnSetFocus(CWnd* pOldWnd);
  33.  
  34.     // Override this if you realize your palette some other way
  35.     // (not by having a ptr to a CPalette).
  36.     //
  37.     virtual int  DoRealizePalette(BOOL bForeground);
  38.  
  39. public:
  40.     CPalMsgHandler();
  41.     ~CPalMsgHandler();
  42.  
  43.     // Get/Set palette obj
  44.     CPalette* GetPalette()                { return m_pPalette; }
  45.     void SetPalette(CPalette* pPal)    { m_pPalette = pPal; }
  46.  
  47.     // Call this to install the palette handler
  48.     BOOL Install(CWnd* pWnd, CPalette* pPal) {
  49.         m_pPalette = pPal;
  50.         return HookWindow(pWnd);
  51.     }
  52. };
  53.  
  54. #endif
  55.