Leaked source code of windows server 2003
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.

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