home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / c / cuj9301.zip / 1101036A < prev    next >
Text File  |  1992-11-03  |  1KB  |  47 lines

  1. /* LISTING 1: A C++ class to encapsulate the MS Windows
  2.    WNDCLASS.
  3. */
  4. #include "windows.h"
  5.  
  6. typedef int         BOOL;
  7. typedef WNDPROC     MYWNDPROC;
  8. typedef HINSTANCE   MYHINSTANCE;
  9. typedef HCURSOR     MYHCURSOR;
  10. typedef HBRUSH      MYHBRUSH;
  11.  
  12. class MyWndClass
  13. {
  14. public:
  15.   MyWndClass (char *, MYWNDPROC, MYHINSTANCE, char *);
  16.   void SetCursor (MYHCURSOR hCursor)
  17.       { wndclass.hCursor = hCursor; }
  18.   void SetBackground (MYHBRUSH hbrBackground)
  19.       { wndclass.hbrBackground = hbrBackground; }
  20.   void SetMenu (char *szMenuName)
  21.       { wndclass.lpszMenuName = szMenuName; }
  22.   BOOL RegisterClass (void)
  23.       { return (::RegisterClass (&wndclass)); }
  24.  
  25. private:
  26.   // Default constructor is inaccessible.
  27.   MyWndClass (void);
  28.   WNDCLASS wndclass;
  29. };
  30.  
  31. MyWndClass::MyWndClass (char *szAppName, MYWNDPROC
  32.     WndProc, MYHINSTANCE hInstance, char *szMenuName)
  33. {
  34.     wndclass.style = CS_HREDRAW | CS_VREDRAW;
  35.     wndclass.lpfnWndProc = WndProc;
  36.     wndclass.cbClsExtra = 0;
  37.     wndclass.cbWndExtra = 0;
  38.     wndclass.hInstance = hInstance;
  39.     wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  40.     wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
  41.     wndclass.hbrBackground =
  42.                 GetStockObject (WHITE_BRUSH);
  43.     wndclass.lpszMenuName = szMenuName;
  44.     wndclass.lpszClassName = szAppName;
  45. }
  46.  
  47.