home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / PASM.LZH / LOG.CPP < prev    next >
C/C++ Source or Header  |  1995-11-08  |  1KB  |  84 lines

  1. #undef FLOAT
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <stdarg.h>
  5. #include <string.h>
  6. #include <dir.h>
  7.  
  8. const int UM_STRING_INSERT = 303;
  9. //#include "id.h"
  10.  
  11. static char LogName[MAXPATH+32];
  12.  
  13. int WindowInsertString(char name[], char buf[])
  14. {
  15.     char str[256];
  16.     HGLOBAL hData;
  17.     HWND hwnd;
  18.     char *p, *q;
  19.     int len;
  20.  
  21.     hwnd=FindWindow(name, NULL);
  22.     if(hwnd==NULL) return -1;
  23.  
  24.     p=str;
  25.     for(q=buf; *q!='\0';)
  26.     {
  27.         if(*q=='\n') *p++='\r';
  28.         *p++=*q++;
  29.     }
  30.     *p='\0';
  31.  
  32.     len=strlen(str)+1;
  33.     hData=GlobalAlloc(
  34.         GMEM_MOVEABLE, len);
  35.     p=(char *)GlobalLock(hData);
  36.     strcpy(p, str);
  37.     GlobalUnlock(hData);
  38.     SendMessage(hwnd,
  39.         UM_STRING_INSERT,
  40.         0, (LPARAM)hData);
  41.  
  42.     return 0;
  43. }
  44.  
  45. int loginit(char format[], ...)
  46. {
  47.     return 0;
  48. }
  49.  
  50. int logprintf(char format[], ...)
  51. {
  52.     va_list arglist;
  53.     char buf[256];
  54.  
  55.     va_start(arglist, format);
  56.     vsprintf(buf, format, arglist);
  57.     va_end(arglist);
  58.  
  59.     return WindowInsertString("Log Editor", buf);
  60. }
  61.  
  62. void print(char format[], ...)
  63. {
  64.     va_list arg_ptr;
  65.     char buf[256];
  66.  
  67.     va_start(arg_ptr, format);
  68.     vsprintf(buf, format, arg_ptr);
  69.     va_end(arg_ptr);
  70.  
  71.     if(WindowInsertString("Stat Flex Editor", buf))
  72.     {
  73.         logprintf("Because Log Window can not be found,\n");
  74.         logprintf("the message (%s) can not be printed.\n", buf);
  75.     }
  76. }
  77.  
  78. /* num行の空行を挿入する */
  79. void slf(int num)
  80. {
  81.     while(num-->0) print("\n");
  82. }
  83.  
  84.