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.

400 lines
12 KiB

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