06-07-2014 01:08 PM
hello everyone,
ill be short and i hope someone will know how to help me.
I have an application, in wich in its end, i want to make a screen capture after hiding the main panel.
Meanning i dont need the panel`s capture, but the windows and whatever programs are working at that time.
Plus i need the screen capture photo in a bitmap/jpg/atc. file.
thanks in advance,
Adi.
06-07-2014 05:53 PM
Hello, you could use GetPanelDisplayBitmap and SaveBitmapToPngFile (or to other file format like jpg: look at available functions in the help)
06-07-2014 06:03 PM
Just reading your post better and my answer is not what you are looking for.
Take a look at this thread and at NickB code in this other one
06-08-2014 03:03 AM
Not sure i can use these previos posts...
hope i just didnt miss understand it.
I need the screen capture to happend by it self.
The operator presses a command botton that generats few thing, then hides the panel - and only then takes the screen shot...
I dont want the operator to be involved in the capture process.
But i do need it in a file.
thanks.
06-08-2014 08:41 AM
i just need hiding the panel
and saving a screen capture
there is my spesific code :
...
HidePanel (panelHandle);
keybd_event(0x2C, 0, 0, 0);
ClipboardGetBitmap (&image, NULL);
SaveBitmapToJPEGFile (image, machinestr3, 0, 100);
QuitUserInterface (0);
...
I keep getting things I dont understand why they happen.
first one after saving my code and running:
NON-FATAL RUN-TIME ERROR: "NewScap.c", line 449, col 17, thread id 0x0000255C: Library function error (return value == -127 [0xffffff81]). Bitmap is invalid
then when i press again on run - it runs perfect the first time,
then when i run again and again I keep getting the screen capture of time I pressed the first time.
plz help i am a bit frustrated.
tnx Adi.
06-09-2014 02:37 AM - edited 06-09-2014 02:38 AM
I have problems myself with this function, even though different from yours. In my case it keeps saving simply the previous image pasted to the clipboard: that is, if I execute the function at 9:00:00 it saves the screenshot taken e.g. at 8:58:00; next time it will save screenshot taken at 9:00:00 and so on.
I supposed I am simply too fast in saving the image: in effect adding a small delay corrected the problem.
The complete function, with error trapping added, is the following:
int avail, bitmap = 0, error = 0; char msg[512]; // ... other code here keybd_event (VK_SNAPSHOT, 0, 0, 0); DelayWithEventProcessing (1.0); // Delay added ClipboardGetBitmap (&bitmap, &avail); if (!avail) MessagePopup ("Warning", "No bitmap available in the clipboard!"); else error = SaveBitmapToPNGFile (bitmap, "c:\\temp\\bitmap.png"); // Clearing resources and error warning if (bitmap) DiscardBitmap (bitmap); if (error < 0) { sprintf (msg, "Error %d found:\n%s", error, GetGeneralErrorString (error)); MessagePopup ("Warning", msg); }
Check your situation and see if this workaround can fix your problems too.
06-09-2014 06:10 AM
THANK YOU VERY MUCH !!!
And the part i needed the most is indeed the delay function....
It solved 3 problems i had.
(i am writing it so if more ppl would get in trouble with it)
1.At initial run it couldnt find the bitmap, and the application kept crushing down, i guess its like u wrote - that was too fast.
2.The image i got was of previos run not corrent run.
3.The images were saved with the application`s panel in it.
here is the code I finaly used :
//...........rest of code
HidePanel (panelHandle);
DelayWithEventProcessing (1.0);
keybd_event(VK_SNAPSHOT, 0, 0x0001, 0);
DelayWithEventProcessing (1.0);
ClipboardGetBitmap (&image, NULL);
SaveBitmapToJPEGFile (image, "IMAGE_NAME", 0, 100);
//...........rest of code
{ill take the error traping to another place in my code 🙂 }
Thank you very much Mr. Bozzolo.
I hope this post would help more ppl.
Adi.
06-09-2014 06:21 AM
Good to know you've solved your problem
Another hint I can give you: if the panel has elementos with a transparent background (labels, pictures and so on) you will receive errors in SaveBitmapToJPEGFile since jpg format cannot handle transparency: in this case you can use png format and the corresponding SaveBitmapToPNGFile.