home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / ntcode / holep / os2win.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  12.0 KB  |  359 lines

  1. #include <windows.h>
  2.  
  3. #define EXLST_EXIT 1
  4.  
  5. #define _far
  6. #define far     /* NT -- No more far's          */
  7. #define near    /* NT -- No more near's         */
  8. #define _loadds /* NT -- No more load DS stuff  */
  9. #define pascal  /* NT -- No more 'pascal' BS    */
  10. #define huge    /* NT -- No more 'huge' BS      */
  11.  
  12. #define PMERR_MEMORY_ALLOCATION_ERR ERROR_OUTOFMEMORY;
  13. #define SELECTOROF(a) (a)
  14. #define EXLST_ADD    5
  15. #define EXLST_REMOVE 6
  16. #define CSEM_PUBLIC  TRUE
  17. #define CSEM_PRIVATE FALSE
  18. #define HWND_OBJECT NULL
  19. #define MPFROMLONG(a) a
  20. #define LONGFROMMP(a)  a
  21. #define MPFROMSHORT(a) a
  22. #define OFFSETOF(a) a
  23. #define SHORT1FROMMR(a) ((SHORT)(a))
  24. #define PVOIDFROMMR(a) ((LPVOID)(a))
  25. typedef  HCURSOR HPOINTER;
  26.  
  27. #define DID_OK      1
  28. #define DID_CANCEL  2
  29. #define DID_ERROR  -1
  30. #define MBID_ERROR  0
  31.  
  32.  
  33.  
  34.  
  35. // ==============================================================
  36. // Globals defined in HolePort.c WinMain for your use.
  37. // ==============================================================
  38. extern HANDLE hinst;  // You must have a global hinst for some
  39.                       // of the translations to work.
  40. extern int nCmdShow;
  41.  
  42. // ==============================================================
  43. // Type defs needed for Holeport.c or old OS/2 code that
  44. // can translate as is.
  45. // ==============================================================
  46.  
  47. typedef HWND   *PHWND;
  48. typedef HANDLE *PHANDLE;
  49. typedef HANDLE HPIPE;
  50. typedef HANDLE *PHPIPE;
  51. typedef PROC PFN;
  52. typedef PROC *PPFN;
  53. typedef HANDLE SEL;
  54. typedef HANDLE *PSEL;
  55. typedef char *PSZ;
  56. typedef char *NPSZ;
  57. typedef DWORD *PULONG;
  58.  
  59.  
  60. typedef struct _FILELOCK
  61.     {
  62.     DWORD lOffset;
  63.     DWORD lRange;
  64.     } FILELOCK;
  65. typedef FILELOCK *PFILELOCK;
  66.  
  67.  
  68. typedef struct {
  69.     HWND hwnd;
  70.     DWORD msg;
  71.     DWORD mp1;
  72.     LONG  mp2;
  73.     DWORD time;
  74.     POINTL ptl;
  75. } QMSG;
  76. typedef QMSG *PQMSG;
  77.  
  78. typedef struct {
  79.     LONG xLeft;
  80.     LONG yBottom;
  81.     LONG xRight;
  82.     LONG yTop;
  83. } XRECTL;
  84. typedef XRECTL *PXRECTL;
  85. typedef XRECTL *NXPRECTL;
  86.  
  87. typedef union _packit {
  88.     DWORD dw;
  89.     union {
  90.         SHORT shl;
  91.         SHORT shh;
  92.     };
  93.     union {
  94.         char ch[4];
  95.     };
  96. } PACKED_LONG;
  97.  
  98. typedef struct _MENUITEM { /* mi */
  99.     SHORT   iPosition;
  100.     USHORT  afStyle;
  101.     USHORT  afAttribute;
  102.     USHORT  id;
  103.     HWND    hwndSubMenu;
  104.     ULONG   hItem;
  105. } MENUITEM;
  106. typedef MENUITEM FAR *PMENUITEM;
  107.  
  108. typedef struct _COMMANDMSG { /* commandmsg */
  109.     USHORT  cmd;             /* mp1 */
  110.     USHORT  invalid1;          
  111.     USHORT  invalid2;        /* mp2 */
  112.     USHORT  invalid3;
  113. } CMDMSG;
  114.  
  115.  
  116. typedef struct _CURSORINFO { /* csri */
  117.     HWND    hwnd;
  118.     LONG   x;
  119.     LONG   y;
  120.     LONG   cx;
  121.     LONG   cy;
  122.     USHORT  fs;
  123.     RECT    rclClip;
  124. } CURSORINFO;
  125. typedef CURSORINFO FAR *PCURSORINFO;
  126.  
  127.  
  128. // ==============================================================
  129. // Definitions that are needful
  130. // ==============================================================
  131.  
  132. #define VOID    void
  133. #define SHANDLE HANDLE
  134. #define LHANDLE HANDLE
  135. #define EXPENTRY
  136. #define ERRORID DWORD
  137. #define NEG_ONE  0xFFFFFFFF
  138.  
  139.  
  140. #define QW_NEXT         0
  141. #define QW_PREV         1
  142. #define QW_TOP          2
  143. #define QW_BOTTOM       3
  144. #define QW_OWNER        4
  145. #define QW_PARENT       5
  146. #define QW_NEXTTOP      6
  147. #define QW_PREVTOP      7
  148. #define QW_FRAMEOWNER   8
  149.  
  150. #define SPTR_APPICON               10
  151. #define SPTR_ARROW                 1
  152. #define SPTR_ICONERROR             13
  153. #define SPTR_ICONINFORMATION       11
  154. #define SPTR_ICONQUESTION          12
  155. #define SPTR_ICONWARNING           14
  156. #define SPTR_MOVE                  5
  157. #define SPTR_SIZENESW              7
  158. #define SPTR_SIZENS                9
  159. #define SPTR_SIZENWSE              6
  160. #define SPTR_SIZEWE                8
  161. #define SPTR_TEXT                  2
  162. #define SPTR_WAIT                  3
  163.  
  164. #define SEG_NONSHARED       0x0000
  165. #define SEG_GIVEABLE        0x0001
  166. #define SEG_GETTABLE        0x0002
  167. #define SEG_DISCARDABLE     0x0004
  168. #define SEG_SIZEABLE        0x0008
  169.  
  170.  
  171.  
  172. #define FILE_CREATE     0x0010
  173. #define FILE_OPEN       0x0001
  174. #define FILE_TRUNCATE   0x0002
  175. #define FILE_NORMAL     0x0000
  176. #define FILE_READONLY   0x0001
  177. #define FILE_HIDDEN     0x0002
  178. #define FILE_SYSTEM     0x0004
  179. #define FILE_ARCHIVED   0x0020
  180.  
  181. #define OPEN_FLAGS_DASD             0x0000
  182. #define OPEN_ACCESS_READONLY        0x0000  /* ---- ---- ---- -000 */
  183. #define OPEN_ACCESS_WRITEONLY       0x0001  /* ---- ---- ---- -001 */
  184. #define OPEN_ACCESS_READWRITE       0x0002  /* ---- ---- ---- -010 */
  185. #define OPEN_SHARE_DENYREADWRITE    0x0010  /* ---- ---- -001 ---- */
  186. #define OPEN_SHARE_DENYWRITE        0x0020  /* ---- ---- -010 ---- */
  187. #define OPEN_SHARE_DENYREAD         0x0030  /* ---- ---- -011 ---- */
  188. #define OPEN_SHARE_DENYNONE         0x0040  /* ---- ---- -100 ---- */
  189. #define OPEN_FLAGS_NOINHERIT        0x0080  /* ---- ---- 1--- ---- */
  190. #define OPEN_FLAGS_WRITE_THROUGH    0x4000  /* -1-- ---- ---- ---- */
  191. #define OPEN_FLAGS_FAIL_ON_ERROR    0x2000  /* --1- ---- ---- ---- */
  192. #define OPEN_FLAGS_NO_CACHE         0x1000  /* ---1 ---- ---- ---- */
  193. #define OPEN_FLAGS_SEQUENTIAL       0x0100  /* ---- -001 ---- ---- */
  194. #define OPEN_FLAGS_RANDOM           0x0200  /* ---- -010 ---- ---- */
  195. #define EXIT_THREAD         0
  196. #define EXIT_PROCESS        1
  197.  
  198. #define FATTR_SEL_ITALIC           0x0001
  199. #define FATTR_SEL_UNDERSCORE       0x0002
  200. #define FATTR_SEL_STRIKEOUT        0x0010
  201. #define FATTR_SEL_BOLD             0x0020
  202.  
  203. #define HARDERROR_ENABLE   0
  204. #define HARDERROR_DISABLE  1
  205.  
  206. #define MLFQS_MINMAXSEL            0
  207. #define MLFQS_MINSEL               1
  208. #define MLFQS_MAXSEL               2
  209. #define MLFQS_ANCHORSEL            3
  210. #define MLFQS_CURSORSEL            4
  211.  
  212. #define LIT_END  -1
  213.  
  214.  
  215. #define HDIR_SYSTEM                   0x0001
  216. #define HDIR_CREATE                   0xFFFF
  217.  
  218. #define FID_SYSMENU                0x8002
  219. #define FID_TITLEBAR               0x8003
  220. #define FID_MINMAX                 0x8004
  221. #define FID_MENU                   0x8005
  222. #define FID_VERTSCROLL             0x8006
  223. #define FID_HORZSCROLL             0x8007
  224. #define FID_CLIENT                 0x8008
  225.  
  226.  
  227.  
  228. // ==============================================================
  229. // Definitions that are needful, HP_ prefix
  230. // ==============================================================
  231.  
  232. #define HP_FILE_NORMAL  0x0000
  233.  
  234. #define HP_CS_SIZEREDRAW              0x00000004L
  235. #define HP_CS_SAVEBITS                0x04000000L
  236.  
  237. #define HP_FS_DLGBORDER               0x00000080L
  238. #define HP_FS_BORDER                  0x00000100L
  239. #define HP_FS_SIZEBORDER              0x00000800L
  240. #define HP_FS_STANDARD                0x10000000L
  241. #define HP_FCF_TITLEBAR               0x00000001L
  242. #define HP_FCF_SYSMENU                0x00000002L
  243. #define HP_FCF_MENU                   0x00000004L
  244. #define HP_FCF_SIZEBORDER             0x00000008L
  245. #define HP_FCF_MINBUTTON              0x00000010L
  246. #define HP_FCF_MAXBUTTON              0x00000020L
  247. #define HP_FCF_MINMAX                 0x00000030L 
  248. #define HP_FCF_VERTSCROLL             0x00000040L
  249. #define HP_FCF_HORZSCROLL             0x00000080L
  250. #define HP_FCF_DLGBORDER              0x00000100L
  251. #define HP_FCF_BORDER                 0x00000200L
  252. #define HP_FCF_STANDARD               0x10000000L
  253. #define HP_WS_VISIBLE                 0x80000000L
  254. #define HP_WS_DISABLED                0x40000000L
  255. #define HP_WS_CLIPCHILDREN            0x20000000L
  256. #define HP_WS_CLIPSIBLINGS            0x10000000L
  257. #define HP_WS_MINIMIZED               0x01000000L
  258. #define HP_WS_MAXIMIZED               0x00800000L
  259. #define HP_WS_GROUP                   0x00010000L
  260. #define HP_WS_TABSTOP                 0x00020000L
  261.  
  262. #define HP_LB_GETTEXT   LB_GETTEXT
  263. #define HP_BM_GETSTATE  BM_GETSTATE
  264. #define HP_EM_GETMODIFY EM_GETMODIFY
  265. #define HP_EM_GETSEL    EM_GETSEL
  266. #define HP_LB_SELITEMRANGE LB_SELITEMRANGE
  267.  
  268. #define HP_MIA_CHECKED                0x2000
  269. #define HP_MIA_DISABLED               0x4000
  270. #define HP_MIA_HILITED                0x8000
  271.  
  272. // ==============================================================
  273. // HolePort message values.
  274. // ==============================================================
  275.  
  276. #define WM_PORT_BOTTOM  0x4A4D4800
  277. #define WM_SETICON                    (WM_PORT_BOTTOM + 0)
  278. #define HP_SBM_SETSCROLLBAR           (WM_PORT_BOTTOM + 1)
  279. #define MM_SETITEMATTR                (WM_PORT_BOTTOM + 2)
  280. #define HP_MLM_QUERYSEL               (WM_PORT_BOTTOM + 3)
  281. #define HP_EM_SETSEL                  (WM_PORT_BOTTOM + 4)
  282. #define HP_LM_SETITEMTEXT             (WM_PORT_BOTTOM + 5)
  283. #define HP_SBM_QUERYPOS               (WM_PORT_BOTTOM + 6)
  284. #define HP_SBM_QUERYRANGE             (WM_PORT_BOTTOM + 7)
  285. #define HP_SBM_SETPOS                 (WM_PORT_BOTTOM + 8)
  286.  
  287. // ==============================================================
  288. // Macros
  289. // ==============================================================
  290.  
  291. #define COMMANDMSG(pmsg) \
  292.         ((struct _COMMANDMSG FAR *)((PBYTE)pmsg + sizeof(UINT)))
  293.  
  294. #define MS_W32_NOTIMP(a) 0
  295. #define MAKEP(a,b) ((LPBYTE)(a) + (b))
  296. #define HP_SendMessage(h,m,w,l) HP_Message((h),(m),(w),(l),TRUE)
  297. #define HP_PostMessage(h,m,w,l) HP_Message((h),(m),(w),(l),FALSE)
  298.  
  299. #define MPFROMP(a)                 (a)
  300. #define CHAR1FROMMP(mp)            ((UCHAR)(mp))
  301. #define CHAR2FROMMP(mp)            ((UCHAR)((ULONG)mp >> 8))
  302. #define CHAR3FROMMP(mp)            ((UCHAR)((ULONG)mp >> 16))
  303. #define CHAR4FROMMP(mp)            ((UCHAR)((ULONG)mp >> 24))
  304. #define SHORT1FROMMP(mp)           ((USHORT)(ULONG)(mp))
  305. #define SHORT2FROMMP(mp)           ((USHORT)((ULONG)mp >> 16))
  306.  
  307.  
  308. #define HP_SetCurrentDirectory(a) (SetCurrentDirectory((a)) ? 0 : -1)
  309.  
  310. // ==============================================================
  311. // HolePort.c functions
  312. // ==============================================================
  313.  
  314.  
  315. LONG HP_gpiCharStringAt(HDC hdc, PPOINTL ppl, int cb, LPCSTR pch);
  316. USHORT HP_dosReallocSeg(USHORT usNew, SEL sel);
  317. USHORT HP_dosFreeSeg( SEL sel);
  318. USHORT HP_dosAllocSeg( USHORT usSize, PSEL psel, USHORT fs);
  319. BOOL HP_winQueryCursorInfo(HWND hd, PCURSORINFO pcsri);
  320. HWND HP_winQueryWindow(HWND hwnd, SHORT cmd, BOOL b);
  321. HANDLE HP_winQuerySysPointer(HWND hd, SHORT s, BOOL b);
  322. USHORT HP_dosChgFilePtr(HANDLE h, LONG l, USHORT M, PULONG pul);
  323. VOID HP_dosExit( USHORT usF, USHORT usC);
  324. USHORT HP_dosQHandType( HANDLE h, PULONG pul, PUSHORT pus);
  325. USHORT HP_dosQFileMode( PSZ psz, PULONG pul, DWORD d);
  326. USHORT HP_dosGetProcAddress( HANDLE h, PSZ psz, PPFN pul);
  327. DWORD  HP_dosMakeNmPipe(PSZ pszName, PHPIPE php, USHORT fsOpenMode,
  328.     USHORT fsPipeMode, USHORT cbOutBuf, USHORT cbInBuf, DWORD ulTimeOut);
  329. DWORD HP_dosOpen(PSZ pszFileName, PHANDLE phf, PUSHORT pusAction,
  330.     ULONG ulFileSize, USHORT usAttribute, USHORT fsOpenFlags, 
  331.     USHORT fsOpenMode, ULONG ul);
  332. USHORT HP_dosQCurDir(USHORT usDriveNum, PSZ pszPath, PUSHORT pcb);
  333. USHORT HP_dosQCurDisk(PUSHORT pusDriveNum, PULONG pul);
  334. USHORT HP_dosSelectDisk(USHORT usDriveNum);
  335. UINT HP_Message(HWND a, UINT b, WPARAM c, LPARAM d, UINT e);
  336. HWND HP_CreateStdWindow(HWND a,DWORD b,LPDWORD c,LPCTSTR d,LPCTSTR e,DWORD f,
  337.         HMODULE g, DWORD h, PHWND i);
  338. void HP_RegisterClass(LPCTSTR a, PFN b, DWORD c, int d);
  339. HFONT HP_SimpleFont( LPCTSTR a, LONG b, LONG c, DWORD d);
  340. UINT HP_DlgItemMessage(HWND hwnd, int idDlg, UINT msg, WPARAM mp1, LPARAM mp2);
  341. int HP_IsPtr( LPVOID lpv);
  342. DWORD HP_dosCreateSem(int bExclusive, LPHANDLE lph, LPCTSTR lpch);
  343. DWORD HP_dosOpenSem( LPHANDLE lph, LPCTSTR lpch, DWORD dwAccess);
  344. USHORT HP_dosSemClear(HANDLE lpv);
  345. USHORT HP_dosSemSet(HANDLE lpv);
  346. USHORT HP_dosSemWait(HANDLE lpv, DWORD lTimeOut);
  347. USHORT HP_dosSemRequest(HANDLE lpv, DWORD lTimeOut);
  348. DWORD HP_dosFindFirst(LPTSTR pszSpec, LPDWORD ph, USHORT usAttr,
  349.     LPWIN32_FIND_DATA lpdata, USHORT usBufLen, PUSHORT pusCount);
  350. USHORT HP_dosFindNext(DWORD dw, LPWIN32_FIND_DATA lpdata,
  351.         USHORT usBufLen, PUSHORT pusCount);
  352. USHORT HP_dosFindClose(DWORD dw);
  353. DWORD HP_dosNewSize(HANDLE h, DWORD dwSize);
  354. DWORD HP_dosFileLocks(HANDLE h, PFILELOCK pfUnlock, PFILELOCK pfLock);
  355. HP_dosLoadModule( LPCTSTR lpName, LPHANDLE ph);
  356. VOID HP_SetHinst(HANDLE h);
  357.  
  358.  
  359.