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

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. // PURPOSE:
  9. //    Contains declarations for all globally scoped names in the program.
  10. //
  11.  
  12.  
  13. //-------------------------------------------------------------------------
  14. // Functions for handling main window messages.  The message-dispatching
  15. // mechanism expects all message-handling functions to have the following
  16. // prototype:
  17. //
  18. //     LRESULT FunctionName(HWND, UINT, WPARAM, LPARAM);
  19.  
  20. // **TODO**  Add message-handling function prototypes here.  Be sure to
  21. //           add the function names to the main window message table in
  22. //           WritePad.c.
  23.  
  24. LRESULT MsgFindReplace    (HWND, UINT, WPARAM, LPARAM);         // Search
  25. LRESULT MsgCommand        (HWND, UINT, WPARAM, LPARAM);
  26. LRESULT MsgDestroy        (HWND, UINT, WPARAM, LPARAM);
  27. LRESULT MsgCreate         (HWND, UINT, WPARAM, LPARAM);
  28. LRESULT MsgInitMenu       (HWND, UINT, WPARAM, LPARAM);
  29. LRESULT MsgMenuSelect     (HWND, UINT, WPARAM, LPARAM);
  30. LRESULT MsgNotify         (HWND, UINT, WPARAM, LPARAM);
  31. LRESULT MsgTimer          (HWND, UINT, WPARAM, LPARAM);
  32. LRESULT MsgSize           (HWND, UINT, WPARAM, LPARAM);
  33. LRESULT MsgClose          (HWND, UINT, WPARAM, LPARAM);
  34. LRESULT MsgQueryEndSession(HWND, UINT, WPARAM, LPARAM);
  35.  
  36.  
  37. //-------------------------------------------------------------------------
  38. // Functions for handling main window commands--ie. functions for
  39. // processing WM_COMMAND messages based on the wParam value.
  40. // The message-dispatching mechanism expects all command-handling
  41. // functions to have the following prototype:
  42. //
  43. //     LRESULT FunctionName(HWND, WORD, WORD, HWND);
  44.  
  45. // **TODO**  Add message-handling function prototypes here.  Be sure to
  46. //           add the function names to the main window command table in
  47. //           WritePad.c.
  48.  
  49. LRESULT CmdExit(HWND, WORD, WORD, HWND);
  50. LRESULT CmdAbout(HWND, WORD, WORD, HWND);
  51.  
  52. //
  53. // File Commands
  54. //
  55.  
  56. LRESULT CmdFileNew(HWND, WORD, WORD, HWND);
  57. LRESULT CmdFileOpen(HWND, WORD, WORD, HWND);
  58. LRESULT CmdFileSave(HWND, WORD, WORD, HWND);
  59. LRESULT CmdFileSaveAs(HWND, WORD, WORD, HWND);
  60. LRESULT CmdFilePrint(HWND, WORD, WORD, HWND);
  61. LRESULT CmdFilePrintSU(HWND, WORD, WORD, HWND);
  62. LRESULT CmdFilePageSU(HWND, WORD, WORD, HWND);
  63. LRESULT CmdFileClose(HWND, WORD, WORD, HWND);
  64. LRESULT CmdSearchFindReplace(HWND, WORD, WORD, HWND);             // Search
  65. LRESULT CmdSearchFindNext(HWND, WORD, WORD, HWND);
  66.  
  67.  
  68. //
  69. // Edit Commands
  70. //
  71.  
  72. LRESULT CmdClip(HWND, WORD, WORD, HWND);      // Clipboard
  73. LRESULT CmdBold        (HWND, WORD, WORD, HWND);
  74. LRESULT CmdItalic      (HWND, WORD, WORD, HWND);
  75. LRESULT CmdUnderline   (HWND, WORD, WORD, HWND);
  76. LRESULT CmdFontDialog  (HWND, WORD, WORD, HWND);
  77. LRESULT CmdIncreaseFont(HWND, WORD, WORD, HWND);
  78. LRESULT CmdDecreaseFont(HWND, WORD, WORD, HWND);
  79.  
  80. //
  81. // Window Commands
  82. //
  83.  
  84. LRESULT CmdWindowTile(HWND, WORD, WORD, HWND);
  85. LRESULT CmdWindowCascade(HWND, WORD, WORD, HWND);
  86. LRESULT CmdWindowIcons(HWND, WORD, WORD, HWND);
  87. LRESULT CmdWindowCloseAll(HWND, WORD, WORD, HWND);
  88.  
  89.  
  90. //-------------------------------------------------------------------------
  91. // Global type declarations.
  92.  
  93. typedef enum {
  94.     frtFind,
  95.     frtReplace,
  96.     frtRepAll
  97. } FRT;  // Find/Replace tag
  98.  
  99.  
  100.  
  101. //-------------------------------------------------------------------------
  102. // Global function prototypes.
  103.  
  104. // **TODO**  Add global function prototypes here.
  105.  
  106. BOOL InitApplication(HINSTANCE, int);
  107. BOOL CenterWindow(HWND, HWND);
  108. BOOL InitMDIChild(HINSTANCE);
  109. HWND GetEditWindow(HWND);
  110. VOID Open(LPSTR, BOOL, HWND);                               // File
  111. VOID SaveAs(LPSTR, LPSTR, HWND);
  112. BOOL QuerySaveFile(HWND);
  113. VOID SetEditText(HWND, HANDLE);
  114. char *LockEditText(HWND);
  115. VOID UnlockEditText(HWND);
  116. BOOL CreateMDIChild(LPSTR);
  117. HWND GetActiveMDIChild(VOID);
  118. VOID Print                                                  // Print
  119.     (HWND, HDC, BOOL, BOOL, BOOL, BOOL, UINT, UINT, UINT, HGLOBAL);
  120. DWORD GetPageRange(VOID);
  121. BOOL InitFindReplace(VOID);                                 // Search
  122. BOOL IsFindReplaceMsg(LPMSG);
  123. BOOL CanFind(VOID);
  124. VOID FindReplace(char *, char *, FRT, BOOL, BOOL, BOOL);
  125.  
  126. BOOL InitRuler(HINSTANCE);
  127. HWND CreateRuler(HWND, UINT, int, int);
  128.  
  129. BOOL InitPreview(HINSTANCE hInstance);
  130. int PrintPreview(HWND hwndOwner, HWND hwndEdit, HDC hdcTarget);
  131. HDC GetCurrentPrinterDC(void);
  132. char *GetFName(VOID);
  133.  
  134. extern char szFName[256];
  135.  
  136.  
  137. // Callback functions.  These are called by Windows.
  138.  
  139. // **TODO**  Add new callback function prototypes here.
  140.  
  141. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  142. LRESULT CALLBACK MDIChildWndProc(HWND, UINT, WPARAM, LPARAM);
  143. LRESULT CALLBACK Ruler(HWND, UINT, WPARAM, LPARAM);
  144.  
  145.  
  146. //-------------------------------------------------------------------------
  147. // Global macros
  148.  
  149. #define WINDOWMENU  3
  150. #define MAKEBOOL(i) ((BOOL) !!(i))                          // General
  151.  
  152.  
  153. //-------------------------------------------------------------------------
  154. // Global variable declarations.
  155.  
  156. extern HINSTANCE hInst;          // The current instance handle
  157. extern char      szAppName[];    // The name of this application
  158. extern char      szTitle[];      // The title bar text
  159. extern HCURSOR   hcursHourGlass; // Hourglass cursor
  160.  
  161. // **TODO**  For NON-MDI applications, uncomment line 1 below and comment
  162. //           line 2.  For MDI applications, uncomment line 2 below, comment
  163. //           line 1, and then define hwndMDIClient as a global variable in
  164. //           INIT.C
  165. //#define hwndMDIClient NULL     /* (1) Stub for NON-MDI applications. */
  166. extern HWND hwndMDIClient;       /* (2) For MDI applications.          */
  167.  
  168. // **WritePad** MDI Frame and Client windows must be accessable to many modules.
  169. extern HWND hwndFrame;           // The MDI Frame window
  170. extern UINT cOpen;
  171. extern UINT cUntitled;
  172.  
  173.  
  174.  
  175. //-------------------------------------------------------------------------
  176. // Message and command dispatch infrastructure.  The following type
  177. // definitions and functions are used by the message and command dispatching
  178. // mechanism and do not need to be changed.
  179.  
  180.     // Function pointer prototype for message handling functions.
  181. typedef LRESULT (*PFNMSG)(HWND,UINT,WPARAM,LPARAM);
  182.  
  183.     // Function pointer prototype for command handling functions.
  184. typedef LRESULT (*PFNCMD)(HWND,WORD,WORD,HWND);
  185.  
  186.     // Enumerated type used to determine which default window procedure
  187.     // should be called by the message- and command-dispatching mechanism
  188.     // if a message or command is not handled explicitly.
  189. typedef enum
  190. {
  191.    edwpNone,            // Do not call any default procedure.
  192.    edwpWindow,          // Call DefWindowProc.
  193.    edwpDialog,          // Call DefDlgProc (This should be used only for
  194.                         // custom dialogs - standard dialog use edwpNone).
  195.    edwpMDIChild,        // Call DefMDIChildProc.
  196.    edwpMDIFrame         // Call DefFrameProc.
  197. } EDWP;                // Enumeration for Default Window Procedures
  198.  
  199.     // This structure maps messages to message handling functions.
  200. typedef struct _MSD
  201. {
  202.     UINT   uMessage;
  203.     PFNMSG pfnmsg;
  204. } MSD;                 // MeSsage Dispatch structure
  205.  
  206.     // This structure contains all of the information that a window
  207.     // procedure passes to DispMessage in order to define the message
  208.     // dispatching behavior for the window.
  209. typedef struct _MSDI
  210. {
  211.     int  cmsd;          // Number of message dispatch structs in rgmsd
  212.     MSD *rgmsd;         // Table of message dispatch structures
  213.     EDWP edwp;          // Type of default window handler needed.
  214. } MSDI, FAR *LPMSDI;    // MeSsage Dipatch Information
  215.  
  216.     // This structure maps command IDs to command handling functions.
  217. typedef struct _CMD
  218. {
  219.     WORD   wCommand;
  220.     PFNCMD pfncmd;
  221. } CMD;                  // CoMmand Dispatch structure
  222.  
  223.     // This structure contains all of the information that a command
  224.     // message procedure passes to DispCommand in order to define the
  225.     // command dispatching behavior for the window.
  226. typedef struct _CMDI
  227. {
  228.     int  ccmd;          // Number of command dispatch structs in rgcmd
  229.     CMD *rgcmd;         // Table of command dispatch structures
  230.     EDWP edwp;          // Type of default window handler needed.
  231. } CMDI, FAR *LPCMDI;    // CoMmand Dispatch Information
  232.  
  233.     // Message and command dispatching functions.  They look up messages
  234.     // and commands in the dispatch tables and call the appropriate handler
  235.     // function.
  236. LRESULT DispMessage(LPMSDI, HWND, UINT, WPARAM, LPARAM);
  237. LRESULT DispCommand(LPCMDI, HWND, WPARAM, LPARAM);
  238.  
  239.     // Message dispatch information for the main window
  240. extern MSDI msdiMain;
  241.     // Command dispatch information for the main window
  242. extern CMDI cmdiMain;
  243.