home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
REND.LZH
/
REND
/
LOG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-08
|
1KB
|
84 lines
#undef FLOAT
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <dir.h>
const int UM_STRING_INSERT = 303;
//#include "id.h"
static char LogName[MAXPATH+32];
int WindowInsertString(char name[], char buf[])
{
char str[256];
HGLOBAL hData;
HWND hwnd;
char *p, *q;
int len;
hwnd=FindWindow(name, NULL);
if(hwnd==NULL) return -1;
p=str;
for(q=buf; *q!='\0';)
{
if(*q=='\n') *p++='\r';
*p++=*q++;
}
*p='\0';
len=strlen(str)+1;
hData=GlobalAlloc(
GMEM_MOVEABLE, len);
p=(char *)GlobalLock(hData);
strcpy(p, str);
GlobalUnlock(hData);
SendMessage(hwnd,
UM_STRING_INSERT,
0, (LPARAM)hData);
return 0;
}
int loginit(char format[], ...)
{
return 0;
}
int logprintf(char format[], ...)
{
va_list arglist;
char buf[256];
va_start(arglist, format);
vsprintf(buf, format, arglist);
va_end(arglist);
return WindowInsertString("Log Editor", buf);
}
void print(char format[], ...)
{
va_list arg_ptr;
char buf[256];
va_start(arg_ptr, format);
vsprintf(buf, format, arg_ptr);
va_end(arg_ptr);
if(WindowInsertString("Stat Flex Editor", buf))
{
logprintf("Because Log Window can not be found,\n");
logprintf("the message (%s) can not be printed.\n", buf);
}
}
/* num行の空行を挿入する */
void slf(int num)
{
while(num-->0) print("\n");
}