Hallo - I have somw code that looks like this:
void __fastcall Tmainform::tmrClickTimer(TObject *Sender)
{
if(!doing){
doing=true;
char buffer[16];
int len;
keybd_event(VK_SNAPSHOT,0,0,0);
if(clp->HasFormat(CF_BITMAP))
bmp->LoadFromClipboardFormat(CF_BITMAP,clp->GetAsHandle(CF_BITMAP),0);
string fname="C:\\temp\\stream_pics\\ss";
ltoa(num,buffer,10);
len=8-strlen(buffer);
for(int i=0;i<len;i++)
fname+="0";
fname+=buffer;
fname+=".bmp";
bmp->SaveToFile(fname.c_str());
num++;
doing=false;
}
}
As that looks like a total pig, I'll exlpain - I have a Clipboard, a Bitmap, a Timer and a number. Each time the timer's event is called, I call PreintScreen with a keybd_event, then copy from the clipboard to the bitmap. I then want to save that to file. There is a bool called 'doing' that's supposed to save me from screw ups, but it doesn't seem to.
Can anybody suggest why this is failing (always on the line where the string fname is declared)? I guess it's because of multiple calls to the timer. If so, anyone any ideas?
Cheers,
Douglas JL
If it don't make you laugh, it ain't true.
void __fastcall Tmainform::tmrClickTimer(TObject *Sender)
{
if(!doing){
doing=true;
char buffer[16];
int len;
keybd_event(VK_SNAPSHOT,0,0,0);
if(clp->HasFormat(CF_BITMAP))
bmp->LoadFromClipboardFormat(CF_BITMAP,clp->GetAsHandle(CF_BITMAP),0);
string fname="C:\\temp\\stream_pics\\ss";
ltoa(num,buffer,10);
len=8-strlen(buffer);
for(int i=0;i<len;i++)
fname+="0";
fname+=buffer;
fname+=".bmp";
bmp->SaveToFile(fname.c_str());
num++;
doing=false;
}
}
As that looks like a total pig, I'll exlpain - I have a Clipboard, a Bitmap, a Timer and a number. Each time the timer's event is called, I call PreintScreen with a keybd_event, then copy from the clipboard to the bitmap. I then want to save that to file. There is a bool called 'doing' that's supposed to save me from screw ups, but it doesn't seem to.
Can anybody suggest why this is failing (always on the line where the string fname is declared)? I guess it's because of multiple calls to the timer. If so, anyone any ideas?
Cheers,
Douglas JL
If it don't make you laugh, it ain't true.