Save Screenshot
-
Hi, I'm developing a Visual C++ App. I need to save my app's screenshot and save it as an image (to analize it in future). Can somebody help me to do this on a Button's click event? Thanks a lot
You can save your app's screen as a bmp file. there are many samples in code project desribing this. Have a search. How ever i will explain the steps. Get the device context of your window. Create a memory dc and a bitmap. bitblt the content of the screen to the memory dc now get the pixel data and other informarion from this bimap object and write to a file.
nave [OpenedFileFinder]
-
Hi, I'm developing a Visual C++ App. I need to save my app's screenshot and save it as an image (to analize it in future). Can somebody help me to do this on a Button's click event? Thanks a lot
Do you have any handle of this screenshot (hbitmap)?
WhiteSky
-
Do you have any handle of this screenshot (hbitmap)?
WhiteSky
I need to save the screenshot in a file .bmp or jpg (better) and the post it via email. I don't have implement nothing code yet, have you sample code? How I've just said I need to post it in email message (compiled with the TO: address), is there an API function (like the HTML "mailto:mymail@my.com" or some simple command) to open the user's email App with this message ready to me sent? Thanks. -- modified at 6:53 Friday 15th June, 2007
-
I need to save the screenshot in a file .bmp or jpg (better) and the post it via email. I don't have implement nothing code yet, have you sample code? How I've just said I need to post it in email message (compiled with the TO: address), is there an API function (like the HTML "mailto:mymail@my.com" or some simple command) to open the user's email App with this message ready to me sent? Thanks. -- modified at 6:53 Friday 15th June, 2007
Yeah I had and I think its easy for you,you can send a message with attachment for send message with attachment you can use of IMAPI(I think you can find an example on the codeproject. for make a file simplest code is like this (but you didnt tell me do you have a handle (hbitmap) or no)
CImage m_Image;
m_Image.Attach(hbitmap);
m_Image.Save(filename,file type but if you dont set this parameter I think it makes a bitmap);
//but you can save your file with png,jpg,...
m_Image.Detach();this code is simplest code that you can make your file. Does this information helpful and does your problem solve or no.
WhiteSky
-
Yeah I had and I think its easy for you,you can send a message with attachment for send message with attachment you can use of IMAPI(I think you can find an example on the codeproject. for make a file simplest code is like this (but you didnt tell me do you have a handle (hbitmap) or no)
CImage m_Image;
m_Image.Attach(hbitmap);
m_Image.Save(filename,file type but if you dont set this parameter I think it makes a bitmap);
//but you can save your file with png,jpg,...
m_Image.Detach();this code is simplest code that you can make your file. Does this information helpful and does your problem solve or no.
WhiteSky
I don't have hbitmap I need to capture the screen, and than save the image with the code you post (thanks for this). - I need to know how to capture the screen bitmap? - Can you easilly post me code or an example of the IMAPI's use (or when I can I'll search an examle).. Thaks of all.
-
I don't have hbitmap I need to capture the screen, and than save the image with the code you post (thanks for this). - I need to know how to capture the screen bitmap? - Can you easilly post me code or an example of the IMAPI's use (or when I can I'll search an examle).. Thaks of all.
You must wait till I find my code and then send for you.:)
WhiteSky
-
I don't have hbitmap I need to capture the screen, and than save the image with the code you post (thanks for this). - I need to know how to capture the screen bitmap? - Can you easilly post me code or an example of the IMAPI's use (or when I can I'll search an examle).. Thaks of all.
HDC m_hdcMem,hdc;
HBITMAP m_Bitmap,m_OldBitmap,hMainBmp ;
//one intersting for you if you want to use of other resulition
you can simply change 800x600(640x480/1024x768,...)
int x=800;
int y=600;//use of GetDC()->m_hDC and see result.
//hdc=GetDC()->m_hDC;
hdc=GetDesktopWindow()->GetDC()->m_hDC;m_hdcMem= CreateCompatibleDC(hdc);
//one interesting for you if you want to use of other
m_Bitmap = CreateCompatibleBitmap(hdc,x,y);
m_OldBitmap=(HBITMAP) SelectObject(m_hdcMem, m_Bitmap);BitBlt(m_hdcMem, 0,0,x,y, hdc,0,0,SRCCOPY);
hMainBmp =(HBITMAP) SelectObject(m_hdcMem, m_OldBitmap);
///////////Now you have a hbitmap of screen hMainBmp/////CImage m_Image;
m_Image.Attach(hMainBmp);
m_Image.Save("c:\\test.bmp");//use of jpg instead bmp but if you can zip your file its good.
m_Image.Detach();
DeleteDC(m_hdcMem);
DeleteObject(hMainBmp );
DeleteObject(m_OldBitmap);for second part I could'nt find my program but I found a good article for you Another simple MAPI class[^]
WhiteSky
-
HDC m_hdcMem,hdc;
HBITMAP m_Bitmap,m_OldBitmap,hMainBmp ;
//one intersting for you if you want to use of other resulition
you can simply change 800x600(640x480/1024x768,...)
int x=800;
int y=600;//use of GetDC()->m_hDC and see result.
//hdc=GetDC()->m_hDC;
hdc=GetDesktopWindow()->GetDC()->m_hDC;m_hdcMem= CreateCompatibleDC(hdc);
//one interesting for you if you want to use of other
m_Bitmap = CreateCompatibleBitmap(hdc,x,y);
m_OldBitmap=(HBITMAP) SelectObject(m_hdcMem, m_Bitmap);BitBlt(m_hdcMem, 0,0,x,y, hdc,0,0,SRCCOPY);
hMainBmp =(HBITMAP) SelectObject(m_hdcMem, m_OldBitmap);
///////////Now you have a hbitmap of screen hMainBmp/////CImage m_Image;
m_Image.Attach(hMainBmp);
m_Image.Save("c:\\test.bmp");//use of jpg instead bmp but if you can zip your file its good.
m_Image.Detach();
DeleteDC(m_hdcMem);
DeleteObject(hMainBmp );
DeleteObject(m_OldBitmap);for second part I could'nt find my program but I found a good article for you Another simple MAPI class[^]
WhiteSky
Thanks al lot for the help, now I'm able to save and send screenshot vie email. With the sample you send me I'm able to send email directly in "background", but how can I obtain an editable and pre-compiled mail on my email's Manager (Outlook Express) so that I can add text or modify something before send it? Thanks.
-
Thanks al lot for the help, now I'm able to save and send screenshot vie email. With the sample you send me I'm able to send email directly in "background", but how can I obtain an editable and pre-compiled mail on my email's Manager (Outlook Express) so that I can add text or modify something before send it? Thanks.
I think you can find exmaples about outlook express but I'm not sure I saw on the Codeproject or other sites(I saw many years ago) on that article user able to fill fields on the outlook,but why you dont use of your program I dont know aout your program is that a project or homework but for example you can insert two options to your program on the first option user use of a file that this file made previous with program,on other choise you show a dialog to user and he can selects detaily for send (To,Bc,BCC,attachment) and for detaily of image(size of image(100x100,...),type of image(bmp,...) and advanced option on the BitBlt(0(or insert different x),0(or insert different y),x,y,..).
WhiteSky
-
I think you can find exmaples about outlook express but I'm not sure I saw on the Codeproject or other sites(I saw many years ago) on that article user able to fill fields on the outlook,but why you dont use of your program I dont know aout your program is that a project or homework but for example you can insert two options to your program on the first option user use of a file that this file made previous with program,on other choise you show a dialog to user and he can selects detaily for send (To,Bc,BCC,attachment) and for detaily of image(size of image(100x100,...),type of image(bmp,...) and advanced option on the BitBlt(0(or insert different x),0(or insert different y),x,y,..).
WhiteSky
My programm is a project, an "analisy and reporter project", and I want to fit it with the MS Office's standards, so I must have a preview of the mail to send with the document attached (or empty if so). However I accept your suggest and I can try to perform this (initially) but then I like to obtain what I search. Thanks a lot for Help, it's very usefull. Bye
-
My programm is a project, an "analisy and reporter project", and I want to fit it with the MS Office's standards, so I must have a preview of the mail to send with the document attached (or empty if so). However I accept your suggest and I can try to perform this (initially) but then I like to obtain what I search. Thanks a lot for Help, it's very usefull. Bye
Some time ago I saw a question on this forum bout preview of print well it seems to you do you wan to make your print preview or use of a activex (I personal dont want to tell you use of activex I like that you make your class and use of it its better for preview an article is on the www.codresource.net (Im not sure spell of this address is correct or no) except this site on the codeproject you can see a lot of articles that they show steps for write preview).Your answer doesnt have an answer "MS Office's standards" I think you want to write a package that conform with office well I think you are lucky I think if you search on the codeproject you can find your answer and more thing that I like to tell you always check variables and return value and generaly all things for example you get a screenshot but hbitmap is null so if you pass this variable to CImage you will get an exception or other example you run your program of CD so you cant save your file on the CD. I hope this informations helpful for you.
WhiteSky
-
Some time ago I saw a question on this forum bout preview of print well it seems to you do you wan to make your print preview or use of a activex (I personal dont want to tell you use of activex I like that you make your class and use of it its better for preview an article is on the www.codresource.net (Im not sure spell of this address is correct or no) except this site on the codeproject you can see a lot of articles that they show steps for write preview).Your answer doesnt have an answer "MS Office's standards" I think you want to write a package that conform with office well I think you are lucky I think if you search on the codeproject you can find your answer and more thing that I like to tell you always check variables and return value and generaly all things for example you get a screenshot but hbitmap is null so if you pass this variable to CImage you will get an exception or other example you run your program of CD so you cant save your file on the CD. I hope this informations helpful for you.
WhiteSky
-
I tried to told a good answer to you but maybe I was lucky that I saw your question!;)
WhiteSky