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.

505 lines
16 KiB

  1. /****************************************************************************
  2. *
  3. * WINCOM.H
  4. *
  5. * Exported definitions for MM/Windows common code library.
  6. *
  7. ****************************************************************************/
  8. #ifndef _WINCOM_H_
  9. #define _WINCOM_H_
  10. /*************************************
  11. *
  12. * OPEN FILE DIALOG BOX
  13. *
  14. *************************************/
  15. int FAR PASCAL OpenFileDialog(HWND hwndParent, LPSTR lpszTitle,
  16. LPSTR lpszExtension, WORD wFlags,
  17. LPSTR lpszFileBuf, WORD wFileLen );
  18. /* Flags for OpenFileDialog */
  19. #define DLGOPEN_MUSTEXIST 0x0001
  20. #define DLGOPEN_NOSHOWSPEC 0x0002
  21. #define DLGOPEN_SAVE 0x0004
  22. #define DLGOPEN_OPEN 0x0008
  23. #define DLGOPEN_SHOWDEFAULT 0x0020
  24. #define DLGOPEN_NOBEEPS 0x0040
  25. #define DLGOPEN_SEARCHPATH 0x0080
  26. /* Return codes */
  27. #define DLG_CANCEL 0
  28. #define DLG_MISSINGFILE -1
  29. #define DLG_OKFILE 1
  30. /**************************************************
  31. *
  32. * DEFAULT FILE OPEN DIALOG PROCEDURE STUFF
  33. *
  34. **************************************************/
  35. BOOL FAR PASCAL DefDlgOpenProc(HWND hwnd, unsigned msg,
  36. WORD wParam, LONG lParam);
  37. typedef struct _DlgOpenCreate {
  38. LPSTR lpszTitle; // NULL if use default dialog caption
  39. LPSTR lpszExt; // NULL defaults to *.*
  40. LPSTR lpszBuf; // final filename buffer
  41. WORD wBufLen; // length of this buffer
  42. WORD wFlags; // DLGOPEN_xxx flags
  43. DWORD dwExtra; // for use by the owner of the dialog
  44. } DlgOpenCreate;
  45. typedef DlgOpenCreate FAR *FPDlgOpenCreate;
  46. #define SetDialogReturn(hwnd, val) SetWindowLong(hwnd, 0, val)
  47. /* These messages are sent to/from DefDlgOpenProc to make the
  48. * Dialog box work. They may be answered by the "owner" of the dialog
  49. * box.
  50. */
  51. #define DLGOPEN_OKTOCLOSE (WM_USER + 1) // ask whether ok to close box
  52. #define DLGOPEN_CLOSEBOX (WM_USER + 2) // tell dlgOpen to close box
  53. #define DLGOPEN_SETEXTEN (WM_USER + 3) // sets default extensions
  54. // #define DLGOPEN_SETEDITTEXT (WM_USER + 4) // sets editbox contents
  55. // #define DLGOPEN_REFRESH (WM_USER + 5) // refresh the box?
  56. #define DLGOPEN_CHANGED (WM_USER + 6) // edit box has been changed
  57. #define DLGOPEN_RESETDIR (WM_USER + 7) // directory change
  58. BOOL FAR PASCAL IconDirBox(HWND hwnd, WORD wId, unsigned msg,
  59. WORD wParam, LONG lParam);
  60. BOOL FAR PASCAL IconDirBoxFixup(HWND hwndDirbox);
  61. /*
  62. * HUGE READ/WRITE functions
  63. *
  64. */
  65. LONG FAR PASCAL _hread( int hFile, HPSTR hpBuffer, DWORD dwBytes );
  66. LONG FAR PASCAL _hwrite( int hFile, HPSTR hpBuffer, DWORD dwBytes );
  67. /*
  68. * FAR STRING FUNCTIONS
  69. */
  70. LPSTR FAR PASCAL lstrncpy(LPSTR dest, LPSTR source, WORD count);
  71. LPSTR FAR PASCAL lstrncat(LPSTR dest, LPSTR source, WORD count);
  72. int FAR PASCAL lstrncmp(LPSTR d, LPSTR s, WORD n);
  73. /*
  74. * FAR MEMORY FUNCTIONS
  75. */
  76. void FAR * FAR PASCAL lmemcpy(LPSTR dest, LPSTR source, WORD count);
  77. void FAR * FAR PASCAL hmemcpy(HPSTR dest, HPSTR source, LONG count);
  78. HANDLE FAR PASCAL CopyHandle(WORD wFlags, HANDLE h);
  79. void FAR PASCAL fmemfill (LPSTR lpMem, DWORD count, BYTE bFill);
  80. /*
  81. * BYTE SWAPPING FUNCTIONS
  82. */
  83. WORD FAR PASCAL ByteSwapWORD( WORD w );
  84. DWORD FAR PASCAL ByteSwapDWORD( DWORD dw );
  85. /*
  86. * atol for far strings
  87. */
  88. LONG FAR PASCAL StringToLong( LPSTR lpstr );
  89. /*
  90. * PATH PARSING FUNCTIONS
  91. */
  92. BOOL FAR PASCAL AddExtension(LPSTR lpszPath, LPSTR lpszExt, WORD wBufLen);
  93. WORD FAR PASCAL SplitPath(LPSTR path, LPSTR drive, LPSTR dir,
  94. LPSTR fname, LPSTR ext);
  95. void FAR PASCAL MakePath(LPSTR lpPath, LPSTR lpDrive, LPSTR lpDir,
  96. LPSTR lpFname, LPSTR lpExt);
  97. LPSTR FAR PASCAL QualifyPathname(LPSTR lpszFile);
  98. /* return codes from SplitPath */
  99. #define PATH_OK 0 /* path is fine */
  100. #define PATH_TOOLONG 1 /* filename too long */
  101. #define PATH_ILLEGAL 2 /* filename is illegal */
  102. /* Definitions stolen from <stdlib.h> */
  103. #ifndef _MAX_PATH
  104. #define _MAX_PATH 144 /* max. length of full pathname */
  105. #define _MAX_DRIVE 3 /* max. length of drive component */
  106. #define _MAX_DIR 130 /* max. length of path component */
  107. #define _MAX_FNAME 9 /* max. length of file name component */
  108. #define _MAX_EXT 5 /* max. length of extension component */
  109. #endif
  110. /*
  111. * DOS FAR UTILITY FUNCTIONS
  112. */
  113. typedef struct _FindFileStruct {
  114. char chReserved[21];
  115. BYTE bAttribute;
  116. WORD wTime;
  117. WORD wDate;
  118. DWORD dwSize;
  119. char chFilename[13];
  120. } FindFileStruct;
  121. typedef FindFileStruct FAR *FPFindFileStruct;
  122. typedef FindFileStruct NEAR *NPFindFileStruct;
  123. #define DOS_READONLY 0x0001
  124. #define DOS_HIDDEN 0x0002
  125. #define DOS_SYSTEM 0x0004
  126. #define DOS_VOLUME 0x0008
  127. #define DOS_DIRECTORY 0x0010
  128. #define DOS_ARCHIVE 0x0020
  129. #define DOS_FILES (DOS_READONLY | DOS_SYSTEM)
  130. #define DOS_ALL (DOS_FILES | DOS_DIRECTORY | DOS_HIDDEN)
  131. /* Return codes from DosFindFirst and DosFindNext */
  132. #define DOSFF_OK 0
  133. #define DOSFF_FILENOTFOUND 2
  134. #define DOSFF_PATHINVALID 3
  135. #define DOSFF_NOMATCH 0x12
  136. WORD FAR PASCAL DosFindFirst(FPFindFileStruct lpFindStruct,
  137. LPSTR lpszFileSpec, WORD wAttrib);
  138. WORD FAR PASCAL DosFindNext(FPFindFileStruct lpFindStruct);
  139. int FAR PASCAL DosChangeDir(LPSTR lpszPath);
  140. WORD FAR PASCAL DosGetCurrentDrive();
  141. BOOL FAR PASCAL DosSetCurrentDrive(WORD wDrive);
  142. WORD FAR PASCAL DosGetCurrentDir(WORD wCurdrive, LPSTR lpszBuf);
  143. BOOL FAR PASCAL DosGetCurrentPath(LPSTR lpszBuf, WORD wLen);
  144. WORD FAR PASCAL DosDeleteFile(LPSTR lpszFile);
  145. BOOL FAR PASCAL DosGetVolume(BYTE chDrive, LPSTR lpszBuf);
  146. WORD FAR PASCAL DosQueryNet(WORD wIndex, LPSTR lpszLocal, LPSTR lspzRemote);
  147. WORD FAR PASCAL mscdGetDrives(LPSTR lpszDriveBuf);
  148. /* Return codes from DosQueryNet() */
  149. #define NET_ERROR (-1)
  150. #define NET_INVALID (0x0100)
  151. #define NET_TYPEMASK (0x00ff)
  152. #define NET_PRINTER (0x0003)
  153. #define NET_DRIVE (0x0004)
  154. /*
  155. * ERROR MESSAGE REPORTING BOX
  156. */
  157. short FAR cdecl ErrorResBox( HWND hwnd,
  158. HANDLE hInst,
  159. WORD flags,
  160. WORD idAppName,
  161. WORD idErrorStr, ...);
  162. /*
  163. * PROGRESS BAR GRAPH CONTROL - class "ProgBar"
  164. */
  165. #define BAR_SETRANGE (WM_USER + 0)
  166. #define BAR_SETPOS (WM_USER + 2)
  167. #define BAR_DELTAPOS (WM_USER + 4)
  168. #define CTLCOLOR_PROGBAR (CTLCOLOR_MAX + 2)
  169. /*
  170. * STATUS TEXT CONTROL - class "MPStatusText".
  171. *
  172. * See wincom project file status.c for more information on control.
  173. */
  174. #define ST_GETSTATUSHEIGHT (WM_USER + 0)
  175. #define ST_SETRIGHTSIDE (WM_USER + 1)
  176. #define ST_GETRIGHTSIDE (WM_USER + 2)
  177. #define CTLCOLOR_STATUSTEXT (CTLCOLOR_MAX + 1)
  178. /*
  179. * ARROW CONTROL - class "ComArrow".
  180. */
  181. LONG FAR PASCAL ArrowEditChange( HWND hwndEdit, WORD wParam,
  182. LONG lMin, LONG lMax );
  183. /*
  184. * CHOOSER CONTROL - class "CHOOSER".
  185. */
  186. /* Chooser Window control messages */
  187. #define CM_SETITEMRECTSIZE (WM_USER + 1)
  188. #define CM_CALCSIZE (WM_USER + 2)
  189. #define CM_ADDITEM (WM_USER + 3)
  190. #define CM_INSERTITEM (WM_USER + 4)
  191. #define CM_DELETEITEM (WM_USER + 5)
  192. #define CM_GETCOUNT (WM_USER + 6)
  193. #define CM_GETITEMDATA (WM_USER + 7)
  194. #define CM_GETCURSEL (WM_USER + 8)
  195. #define CM_SETCURSEL (WM_USER + 9)
  196. #define CM_FINDITEM (WM_USER + 10)
  197. #define CM_ERR LB_ERR
  198. /* Chooser Window notification messages */
  199. #define CN_SELECTED 100
  200. #define CN_DESELECTED 101
  201. /*
  202. * Mac-like small Non-client window message handler
  203. */
  204. LONG FAR PASCAL ncMsgFilter(HWND hwnd,unsigned msg, WORD wParam, LONG lParam);
  205. /* Window styles used by ncMsgFilter */
  206. #define WF_SIZEFRAME WS_THICKFRAME
  207. #define WF_SYSMENU WS_SYSMENU
  208. #define WF_MINIMIZED WS_MINIMIZE
  209. #define WF_SIZEBOX 0x0002
  210. /* Obscure stuff to deal with DLL loading/unloading */
  211. typedef HANDLE HLIBLIST;
  212. typedef WORD DYNALIBID;
  213. typedef struct _DynaLib {
  214. HANDLE hModule;
  215. WORD wRefcount;
  216. char achLibname[_MAX_PATH];
  217. } DynaLib;
  218. typedef DynaLib FAR *FPDynaLib;
  219. HLIBLIST FAR PASCAL dllMakeList(WORD wSize, LPSTR lpszLoadPoint,
  220. LPSTR lpszFreePoint);
  221. BOOL FAR PASCAL dllUnloadLib(HLIBLIST hlist, DYNALIBID id, BOOL fDestroy);
  222. BOOL FAR PASCAL dllDestroyList(HLIBLIST hlist);
  223. BOOL FAR PASCAL dllForceUnload(HLIBLIST hlist);
  224. HANDLE FAR PASCAL dllLoadLib(HLIBLIST hlist, DYNALIBID libid);
  225. BOOL FAR PASCAL dllGetInfo(HLIBLIST hlist, DYNALIBID libid, FPDynaLib fpLib);
  226. BOOL FAR PASCAL dllIsLoaded(HLIBLIST hlist, DYNALIBID libid);
  227. DYNALIBID FAR PASCAL dllAddLib(HLIBLIST hlist, LPSTR lpszName);
  228. DYNALIBID FAR PASCAL dllIterAll(HLIBLIST hlist, DYNALIBID idLast);
  229. DYNALIBID FAR PASCAL dllFindHandle(HLIBLIST hlist, HANDLE hModHandle);
  230. DYNALIBID FAR PASCAL dllFindName(HLIBLIST hlist, LPSTR lpszName);
  231. DYNALIBID FAR PASCAL dllAddLoadedLib(HLIBLIST hlist,HANDLE hModule,BOOL fLoad);
  232. /**********************************
  233. *
  234. * FOR DOS FILE FUNCTIONS (SWITCH PSP)
  235. *
  236. **********************************/
  237. /* flags for DosSeek */
  238. #define SEEK_CUR 1
  239. #define SEEK_END 2
  240. #define SEEK_SET 0
  241. /* DOS attributes */
  242. #define ATTR_READONLY 0x0001
  243. #define ATTR_HIDDEN 0x0002
  244. #define ATTR_SYSTEM 0x0004
  245. #define ATTR_VOLUME 0x0008
  246. #define ATTR_DIR 0x0010
  247. #define ATTR_ARCHIVE 0x0020
  248. #define ATTR_FILES (ATTR_READONLY+ATTR_SYSTEM)
  249. #define ATTR_ALL_FILES (ATTR_READONLY+ATTR_SYSTEM+ATTR_HIDDEN)
  250. #define ATTR_ALL (ATTR_READONLY+ATTR_DIR+ATTR_HIDDEN+ATTR_SYSTEM)
  251. typedef struct {
  252. char Reserved[21];
  253. BYTE Attr;
  254. WORD Time;
  255. WORD Date;
  256. DWORD Length;
  257. char szName[13];
  258. } FCB;
  259. typedef FCB * PFCB;
  260. typedef FCB FAR * LPFCB;
  261. /* functions from dos.asm */
  262. extern int FAR PASCAL DosError(void);
  263. extern int FAR PASCAL DosOpen(LPSTR szFile,WORD acc);
  264. extern int FAR PASCAL DosCreate(LPSTR szFile,WORD acc);
  265. extern int FAR PASCAL DosDup(int fh);
  266. extern void FAR PASCAL DosClose(int fh);
  267. extern DWORD FAR PASCAL DosSeek(int fh,DWORD ulPos,WORD org);
  268. extern DWORD FAR PASCAL DosRead(int fh,LPSTR pBuf,DWORD ulSize);
  269. extern DWORD FAR PASCAL DosWrite(int fh,LPSTR pBuf,DWORD ulSize);
  270. /* DOS ERROR CODES */
  271. #define ERROR_OK 0x00
  272. #define ERROR_FILENOTFOUND 0x02 /* File not found */
  273. #define ERROR_PATHNOTFOUND 0x03 /* Path not found */
  274. #define ERROR_NOFILEHANDLES 0x04 /* Too many open files */
  275. #define ERROR_ACCESSDENIED 0x05 /* Access denied */
  276. #define ERROR_INVALIDHANDLE 0x06 /* Handle invalid */
  277. #define ERROR_FCBNUKED 0x07 /* Memory control blocks destroyed */
  278. #define ERROR_NOMEMORY 0x08 /* Insufficient memory */
  279. #define ERROR_FCBINVALID 0x09 /* Memory block address invalid */
  280. #define ERROR_ENVINVALID 0x0A /* Environment invalid */
  281. #define ERROR_FORMATBAD 0x0B /* Format invalid */
  282. #define ERROR_ACCESSCODEBAD 0x0C /* Access code invalid */
  283. #define ERROR_DATAINVALID 0x0D /* Data invalid */
  284. #define ERROR_UNKNOWNUNIT 0x0E /* Unknown unit */
  285. #define ERROR_DISKINVALID 0x0F /* Disk drive invalid */
  286. #define ERROR_RMCHDIR 0x10 /* Attempted to remove current directory */
  287. #define ERROR_NOSAMEDEV 0x11 /* Not same device */
  288. #define ERROR_NOFILES 0x12 /* No more files */
  289. #define ERROR_13 0x13 /* Write-protected disk */
  290. #define ERROR_14 0x14 /* Unknown unit */
  291. #define ERROR_15 0x15 /* Drive not ready */
  292. #define ERROR_16 0x16 /* Unknown command */
  293. #define ERROR_17 0x17 /* Data error (CRC) */
  294. #define ERROR_18 0x18 /* Bad request-structure length */
  295. #define ERROR_19 0x19 /* Seek error */
  296. #define ERROR_1A 0x1A /* Unknown media type */
  297. #define ERROR_1B 0x1B /* Sector not found */
  298. #define ERROR_WRITE 0x1D /* Write fault */
  299. #define ERROR_1C 0x1C /* Printer out of paper */
  300. #define ERROR_READ 0x1E /* Read fault */
  301. #define ERROR_1F 0x1F /* General failure */
  302. #define ERROR_SHARE 0x20 /* Sharing violation */
  303. #define ERROR_21 0x21 /* File-lock violation */
  304. #define ERROR_22 0x22 /* Disk change invalid */
  305. #define ERROR_23 0x23 /* FCB unavailable */
  306. #define ERROR_24 0x24 /* Sharing buffer exceeded */
  307. #define ERROR_32 0x32 /* Unsupported network request */
  308. #define ERROR_33 0x33 /* Remote machine not listening */
  309. #define ERROR_34 0x34 /* Duplicate name on network */
  310. #define ERROR_35 0x35 /* Network name not found */
  311. #define ERROR_36 0x36 /* Network busy */
  312. #define ERROR_37 0x37 /* Device no longer exists on network */
  313. #define ERROR_38 0x38 /* NetBIOS command limit exceeded */
  314. #define ERROR_39 0x39 /* Error in network adapter hardware */
  315. #define ERROR_3A 0x3A /* Incorrect response from network */
  316. #define ERROR_3B 0x3B /* Unexpected network error */
  317. #define ERROR_3C 0x3C /* Remote adapter incompatible */
  318. #define ERROR_3D 0x3D /* Print queue full */
  319. #define ERROR_3E 0x3E /* Not enough room for print file */
  320. #define ERROR_3F 0x3F /* Print file was deleted */
  321. #define ERROR_40 0x40 /* Network name deleted */
  322. #define ERROR_41 0x41 /* Network access denied */
  323. #define ERROR_42 0x42 /* Incorrect network device type */
  324. #define ERROR_43 0x43 /* Network name not found */
  325. #define ERROR_44 0x44 /* Network name limit exceeded */
  326. #define ERROR_45 0x45 /* NetBIOS session limit exceeded */
  327. #define ERROR_46 0x46 /* Temporary pause */
  328. #define ERROR_47 0x47 /* Network request not accepted */
  329. #define ERROR_48 0x48 /* Print or disk redirection paused */
  330. #define ERROR_50 0x50 /* File already exists */
  331. #define ERROR_51 0x51 /* Reserved */
  332. #define ERROR_52 0x52 /* Cannot make directory */
  333. #define ERROR_53 0x53 /* Fail on Int 24H (critical error) */
  334. #define ERROR_54 0x54 /* Too many redirections */
  335. #define ERROR_55 0x55 /* Duplicate redirection */
  336. #define ERROR_56 0x56 /* Invalid password */
  337. #define ERROR_57 0x57 /* Invalid parameter */
  338. #define ERROR_58 0x58 /* Net write fault */
  339. /*
  340. * DIB and BITMAP UTILITIES
  341. */
  342. HANDLE FAR PASCAL dibCreate(DWORD dwWidth, DWORD dwHeight, WORD wBitCount,
  343. WORD wPalSize, WORD wGmemFlags, WORD wDibFlags);
  344. #define DBC_PALINDEX 0x0001
  345. #define dibWIDTHBYTES(i) (((i) + 31) / 32 * 4)
  346. /*
  347. * WPF OUTPUT WINDOW
  348. */
  349. #define WPF_CHARINPUT 0x00000001L
  350. void FAR PASCAL wpfOut(HWND hwnd, LPSTR lpsz);
  351. HWND FAR PASCAL wpfCreateWindow(HWND hwndParent, HANDLE hInst,LPSTR lpszTitle,
  352. DWORD dwStyle, WORD x, WORD y,
  353. WORD dx, WORD dy, int iMaxLines, WORD wID);
  354. /* Control messages sent to WPF window */
  355. //#define WPF_SETNLINES (WM_USER + 1)
  356. #define WPF_GETNLINES (WM_USER + 2)
  357. #define WPF_SETTABSTOPS (WM_USER + 4)
  358. #define WPF_GETTABSTOPS (WM_USER + 5)
  359. #define WPF_GETNUMTABS (WM_USER + 6)
  360. #define WPF_SETOUTPUT (WM_USER + 7)
  361. #define WPF_GETOUTPUT (WM_USER + 8)
  362. #define WPF_CLEARWINDOW (WM_USER + 9)
  363. /* Flags for WPF_SET/GETOUTPUT */
  364. #define WPFOUT_WINDOW 1
  365. #define WPFOUT_COM1 2
  366. #define WPFOUT_NEWFILE 3
  367. #define WPFOUT_APPENDFILE 4
  368. #define WPFOUT_DISABLED 5
  369. /* Messages sent to owner of window */
  370. #define WPF_NTEXT (0xbff0)
  371. #define WPF_NCHAR (0xbff1)
  372. /**********************************
  373. *
  374. * DEBUGGING SUPPORT
  375. *
  376. **********************************/
  377. BOOL FAR PASCAL wpfDbgSetLocation(WORD wLoc, LPSTR lpszFile);
  378. int FAR cdecl wpfDbgOut(LPSTR lpszFormat, ...);
  379. BOOL FAR PASCAL wpfSetDbgWindow(HWND hwnd, BOOL fDestroyOld);
  380. #define WinPrintf wpfDbgOut
  381. #ifdef DEBUG
  382. BOOL __fEval;
  383. BOOL __iDebugLevel;
  384. int FAR PASCAL __WinAssert(LPSTR lpszFile, int iLine);
  385. #define WinAssert(exp) \
  386. ((exp) ? 0 : __WinAssert((LPSTR) __FILE__, __LINE__))
  387. #define WinEval(exp) (__fEval=(exp), WinAssert(__fEval), __fEval)
  388. #define wpfGetDebugLevel(lpszModule) \
  389. (__iDebugLevel = GetProfileInt("MMDebug", (lpszModule), 0))
  390. #define wpfSetDebugLevel(i) \
  391. (__iDebugLevel = (i))
  392. #define wpfDebugLevel() (__iDebugLevel)
  393. #define dprintf if (__iDebugLevel) wpfDbgOut
  394. #define dprintf1 if (__iDebugLevel >= 1) wpfDbgOut
  395. #define dprintf2 if (__iDebugLevel >= 2) wpfDbgOut
  396. #define dprintf3 if (__iDebugLevel >= 3) wpfDbgOut
  397. #define dprintf4 if (__iDebugLevel >= 4) wpfDbgOut
  398. #else
  399. #define WinAssert(exp) 0
  400. #define WinEval(exp) (exp)
  401. #define wpfGetDebugLevel(lpszModule) 0
  402. #define wpfSetDebugLevel(i) 0
  403. #define wpfDebugLevel() 0
  404. #define dprintf if (0) ((int (*)(char *, ...)) 0)
  405. #define dprintf1 if (0) ((int (*)(char *, ...)) 0)
  406. #define dprintf2 if (0) ((int (*)(char *, ...)) 0)
  407. #define dprintf3 if (0) ((int (*)(char *, ...)) 0)
  408. #define dprintf4 if (0) ((int (*)(char *, ...)) 0)
  409. #endif
  410. /** THIS MUST BE LAST LINE OF FILE **/
  411. #endif