home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK8 / MFC / SAMPLES / MULTIPAD / MULTIPAD.H$ / multipad
Encoding:
Text File  |  1992-03-16  |  4.6 KB  |  188 lines

  1. // multipad.h : Defines the class interfaces for the frame and child.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #ifndef __MULTIPAD_H__
  14. #define __MULTIPAD_H__
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17.  
  18. #define EXPORT _export
  19.  
  20. #include <afxwin.h>
  21. #include <afxdlgs.h>
  22. #include "bar.h"
  23. #include "resource.h"
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26.  
  27. CDC* GetPrinterDC();
  28. class CMPChild;
  29.  
  30. class CMultiPad : public CWinApp
  31. {
  32. public:
  33.     CMultiPad(const char* pAppName) : CWinApp(pAppName)
  34.         { }
  35.     BOOL InitInstance();
  36.     int ExitInstance();
  37. };
  38.  
  39. class CMPFrame : public CMDIFrameWnd
  40. {
  41. protected:
  42.     class CMPChild* m_pActiveChild;
  43.  
  44. public:
  45.     CMPFrame() {};
  46.     CMPFrame(const char* szTitle);
  47.     
  48.     BOOL QueryCloseAllChildren();
  49.     void CloseAllChildren();
  50.     void GetInitializationData();
  51.     CMPChild* AlreadyOpen(char* szFile);
  52.     void ReadFile(const char* szFile);
  53.  
  54.     static CMPFrame* GetMDIFrameWnd() 
  55.         { return (CMPFrame*)(AfxGetApp()->m_pMainWnd); }
  56.  
  57.     static CMPChild* GetActiveChild() 
  58.         { return ((CMPFrame*)(AfxGetApp()->m_pMainWnd))->m_pActiveChild; }
  59.     static void SetActiveChild(CMPChild* pActiveChild) 
  60.         { GetMDIFrameWnd()->m_pActiveChild = pActiveChild; }
  61.  
  62. protected:
  63.     void ReadFile();
  64.  
  65.     afx_msg void OnInitMenu(CMenu* pMenu);
  66.     afx_msg void OnClose();
  67.     afx_msg BOOL OnQueryEndSession();
  68.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  69.     afx_msg void OnSize(UINT nType, int cx, int cy);
  70.     afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  71.     
  72.     afx_msg void CmdFileNew();
  73.     afx_msg void CmdFileOpen();
  74.     afx_msg void CmdFileExit();
  75.     afx_msg void CmdToggleMenu();
  76.     afx_msg void CmdFileMRU();
  77.     
  78.     afx_msg void CmdMDITile();
  79.     afx_msg void CmdMDICascade();
  80.     afx_msg void CmdMDIIconArrange();
  81.     afx_msg void CmdWinCloseAll();
  82.     
  83.     afx_msg void CmdHelpAbout();
  84.  
  85.     afx_msg void CmdFind();
  86.     afx_msg void CmdFindPrev();
  87.     afx_msg void CmdFindNext();
  88.     
  89.     DECLARE_MESSAGE_MAP()
  90.  
  91.     BOOL m_bShortMenu;
  92.     CStatBar m_statBar;
  93.  
  94.     // Search helpers
  95.     afx_msg LONG CmdFindHelper(UINT wParam, LONG lParam); // for m_nMsgFind
  96.     static UINT m_nMsgFind;
  97.     static CString m_strFind;
  98.     static CFindReplaceDialog* m_pFindReplace;
  99. };
  100.  
  101. class CMPChild : public CMDIChildWnd
  102. {
  103. public:
  104.     BOOL m_bChanged;
  105.     BOOL m_bUntitled;
  106.     BOOL m_bWordWrap;
  107.     CEdit m_edit;
  108.     CFont m_font;
  109.     
  110.     CMPChild() : m_font(), m_edit() 
  111.         { } 
  112.     CMPChild(char* szName);
  113.     
  114.     BOOL QueryCloseChild();
  115.     void SaveFile();
  116.     BOOL ChangeFile();
  117.     void PrintFile();
  118.     
  119.     int LoadFile(char* szFile);
  120.     
  121.     void SetWrap(BOOL bWrap);
  122.     
  123.     // Find engine stuff
  124.     enum { searchUp = -1, searchDown = +1};
  125.     BOOL FindText(LPCSTR szSearch,
  126.         int nDirection = searchDown, 
  127.         BOOL bMatchCase = FALSE, 
  128.         BOOL bWholeWord = FALSE); // does the actual search
  129.  
  130. protected:
  131.     afx_msg int OnCreate(LPCREATESTRUCT);
  132.     afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivate, CWnd* pDeactivate);
  133.     afx_msg BOOL OnQueryEndSession();
  134.     afx_msg void OnClose();
  135.     afx_msg void OnSize(UINT nType, int cx, int cy);
  136.     afx_msg void OnSetFocus(CWnd* pWnd);
  137.     afx_msg void OnEditChange();
  138.     afx_msg void OnEditErrSpace();
  139.     afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  140.     
  141.     virtual void PostNcDestroy();
  142.  
  143.     // Command handlers
  144.     afx_msg void CmdSetFont();
  145.     afx_msg void CmdFileSave();
  146.     afx_msg void CmdFileSaveAs();
  147.     afx_msg void CmdUndo();
  148.     afx_msg void CmdCut();
  149.     afx_msg void CmdCopy();
  150.     afx_msg void CmdPaste();
  151.     afx_msg void CmdClear();
  152.     afx_msg void CmdSelectAll();
  153.     afx_msg void CmdWordWrap();
  154.  
  155.     DECLARE_MESSAGE_MAP()
  156. };
  157.  
  158. class CPrinter
  159. {
  160. private:
  161.     HWND hwndPDlg;      // Handle to the cancel print dialog
  162.     HANDLE hInitData;   // handle to initialization data
  163.     
  164.     class CPrintCanDlg* pdlg;
  165.     UINT fError;
  166.     
  167. public:
  168.     BOOL fAbort;        // TRUE if the user has aborted the print job
  169.     CPrintDialog printDlg;
  170.     CDC* pdc;
  171.     
  172.     char szTitle [32];  // Global pointer to job title
  173.     
  174.     CPrinter() : printDlg(FALSE) {};
  175.                 
  176.     BOOL        StartJob(char* szDocName);
  177.     void        EndJob();
  178.     
  179.     friend BOOL FAR PASCAL EXPORT AbortProc(HDC, int);
  180. };
  181.  
  182. short MPError(int bFlags, int id, ...);
  183.  
  184. /////////////////////////////////////////////////////////////////////////////
  185.  
  186. #endif // __MULTIPAD_H__
  187.  
  188.