Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
9.8 KiB

  1. /* SxSpad.h */
  2. #define NOCOMM
  3. #define NOSOUND
  4. #include <windows.h>
  5. #include <ole2.h>
  6. #include <commdlg.h>
  7. // we need this for CharSizeOf(), ByteCountOf(),
  8. #include "uniconv.h"
  9. /* handy debug macro */
  10. #define ODS OutputDebugString
  11. typedef enum _SP_FILETYPE {
  12. FT_UNKNOWN=-1,
  13. FT_ANSI=0,
  14. FT_UNICODE=1,
  15. FT_UNICODEBE=2,
  16. FT_UTF8=3,
  17. } SP_FILETYPE;
  18. #define BOM_UTF8_HALF 0xBBEF
  19. #define BOM_UTF8_2HALF 0xBF
  20. /* openfile filter for all text files */
  21. #define FILE_TEXT 1
  22. #define PT_LEN 40 /* max length of page setup strings */
  23. #define CCHFILTERMAX 80 /* max. length of filter name buffers */
  24. // Menu IDs
  25. #define ID_APPICON 1 /* must be one for explorer to find this */
  26. #define ID_ICON 2
  27. #define ID_MENUBAR 1
  28. // Dialog IDs
  29. #define IDD_ABORTPRINT 11
  30. #define IDD_PAGESETUP 12
  31. #define IDD_SAVEDIALOG 13 // template for save dialog
  32. #define IDD_GOTODIALOG 14 // goto line number dialog
  33. // Control IDs
  34. #define IDC_FILETYPE 257 // listbox in save dialog
  35. #define IDC_GOTO 258 // line number to goto
  36. #define IDC_ENCODING 259 // static text in save dialog
  37. // Menu IDs
  38. // File
  39. #define M_NEW 1
  40. #define M_OPEN 2
  41. #define M_SAVE 3
  42. #define M_SAVEAS 4
  43. #define M_PAGESETUP 5
  44. #define M_PRINT 6
  45. #define M_EXIT 7
  46. // Edit
  47. #define M_UNDO 16
  48. #define M_CUT WM_CUT /* These just get passed down to the edit control */
  49. #define M_COPY WM_COPY
  50. #define M_PASTE WM_PASTE
  51. #define M_CLEAR WM_CLEAR
  52. #define M_FIND 21
  53. #define M_FINDNEXT 22
  54. #define M_REPLACE 23
  55. #define M_GOTO 24
  56. #define M_SELECTALL 25
  57. #define M_DATETIME 26
  58. // Format
  59. #define M_WW 32
  60. #define M_SETFONT 33
  61. // Help
  62. #define M_HELP 64
  63. #define M_ABOUT 65
  64. // Control IDs
  65. #define ID_EDIT 15
  66. #define ID_FILENAME 20
  67. #define ID_PAGENUMBER 21
  68. #define ID_HEADER 30
  69. #define ID_FOOTER 31
  70. #define ID_HEADER_LABEL 32
  71. #define ID_FOOTER_LABEL 33
  72. #define ID_ASCII 50
  73. #define ID_UNICODE 51
  74. // IDs used to load RC strings
  75. #define IDS_DISKERROR 1
  76. #define IDS_FNF 2
  77. #define IDS_SCBC 3
  78. #define IDS_UNTITLED 4
  79. #define IDS_SXSPAD 5
  80. #define IDS_CFS 6
  81. #define IDS_ERRSPACE 7
  82. #define IDS_FTL 8
  83. #define IDS_NN 9
  84. #define IDS_COMMDLGINIT 10
  85. #define IDS_PRINTDLGINIT 11
  86. #define IDS_CANTPRINT 12
  87. #define IDS_NVF 13
  88. #define IDS_CREATEERR 14
  89. #define IDS_NOWW 15
  90. #define IDS_MERGE1 16
  91. #define IDS_HELPFILE 17
  92. #define IDS_HEADER 18
  93. #define IDS_FOOTER 19
  94. #define IDS_ANSITEXT 20
  95. #define IDS_ALLFILES 21
  96. #define IDS_OPENCAPTION 22
  97. #define IDS_SAVECAPTION 23
  98. #define IDS_CANNOTQUIT 24
  99. #define IDS_LOADDRVFAIL 25
  100. #define IDS_ACCESSDENY 26
  101. #define IDS_ERRUNICODE 27
  102. #define IDS_FONTTOOBIG 28
  103. #define IDS_COMMDLGERR 29
  104. #define IDS_LINEERROR 30 /* line number error */
  105. #define IDS_LINETOOLARGE 31 /* line number too large */
  106. #define IDS_FT_ANSI 32 /* ascii */
  107. #define IDS_FT_UNICODE 33 /* unicode */
  108. #define IDS_FT_UNICODEBE 34 /* unicode big endian */
  109. #define IDS_FT_UTF8 35 /* UTF-8 format */
  110. #define IDS_CURRENT_PAGE 36 /* currently printing page on abort dlg */
  111. #define CSTRINGS 36 /* cnt of stringtable strings from .rc file */
  112. #define CCHKEYMAX 128 /* max characters in search string */
  113. #define CCHSPMAX 0 /* no limit on file size */
  114. #define SETHANDLEINPROGRESS 0x0001 /* EM_SETHANDLE has been sent */
  115. #define SETHANDLEFAILED 0x0002 /* EM_SETHANDLE caused EN_ERRSPACE */
  116. /* Standard edit control style:
  117. * ES_NOHIDESEL set so that find/replace dialog doesn't undo selection
  118. * of text while it has the focus away from the edit control. Makes finding
  119. * your text easier.
  120. */
  121. #define ES_STD (WS_CHILD|WS_VSCROLL|WS_VISIBLE|ES_MULTILINE|ES_NOHIDESEL)
  122. /* EXTERN decls for data */
  123. extern SP_FILETYPE fFileType; /* Flag indicating the type of text file */
  124. extern BOOL fCase; /* Flag specifying case sensitive search */
  125. extern BOOL fReverse; /* Flag for direction of search */
  126. extern TCHAR szSearch[];
  127. extern HWND hDlgFind; /* handle to modeless FindText window */
  128. extern HANDLE hEdit;
  129. extern HANDLE hFont;
  130. extern HANDLE hAccel;
  131. extern HANDLE hInstanceSP;
  132. extern HANDLE hStdCursor, hWaitCursor;
  133. extern HWND hwndSP, hwndEdit;
  134. extern LOGFONT FontStruct;
  135. extern INT iPointSize;
  136. extern BOOL fRunBySetup;
  137. extern DWORD dwEmSetHandle;
  138. extern TCHAR chMerge;
  139. extern BOOL fUntitled;
  140. extern BOOL fWrap;
  141. extern TCHAR szFileName[];
  142. extern HANDLE fp;
  143. //
  144. // Holds header and footer strings to be used in printing.
  145. // use HEADER and FOOTER to index.
  146. //
  147. extern TCHAR chPageText[2][PT_LEN]; // header and footer strings
  148. #define HEADER 0
  149. #define FOOTER 1
  150. //
  151. // Holds header and footer from pagesetupdlg during destroy.
  152. // if the user hit ok, then keep. Otherwise ignore.
  153. //
  154. extern TCHAR chPageTextTemp[2][PT_LEN];
  155. extern TCHAR szSxspad[];
  156. extern TCHAR *szMerge;
  157. extern TCHAR *szUntitled, *szNpTitle, *szNN, *szErrSpace;
  158. extern TCHAR *szErrUnicode;
  159. extern TCHAR **rgsz[]; /* More strings. */
  160. extern TCHAR *szNVF;
  161. extern TCHAR *szPDIE;
  162. extern TCHAR *szDiskError;
  163. extern TCHAR *szCREATEERR;
  164. extern TCHAR *szWE;
  165. extern TCHAR *szFTL;
  166. extern TCHAR *szINF;
  167. extern TCHAR *szFNF;
  168. extern TCHAR *szNEDSTP;
  169. extern TCHAR *szNEMTP;
  170. extern TCHAR *szCFS;
  171. extern TCHAR *szPE;
  172. extern TCHAR *szCP;
  173. extern TCHAR *szACCESSDENY;
  174. extern TCHAR *szFontTooBig;
  175. extern TCHAR *szLoadDrvFail;
  176. extern TCHAR *szCommDlgErr;
  177. extern TCHAR *szCommDlgInitErr;
  178. extern TCHAR *szHelpFile;
  179. extern TCHAR *szFtAnsi;
  180. extern TCHAR *szFtUnicode;
  181. extern TCHAR *szFtUnicodeBe;
  182. extern TCHAR *szFtUtf8;
  183. extern TCHAR *szCurrentPage;
  184. extern TCHAR *szHeader;
  185. extern TCHAR *szFooter;
  186. /* variables for the new File/Open and File/Saveas dialogs */
  187. extern OPENFILENAME OFN; /* passed to the File Open/save APIs */
  188. extern TCHAR szOpenFilterSpec[]; /* default open filter spec */
  189. extern TCHAR szSaveFilterSpec[]; /* default save filter spec */
  190. extern TCHAR *szAnsiText; /* part of the text for the above */
  191. extern TCHAR *szAllFiles; /* part of the text for the above */
  192. extern FINDREPLACE FR; /* Passed to FindText() */
  193. extern PAGESETUPDLG g_PageSetupDlg;
  194. extern TCHAR szPrinterName []; /* name of the printer passed to PrintTo */
  195. extern SP_FILETYPE g_ftOpenedAs; /* file was opened */
  196. extern SP_FILETYPE g_ftSaveAs; /* file was saved as type */
  197. extern UINT wFRMsg; /* message used in communicating */
  198. /* with Find/Replace dialog */
  199. extern UINT wHlpMsg; /* message used in invoking help */
  200. extern HMENU hSysMenuSetup; /* Save Away for disabled Minimize */
  201. /* EXTERN procs */
  202. /* procs in sxspad.c */
  203. VOID
  204. PASCAL
  205. SetPageSetupDefaults(
  206. VOID
  207. );
  208. BOOL far PASCAL SaveAsDlgHookProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  209. LPTSTR PASCAL far PFileInPath (LPTSTR sz);
  210. BOOL FAR CheckSave (BOOL fSysModal);
  211. LRESULT FAR SPWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  212. void FAR SetTitle (TCHAR *sz);
  213. INT FAR AlertBox (HWND hwndParent, TCHAR *szCaption, TCHAR *szText1,
  214. TCHAR *szText2, UINT style);
  215. void FAR NpWinIniChange (VOID);
  216. void FAR FreeGlobalPD (void);
  217. INT_PTR CALLBACK GotoDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
  218. /* procs in npdate.c */
  219. VOID FAR InsertDateTime (BOOL fCrlf);
  220. /* procs in npfile.c */
  221. BOOL FAR SaveFile (HWND hwndParent, TCHAR *szFileSave, BOOL fSaveAs);
  222. BOOL FAR LoadFile (TCHAR *sz, INT type );
  223. VOID FAR New (BOOL fCheck);
  224. void FAR AddExt (TCHAR *sz);
  225. INT FAR Remove (LPTSTR szFileName);
  226. VOID FAR AlertUser_FileFail( LPTSTR szFileName );
  227. /* procs in npinit.c */
  228. INT FAR SPInit (HANDLE hInstance, HANDLE hPrevInstance,
  229. LPTSTR lpCmdLine, INT cmdShow);
  230. void FAR InitLocale (VOID);
  231. void SaveGlobals( VOID );
  232. /* procs in npmisc.c */
  233. INT FAR FindDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  234. BOOL Search (TCHAR *szSearch);
  235. INT FAR AboutDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  236. BOOL FAR NpReCreate (LONG style);
  237. LPTSTR ForwardScan (LPTSTR lpSource, LPTSTR lpSearch, BOOL fCaseSensitive);
  238. /* procs in npprint.c */
  239. typedef enum _PRINT_DIALOG_TYPE {
  240. UseDialog,
  241. DoNotUseDialog,
  242. NoDialogNonDefault
  243. } PRINT_DIALOG_TYPE;
  244. INT AbortProc( HDC hPrintDC, INT reserved );
  245. INT_PTR AbortDlgProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
  246. INT NpPrint( PRINT_DIALOG_TYPE type );
  247. INT NpPrintGivenDC( HDC hPrintDC );
  248. UINT_PTR
  249. CALLBACK
  250. PageSetupHookProc(
  251. HWND hWnd,
  252. UINT Message,
  253. WPARAM wParam,
  254. LPARAM lParam
  255. );
  256. HANDLE GetPrinterDC (VOID);
  257. HANDLE GetNonDefPrinterDC (VOID);
  258. VOID PrintIt(PRINT_DIALOG_TYPE type);
  259. /* procs in nputf.c */
  260. INT IsTextUTF8 (LPSTR lpstrInputStream, INT iLen);
  261. INT IsInputTextUnicode(LPSTR lpstrInputStream, INT iLen);
  262. // Help IDs for Sxspad
  263. #define NO_HELP ((DWORD) -1) // Disables Help for a control
  264. #define IDH_PAGE_FOOTER 1000
  265. #define IDH_PAGE_HEADER 1001
  266. #define IDH_FILETYPE 1002
  267. #define IDH_GOTO 1003
  268. // Private message to track the HKL switch
  269. #define PWM_CHECK_HKL (WM_APP + 1)