home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lora299s.zip / CPC.H < prev    next >
C/C++ Source or Header  |  1998-05-12  |  6KB  |  211 lines

  1.  
  2. // LoraBBS Version 2.99 Free Edition
  3. // Copyright (C) 1987-98 Marco Maccaferri
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #if defined(__OS2__)
  20. #define IDOK            1
  21. #define IDCANCEL        2
  22. #define IDHELP          3
  23.  
  24. #define IDYES           MBID_YES
  25. #endif
  26.  
  27. #if defined(__NT__)
  28. #include <commctrl.h>
  29.  
  30. #define WM_CONTROL      WM_COMMAND
  31.  
  32. #define CN_ENTER        LBN_DBLCLK
  33. #define LN_SELECT       LBN_SELCHANGE
  34. #endif
  35.  
  36. #define LVC_LEFT        0
  37. #define LVC_CENTER      1
  38. #define LVC_RIGHT       2
  39.  
  40. #if defined(__OS2__)
  41.  
  42. typedef struct {
  43.    PSZ    pszData;
  44.    CHAR   Data[256];
  45. } COLUMNDATA;
  46.  
  47. typedef struct {
  48.    RECORDCORE RecordCore;
  49.    COLUMNDATA Column[1];
  50. } LV_LISTDATA, *LV_PLISTDATA;
  51.  
  52. #endif
  53.  
  54. struct CPC_MSGMAP_ENTRY;
  55.  
  56. #define DECLARE_MESSAGE_MAP() \
  57.     static CPC_MSGMAP_ENTRY _messageEntries[]; \
  58.     virtual CPC_MSGMAP_ENTRY *GetMessageMap (VOID); \
  59.  
  60. class CWnd
  61. {
  62. public:
  63.    virtual USHORT OnCreate (VOID);
  64.  
  65.    HWND   m_hWnd;
  66.    UINT   m_msg;
  67. #if defined(__OS2__)
  68.    MPARAM m_mp1;
  69.    MPARAM m_mp2;
  70. #elif defined(__NT__)
  71.    WPARAM m_wParam;
  72.    LPARAM m_lParam;
  73. #endif
  74.  
  75.    USHORT Create (int x, int y, int dx, int dy, PSZ title = NULL);
  76.    int    MessageBox (PSZ text, PSZ caption, int button);
  77.    VOID   SetWindowTitle (PSZ title);
  78.    VOID   ShowWindow (int nCmdShow);
  79.  
  80. private:
  81.    DECLARE_MESSAGE_MAP ()
  82.  
  83. #if defined(__OS2__)
  84.    friend MRESULT EXPENTRY CFrameWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  85. #elif defined(__NT__)
  86.    friend LRESULT CALLBACK CFrameWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  87. #endif
  88. };
  89.  
  90. class CWinApp
  91. {
  92. public:
  93.    CWinApp (void);
  94.    ~CWinApp (void);
  95.  
  96. #if defined(__NT__)
  97.    int nCmdShow;
  98.    HINSTANCE hinstCurrent;
  99.    HINSTANCE hinstPrev;
  100. #endif
  101.    class  CWnd *m_pMainWnd;
  102.  
  103.    virtual USHORT InitInstance (VOID);
  104.  
  105.    VOID   Run (VOID);
  106.  
  107. private:
  108. };
  109.  
  110. class CDialog : public CWnd
  111. {
  112. public:
  113.    CDialog (PSZ dialogTemplate, HWND p_hWnd);
  114.    virtual ~CDialog (void);
  115.  
  116.    virtual LONG   DoModal (VOID);
  117.    virtual VOID   OnCancel (VOID);
  118.    virtual VOID   OnHelp (VOID);
  119.    virtual USHORT OnInitDialog (VOID);
  120.    virtual VOID   OnOK (VOID);
  121.  
  122. protected:
  123.    VOID   Center (VOID);
  124.    VOID   EndDialog (USHORT Result);
  125.    VOID   GetDlgItemText (int id, PSZ text, USHORT size);
  126.    VOID   GetDlgItemText (int id, USHORT size, PSZ text);
  127.    USHORT GetDlgItemTextLength (int id);
  128.    VOID   SetFocus (int id);
  129.    VOID   SetDlgItemText (int id, PSZ text);
  130.    VOID   WinHelp (PSZ help_file, int topic_id, PSZ title = "Application Help");
  131.  
  132.    USHORT BM_QueryCheck (int id);
  133.    VOID   BM_SetCheck (int id, USHORT value);
  134.    VOID   CB_AddString (int id, PSZ value);
  135.    VOID   CB_SelectItem (int id, USHORT value);
  136.    USHORT CB_QuerySelection (int id);
  137.    VOID   EM_SetTextLimit (int id, USHORT value);
  138.    VOID   LM_AddString (int id, PSZ value);
  139.    VOID   LM_DeleteAll (int id);
  140.    VOID   LM_DeleteItem (int id, USHORT value);
  141.    VOID   LM_SelectItem (int id, USHORT value);
  142.    USHORT LM_QueryItemCount (int id);
  143.    VOID   LM_QueryItemText (int id, USHORT value, USHORT size, PSZ text);
  144.    USHORT LM_QuerySelection (int id);
  145.    VOID   LM_SetItemText (int id, USHORT value, PSZ text);
  146.    VOID   LVM_AllocateColumns (int id, int value);
  147.    VOID   LVM_DeleteAll (int id);
  148.    VOID   LVM_DeleteItem (int id, int item);
  149.    VOID   LVM_InsertColumn (int id, PSZ text, int align);
  150.    VOID   LVM_InsertItem (int id);
  151.    VOID   LVM_InvalidateView (int id);
  152.    int    LVM_QuerySelectedItem (int id);
  153.    VOID   LVM_SelectItem (int id, int item);
  154.    VOID   LVM_SetItemText (int id, int column, PSZ text);
  155.    VOID   LVM_SetItemText (int id, int item, int column, PSZ text);
  156.    int    LVM_QueryItemCount (int id);
  157.    VOID   LVM_QueryItemText (int id, int item, int column, PSZ text);
  158.    LONG   SPBM_QueryValue (int id);
  159.    VOID   SPBM_SetCurrentValue (int id, LONG value);
  160.    VOID   SPBM_SetLimits (int id, LONG highest, LONG lowest);
  161.  
  162. private:
  163.    SHORT  lv_Selected;
  164.    CHAR   dlgTemplate[64];
  165.    HWND   owner_hWnd;
  166.    HWND   help_hWnd;
  167.  
  168.    DECLARE_MESSAGE_MAP ()
  169.  
  170. #if defined(__OS2__)
  171.    friend MRESULT EXPENTRY CDialogDlgProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  172. #elif defined(__NT__)
  173.    friend BOOL CALLBACK CDialogDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  174. #endif
  175. };
  176.  
  177. typedef void (CWnd::*CPC_PMSG)(void);   // routine to call (or special value)
  178.  
  179. struct CPC_MSGMAP_ENTRY {
  180.    UINT nMessage;    // windows message
  181.    UINT nCode;       // control code or WM_NOTIFY code
  182.    UINT nID;         // control ID (or 0 for windows messages)
  183.    UINT nLastID;     // used for entries specifying a range of control id's
  184.    UINT nSig;        // signature type (action) or pointer to message #
  185.    CPC_PMSG pfn;     // routine to call (or special value)
  186. };
  187.  
  188. #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
  189.     CPC_MSGMAP_ENTRY *theClass::GetMessageMap (VOID) \
  190.         { return (&theClass::_messageEntries[0]); } \
  191.     CPC_MSGMAP_ENTRY theClass::_messageEntries[] = \
  192.     { \
  193.  
  194. #define END_MESSAGE_MAP() \
  195.         {0, 0, 0, 0, 0, NULL } \
  196.     }; \
  197.  
  198. #define ON_COMMAND(id, memberFxn) \
  199.     { WM_COMMAND, 0, (UINT)id, (UINT)id, 0, (CPC_PMSG)memberFxn },
  200.  
  201. #define ON_CONTROL(wNotifyCode, id, memberFxn) \
  202.     { WM_CONTROL, (UINT)wNotifyCode, (UINT)id, (UINT)id, 0, (CPC_PMSG)memberFxn },
  203.  
  204. #define ON_MESSAGE(message, memberFxn) \
  205.     { message, 0, 0, 0, 0, (CPC_PMSG)memberFxn },
  206.  
  207. #define ON_NOTIFY(wNotifyCode, id, memberFxn) \
  208.     { WM_NOTIFY, (UINT)wNotifyCode, (UINT)id, (UINT)id, 0, (CPC_PMSG)memberFxn }, \
  209.     { WM_COMMAND, (UINT)wNotifyCode, (UINT)id, (UINT)id, 0, (CPC_PMSG)memberFxn },
  210.  
  211.