home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / msj / v06n06 / intnat.exe / KEY.EXE / WINUTILS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-01  |  1.7 KB  |  68 lines

  1. /* 
  2.  * WINUTIL.C A set of useful Windows utility functions for KEYMAP
  3.  * Copyright (c) 1991 by William S. Hall and Peter Belew
  4.  */
  5.  
  6. #define NOCOMM
  7. #define NOKANJI
  8. #define NOSOUND
  9. #include <windows.h>
  10. #include <stdarg.h>
  11. #include <stdio.h>
  12. #include "winutils.h"
  13.  
  14. /* 
  15.  * This function replaces printf and sends output to the AUX device
  16.  * To use this function you must load the device driver OX.SYS
  17.  * Do NOT run Windows with redirection to AUX.
  18.  * Use dbs just like printf
  19.  * Example dbs("function foo %d %s, myint, mystring);
  20.  */
  21. void FAR _cdecl dbs(const char *fmt, ...)
  22. {
  23.     char buf[255];
  24.  
  25.     va_list arg_ptr;
  26.  
  27.     va_start(arg_ptr, fmt);
  28.     vsprintf(buf, fmt, arg_ptr);
  29.     va_end(arg_ptr);
  30.  
  31.     OutputDebugString(buf);
  32.  
  33. }
  34.  
  35. /* opens a modal dialog box */
  36. int FAR OpenDlgBox(HWND hWnd, FARPROC fpProc, WORD boxnum)
  37. {
  38.  
  39.     FARPROC fp;
  40.     int result;
  41.     HANDLE hInst = GetWindowWord(hWnd, GWW_HINSTANCE);
  42.  
  43.   /* make a proc instance for the about box window function */
  44.     fp = MakeProcInstance(fpProc, hInst);
  45.   /* create a modal dialog box */
  46.     result = DialogBox(hInst, MAKEINTRESOURCE(boxnum), hWnd, fp);
  47.     FreeProcInstance(fp);
  48.     return result;
  49.  
  50. }
  51.  
  52. /* opens a modal dialog box with parameters */
  53. int FAR OpenDlgBoxParam(HWND hWnd, FARPROC fpProc, WORD boxnum, LONG lParam)
  54. {
  55.  
  56.     FARPROC fp;
  57.     int result;
  58.     HANDLE hInst = GetWindowWord(hWnd, GWW_HINSTANCE);
  59.  
  60.   /* make a proc instance for the about box window function */
  61.     fp = MakeProcInstance(fpProc, hInst);
  62.   /* create a modal dialog box */
  63.     result = DialogBoxParam(hInst, MAKEINTRESOURCE(boxnum), hWnd, fp, lParam);
  64.     FreeProcInstance(fp);
  65.     return result;
  66.  
  67. }
  68.