Screenshot just the active window lazarus / 39-Graphics ---------------------------------------------------------------------- Gizmo · 2015-03-12 21:06 Hi I read http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Tak ing_a_screenshot_of_the_screen (which the solution suggests how to screenshot the program itself) and http://wiki.lazarus.freepascal.org/ Developing_with_Graphics#Taking_a_screenshot_of_the_screen and have implemented the code to take a screenshot of the entire screen. However, I'd like my program to take a screenshot of the ACTIVE WINDOW only. So lets say my program is minimised or in the taskbar and the user has a word processing program running. How can my I take a screenshot of only the word processing application? Thanks ---------------------------------------------------------------------- zeljko · 2015-03-12 21:11 1.Take screenshoot of entire desktop -> TBitmap 2.Ask operating system (win32,mac) or X11 (linux) for active window 3.Take bounds rect of active window (from OS or X11) 4.copy that rect from screenshoot of entire desktop ---------------------------------------------------------------------- engkin · 2015-03-12 21:26 Instead of GetDC use GetWindowDC, and instead of 0 for entire desktop, use GetForegroundWindow for the active window. ---------------------------------------------------------------------- zeljko · 2015-03-13 07:09 Quote from: engkin on March 12, 2015, 10:26:04 pmInstead of GetDC use GetWindowDC, and instead of 0 for entire desktop, use GetForegroundWindow for the active window. I've understood that he wants screenshoot of non application window, so your proposal is not correct in that case. ---------------------------------------------------------------------- engkin · 2015-03-13 14:08 Quote from: zeljko on March 13, 2015, 08:09:32 amQuote from: engkin on March 12, 2015, 10:26:04 pmInstead of GetDC use GetWindowDC, and instead of 0 for entire desktop, use GetForegroundWindow for the active window. I've understood that he wants screenshoot of non application window, so your proposal is not correct in that case. I believe we have the same understanding, so why do you think that my proposal is not correct while it is based on your proposal with a small adjustment - limiting the DC to the active window only. I had used this same method a while ago using Windows API only. ---------------------------------------------------------------------- zeljko · 2015-03-13 19:56 Quote from: engkin on March 13, 2015, 03:08:42 pmQuote from: zeljko on March 13, 2015, 08:09:32 amQuote from: engkin on March 12, 2015, 10:26:04 pmInstead of GetDC use GetWindowDC, and instead of 0 for entire desktop, use GetForegroundWindow for the active window. I've understood that he wants screenshoot of non application window, so your proposal is not correct in that case. I believe we have the same understanding, so why do you think that my proposal is not correct while it is based on your proposal with a small adjustment - limiting the DC to the active window only. I had used this same method a while ago using Windows API only. His last question is: How can my I take a screenshot of only the word processing application?  So, it does not smell like his own application window screenshoot. Now answer to you: your approach won't work under linux. ---------------------------------------------------------------------- balazsszekely · 2015-03-13 20:27 @zeljko Gizmo is a windows user(that's a know fact - at least for me), so @engkin answer is valid. @Gizmo Call me paranoid but your questions are still(malware) suspicious! ---------------------------------------------------------------------- engkin · 2015-03-14 02:41 Quote from: zeljko on March 13, 2015, 08:56:37 pmHis last question is: How can my I take a screenshot of only the word processing application?  So, it does not smell like his own application window screenshoot. Yes, I understand that. My approach should work with windows that do not belong to his own application. If there is any exception, it might be DirectX or OpenGL surfaces. Quote from: zeljko on March 13, 2015, 08:56:37 pmNow answer to you: your approach won't work under linux. Thanks, that's true. I am a Windows person, so yes, it might not work on a different OS. ---------------------------------------------------------------------- Gizmo · 2015-03-14 19:51 Yes, the screenshots are to be taken of the active window and not my program itself Thanks for the suggestion Engkin as always. I will have a go when I get the chance next. @GetMem -I've used this forum for years and have many "virtual friends" here, Engkin being one of them amongst several others. If I were a Malware writer I doubt I'd have stayed posting on this forum for years asking for help with stuff and also contributing help where I can. I'm sorry for the post removal which has clearly wound you up no end, for which I apologised about, explained my reasons about and asked you to post again without my direct involvement being included if you recall so you could get the credit for your code. Yet every post I write or contribute to since, you jump in with "He's a Malware writer!". So, can we put it behind us now, or what? If not, discuss it with me via PM please and stop throwing "Malware" rants into every thread I write or join in with (and I am a cross platform developer - Windows, Linux and Mac). There is incidentally a reverse theory to your claims. Is it not possible I am creating something to help people record their every action? For the purposes of something much higher than that of some criminal?