home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / PEEPER.PAK / PEEPER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.4 KB  |  121 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1993, 1995 by Borland International, All Rights Reserved
  4. //
  5. //   Peeper is a program that allows the user to select some windows and
  6. //   perform one or more actions on those windows.  Actions include:
  7. //      . Changing the window text (caption).
  8. //      . Sending messages.
  9. //
  10. //   The windows that are selected are put into a list which can be cleared
  11. //   at any time to start over.
  12. //
  13. //   To choose a window click on the 'Peep!' button and when the mouse if over
  14. //   a window that you want to choose, click the left mouse button.  To stop
  15. //   'peeping' click the right mouse button.  You can't peep Peeper.
  16. //----------------------------------------------------------------------------
  17. #if !defined(PEEPER_H)
  18. #define PEEPER_H
  19.  
  20. #include <owl/applicat.h>
  21. #include <owl/dialog.h>
  22. #include <classlib/vectimp.h>
  23. #include "peeper.rh"
  24.  
  25. //
  26. // Global functions used with ForEach():
  27. //
  28. void SendWMSetText(HWND& hWnd, void* p);
  29. void SendSysMessage(HWND& hWnd, void* p);
  30. void SendWMMessage(HWND& hWnd, void* p);
  31.  
  32. //////////////////////////////////////////////////////////////////////
  33.  
  34. //
  35. // Handles the 'peeping' process by capturing, tracking and releasing
  36. // the mouse.
  37. //
  38. class TClientWindow : public TWindow {
  39.   public:
  40.     TClientWindow() : TWindow(0, "") {}
  41.  
  42.   protected:
  43.     void  DisplayWinInfo();
  44.     void  EvLButtonDown(UINT mod_keys, TPoint& point);
  45.     void  EvRButtonDown(UINT mod_keys, TPoint& point);
  46.  
  47.   DECLARE_RESPONSE_TABLE(TClientWindow);
  48. };
  49.  
  50. //////////////////////////////////////////////////////////////////////
  51.  
  52. // Transfer buffer for the messages dialog.
  53. struct MessagesTB {
  54.    MessagesTB()
  55.    {
  56.       MaxCB = MinCB = PaintCB = RestoreCB = PasteCB = CloseCB = 0;
  57.    }
  58.  
  59.    uint16  MaxCB, MinCB, PaintCB, RestoreCB, PasteCB, CloseCB;
  60. };
  61.  
  62. //
  63. // Dialog that contains checkboxs that reprsent the messages the user wants
  64. // to send to the selected windows.
  65. //
  66. class TMessagesDialog : public TDialog {
  67.   public:
  68.     TMessagesDialog(TWindow* parent, MessagesTB* mtb)
  69.       : TDialog(parent, IDD_MESSAGES)
  70.     {
  71.       MaximizeCB = new TCheckBox(this, IDC_MAXIMIZE);
  72.       MinimizeCB = new TCheckBox(this, IDC_MINIMIZE);
  73.       PaintCB = new TCheckBox(this, IDC_PAINT);
  74.       RestoreCB = new TCheckBox(this, IDC_RESTORE);
  75.       PasteCB = new TCheckBox(this, IDC_PASTE);
  76.       CloseCB = new TCheckBox(this, IDC_CLOSE);
  77.       SetTransferBuffer(mtb);
  78.     }
  79.  
  80.   private:
  81.     TCheckBox*  MaximizeCB;
  82.     TCheckBox*  MinimizeCB;
  83.     TCheckBox*  PaintCB;
  84.     TCheckBox*  RestoreCB;
  85.     TCheckBox*  PasteCB;
  86.     TCheckBox*  CloseCB;
  87. };
  88.  
  89. //////////////////////////////////////////////////////////////////////
  90.  
  91. //
  92. // Peeper application. Handles most of the messages.
  93. //
  94. class TPeeper : public TApplication {
  95.   public:
  96.     TPeeper();
  97.    ~TPeeper();
  98.  
  99.   protected:
  100.     void  InitMainWindow();
  101.  
  102.   private:
  103.     TWindow*           Client;
  104.     TStatic*           SelWinText;
  105.     TListBox*          SelectedWindows;
  106.     TControlBar*       Actions;
  107.     TMessageBar*       StatusLine;
  108.     TCVectorImp<HWND>* WindowList;
  109.  
  110.     void  CmPeeping();
  111.     void  CmChangeCaption();
  112.     void  CmClearWindowList();
  113.     void  CmSendMessage();
  114.     void  CmHelp();
  115.  
  116.   friend class TClientWindow;
  117.   DECLARE_RESPONSE_TABLE(TPeeper);
  118. };
  119.  
  120. #endif
  121.