#include "stdafx.h"
#include <Windows.h>
#include <string>
#include<time.h>
using namespace std;
HWND hWindSnapman = NULL;
int nFiledIndex = 0;
const int SNAPMAN_APP_PROGRESS = 0;
const int SNAPMAN_APP_MESSAGE = 1;
const int SNAPMAN_APP_LOGFILE = 2;
const int SNAPMAN_APP_RESULTFILE = 3;
const int SNAPMAN_APP_COMPLETE = 4;
const int SNAPMAN_APP_CELLDATA = 5;
const int SNAPMAN_APP_CELLFONTCOLOR = 6;
const int SNAPMAN_APP_CELLBACKCOLOR = 7;
void SnapmanSendProgress(int nProgress)//发送进度,nProgress范围[0,100]
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %d",nFiledIndex,nProgress);
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_PROGRESS, (LPARAM)buffer);
}
void SnapmanSendMessage(const wstring &strMessage)//发送运行时消息
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %s",nFiledIndex,strMessage.c_str());
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_MESSAGE, (LPARAM)buffer);
}
void SnapmanSendLogFile(const wstring &strLogFilePath)//发送日志文件
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %s",nFiledIndex,strLogFilePath.c_str());
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_LOGFILE, (LPARAM)buffer);
}
void SnapmanSendResultFile(const wstring &strResultFilePath)//发送结果文件
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %s",nFiledIndex,strResultFilePath.c_str());
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_RESULTFILE, (LPARAM)buffer);
}
void SnapmanSendAppCompleted(bool bSuccess)//发送程序结束命令
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %d",nFiledIndex,bSuccess);
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_COMPLETE, (LPARAM)buffer);
}
void SnapmanSendCellData(int nRow, int nCol,const wstring &strData)//改变某单元格的内容
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %d %d %s",nFiledIndex,nRow,nCol,strData.c_str());
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_CELLDATA, (LPARAM)buffer);
}
void SnapmanSendCellFontColor(int nRow, int nCol,int nColor)//改变某单元格的字体颜色
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %d %d %d",nFiledIndex,nRow,nCol,nColor);
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_CELLFONTCOLOR, (LPARAM)buffer);
}
void SnapmanSendCellBackColor(int nRow, int nCol,int nColor)//改变某单元格的背景颜色
{
wchar_t buffer[1024] = {0};
wsprintf(buffer,L"%d %d %d %d",nFiledIndex,nRow,nCol,nColor);
SendMessage(hWindSnapman, WM_SETTEXT, (WPARAM)SNAPMAN_APP_CELLBACKCOLOR, (LPARAM)buffer);
}
int SnapmanMain(_TCHAR *argv);
int _tmain(int argc, _TCHAR* argv[])
{
wprintf(L"%s\n",argv[0]);
hWindSnapman = (HWND)_wtoi(argv[1]);
nFiledIndex = _wtoi(argv[2]);
return SnapmanMain(argc>=4?argv[3]:NULL);
}
int SnapmanMain(_TCHAR *argv)
{
return 0;
}