www.pudn.com > LastTray_Jpeg.rar > Capture.cpp
// Capture.cpp : implementation file
//
#include "stdafx.h"
#include "Tray.h"
#include "Capture.h"
#include "TrayDlg.h"
#include "BitmapFile.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCapture
void Screen(char filename[],CPoint p1,CPoint p2,int tag);
IMPLEMENT_DYNCREATE(CCapture, CWinThread)
CCapture::CCapture()
{
}
void CCapture::OnCaptureNew(CWnd *pWnd)
{
//以系统时间作为截取图片的文件名
SYSTEMTIME st;
//CString strDate,strTime;
//GetLocalTime(&st);
CString strTime;
GetLocalTime(&st);
strTime.Format("%d_%d_%d_%d_%d_%d",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
char FileName[50];
int count=0;
CString time;
char *end;
GetPrivateProfileString("Time delay","time",NULL,time.GetBuffer(MAX_PATH),MAX_PATH,".\\Tray.ini");
long delay = strtol(time,&end,10);
//进行截图操作
int amount = GetPrivateProfileInt("amount","Amount",NULL,".\\Tray.ini");
while( count < amount)
{
Sleep(delay);
count ++;
sprintf(FileName,"%s_%d.jpg",strTime,count); //执行完该句后,count变成了一个很大的数字,然后程序崩溃了
CBitmapFile obj;
obj.SaveDesktopAsFile(FileName,JPG_FILE,p1,p2,tag);
}
}
void Screen(char filename[],CPoint p1,CPoint p2,int tag)
{
}
CCapture::~CCapture()
{
}
BOOL CCapture::InitInstance()
{
// TODO: perform and per-thread initialization here
OnCaptureNew(pWnd);
m_start.EnableWindow(TRUE);
MessageBox(NULL,"截图完成","END",MB_OK);
return TRUE;
}
int CCapture::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(CCapture, CWinThread)
//{{AFX_MSG_MAP(CCapture)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCapture message handlers