home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / WINIOBC.ZIP / WINIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-09  |  7.4 KB  |  224 lines

  1. /*
  2. WINIO.H
  3. Stdio (e.g. printf) functionality for Windows - definition
  4.  
  5. from "Undocumented Windows" (Addison-Wesley, 1992)
  6. by Andrew Schulman, Dave Maxey and Matt Pietrek.
  7.  
  8. Copyright (c) Dave Maxey and Andrew Schulman 1991-1992. All rights reserved.
  9. */
  10.  
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /* ==== STDIO.H for Windows ==== */
  15. #include <stdarg.h>
  16. #ifdef __BORLANDC__
  17. /* Borland C++ STDIO.H doesn't do gets, etc. #if defined(_Windows) */
  18. #undef _Windows
  19. #include <stdio.h>
  20. #define _Windows
  21. #else
  22. #include <stdio.h>
  23. #endif
  24.  
  25. #if defined(_MSC_VER) && (_MSC_VER >= 700)
  26. #define main    winio_main
  27. #endif
  28.  
  29. #ifndef MK_FP
  30. #define MK_FP(s,o) ((void far *) (((DWORD) (s) << 16) | (o)))
  31. #endif
  32.  
  33. #undef putchar
  34. #define putchar fputchar
  35. #undef getchar
  36. #define getchar fgetchar
  37. BOOL kbhit(void);
  38.  
  39. /* these were missing from original MSJ version, which assumes inclusion
  40.    of WINDOWS.H as well as WINIO.H.  #ifndef PASCAL is a semi-unreliable
  41.    way to check for inclusion of any vendor's WINDOWS.H */
  42. #ifndef PASCAL
  43. typedef unsigned HANDLE;
  44. typedef unsigned char BYTE;
  45. typedef unsigned WORD;
  46. typedef unsigned BOOL;
  47. typedef unsigned long DWORD;
  48. typedef unsigned HWND;
  49. typedef long LONG;
  50. #define PASCAL pascal
  51. #define FAR far
  52. #endif
  53.  
  54. /* winio_init() must be called before any of the above listed
  55. functions to introduce the app to WINIO. This function should only be
  56. called from WinMain before main() is invoked */
  57. int winio_init(void);
  58.  
  59. /* Signals WINIO that the task is terminating. Makes all windows for the 
  60. task inactive, and allows the user to view and play with
  61. them until double-clicking on the system menu of each to close. Will
  62. only be called from WinMain() upon return from main() */
  63. void winio_end(void);
  64.  
  65. /* closes a window and frees up buffers */
  66. void winio_close(HWND hWnd);
  67.  
  68. /* closes all windows for the app and frees up all buffers. Will usually
  69. only be called by winio_app_exit() which itself is registered via atexit() */
  70. void winio_closeall(void);
  71.  
  72. #define     WW_HASMENU          0x0001 // new window has standard menu
  73. #define     WW_EXITALLOWED      0x0002 // ignored unless WW_HASMENU
  74. #define     WW_STAYSONTOP       0x0004 // window will always overlay parent
  75. #define     WW_OUTPUTONLY       0x0008 // window will not take input
  76.  
  77. /* Creates a new window. strTitle is the initial title. The bufsize
  78. parameter if 0 means default (16k). wFlags are one or more of the
  79. above flags ORed together */
  80. HWND winio_window(LPSTR strTitle, WORD wBufSize, WORD wFlags);
  81.  
  82. /* Tells an app how many windows are still open */
  83. int winio_openwindows(void);
  84.  
  85. /* Sets the current window. This is the window that will be the target
  86. for STDIO calls. Returns the previous current. */
  87. HWND winio_setcurrent(HWND);
  88.  
  89. /* Resizes the output buffer for the specified window. If the BOOL
  90. parameter is FALSE, the buffer cannot be shrunk to smaller than the amount
  91. currently in use. If the BOOL parameter is TRUE, the buffer will be
  92. cleared, and the new size can be anything over 4K. The return value is
  93. the new actual buffer size. */
  94. WORD winio_setbufsize(HWND, WORD, BOOL);
  95.  
  96. /* Sets the default window size (height in high order WORD, width
  97. in low order, both in chars) to have an effect in future
  98. winio_window calls. Returns previous in effect. */
  99. DWORD winio_defwindowsize(DWORD);
  100.  
  101. /* Return the window's output buffer size */
  102. WORD winio_bufsize(HWND);
  103.  
  104. /* Sets the text for the Help About... box which is only present
  105. on the main window - truncated to a maximum of 512 chars. */
  106. void winio_about(char *);
  107.  
  108. /* Sets the text for the specified window. This is here only for consistency
  109. since it is a direct cover on SetWindowText().... */
  110. void winio_settitle(HWND, char *);
  111.  
  112. /* May be SYSTEM_FIXED_FONT (default), ANSI_FIXED_FONT, or OEM_FIXED_FONT */
  113. WORD winio_setfont(HWND, WORD);
  114.  
  115. typedef void (* LINEHANDLER)(HWND, LPSTR, int);
  116.  
  117. /* Sets up a handler for a user double-click. May be cancelled using
  118.     winio_linefn(hwnd, NULL). Returns previous handler...  */
  119. LINEHANDLER winio_setlinefn(HWND, LINEHANDLER);
  120.  
  121. /* To turn automatic updating of window off and on */
  122. BOOL winio_setpaint(HWND, BOOL);
  123.  
  124. /* Goes to top left of window buffer */
  125. void winio_home(HWND);
  126.  
  127. /* Captures the cursor and turns it into an hourglass. Calling this
  128. function repeatedly increments a counter. */
  129. void winio_setbusy(void);
  130.  
  131. /* Decrements the counter incremented above. Returns the cursor to the
  132. arrow when the counter reaches 0. */
  133. void winio_resetbusy(void);
  134.  
  135. /* To change the behavior of getchar(). Note. This is a task global,
  136. because console input is only ever coming from one Window at a time */
  137. BOOL winio_setecho(HWND, BOOL);
  138.  
  139. /* clear out the contents of the buffer and start over fresh */
  140. void winio_clear(HWND);
  141.  
  142. /* Returns the current WINIO window handle */
  143. HWND winio_current(void);
  144.  
  145. /* ==== User definable exit routine ==== */
  146.  
  147. typedef void (* DESTROY_FUNC)(HWND);
  148.  
  149. /* Optional notification function; without it, there is no way for your
  150. application to know if the user has double-clicked the system menu box */
  151. void winio_onclose(HWND, DESTROY_FUNC);
  152.  
  153. /* ==== User definable paint involvement routines ==== */
  154.  
  155. typedef struct {
  156.     POINT dimChar;          // dimensions of a character cell
  157.     POINT posCurr;          // curr pos from top of buffer in chars.
  158.     RECT rectView;          // frame in view from top of buffer in chars.
  159.     long cDiscarded;        // lines discarded from buffer so far
  160.     }   WINIOINFO,
  161.         * PWINIOINFO,
  162.         FAR * LPWINIOINFO;
  163.  
  164.  
  165. typedef BOOL (* PAINT_FUNC)(HWND, HDC, PAINTSTRUCT *, PWINIOINFO);
  166.  
  167. /* Optional paint daemon installation functions; with these, it is
  168. possible to install routines that can prepare the DC on entry, or
  169. redraw some graphics on exit, or whatever. */
  170. PAINT_FUNC winio_onpaintentry(HWND, PAINT_FUNC);
  171. PAINT_FUNC winio_onpaintexit(HWND, PAINT_FUNC);
  172.  
  173. /* To obtain WINIOINFO at non-WM_PAINT times */
  174. void winio_getinfo(HWND, PWINIOINFO);
  175.  
  176.  
  177. /* ==== Utility functions built on message box ==== */
  178.  
  179. BOOL winio_warn(BOOL, char *, const char *, ...);
  180.  
  181. /* fail() is a format/var.args. dialog box and exit routine */
  182. void fail(const char *strFmt, ...);
  183.  
  184. /* ==== STDIO extension function ==== */
  185.  
  186. char *ungets(char *);
  187.  
  188.  
  189. typedef void (* MENU_FUNC)(HWND, int);
  190.  
  191.  
  192. /* The following functions allow submenus to be added to a window's
  193. existing menu, and for handler functions to be registered against new
  194. options. winio_hmenumain returns the handle to the window's main
  195. menu, and winio_hmenufile returns the handle to the window's file
  196. popup menu. The application can then use AppendMenu/InsertMenu to add
  197. additional menus/choices. winio_setmenufunc allows a handler function
  198. to be registered for a menu option id. NOTE that if a menu option id
  199. is not registered with a handler in this way, the app will never know
  200. that the option has been selected... NOTE ALSO that application menu
  201. option IDs must be allocated from 1 thru 32 (giving a total of 32
  202. possible additional menu options per window). */
  203.  
  204. HMENU winio_hmenumain(HWND);
  205.  
  206. HMENU winio_hmenufile(HWND);
  207.  
  208. HMENU winio_hmenuhelp(HWND);
  209.  
  210. MENU_FUNC winio_setmenufunc(HWND, int, MENU_FUNC);
  211.  
  212. // The following are defined in argcargv.c 
  213. extern HANDLE __hInst;
  214. extern HANDLE __hPrevInst;
  215. extern LPSTR __lpCmdLine;
  216. extern int __nCmdShow;
  217. extern HWND __hMainWnd;
  218. extern WORD __hAppTimer;
  219. extern char __szModule[];
  220.  
  221. #ifdef __cplusplus
  222. }
  223. #endif
  224.