ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CaptureFromScreen from handle fails sometimes
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jrpcguru

USA
266 Posts

Posted - Jul 31 2020 :  14:52:47  Show Profile  Reply
I am using:

WindowHandle := FindWindow(nil,pChar(sTitleBar)); 
ImageEnView1.IO.CaptureFromScreen(iecsSpecifiedWindow,crDefault, WindowHandle);    


sTitleBar contains the title bar name for a window. This code works as expected for normal program windows. But fails if the desired window is the Win 10 Settings dialog, Windows Calculator, Windows Character Map. My code correctly identifies the title bar and obtains a Windows handle for those dialogs but CaptureFromScreen fails. Alt+PrtSc key combination does capture these windows. I haven't succeeded in researching what the difference is for these types of windows.

J.R.

xequte

38611 Posts

Posted - Aug 03 2020 :  22:36:42  Show Profile  Reply
Hi JR

Yes, for those types of windows, you need to use iecsSpecifiedWindow2.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jrpcguru

USA
266 Posts

Posted - Aug 10 2020 :  11:28:43  Show Profile  Reply
It would seem I was incorrect. The Character Map and the Snipping Tool don't even show in a list of windows so no handle is available. Once you actually snip something, then it gets a handle.

The Calculator, Windows Settings, and Snip & Sketch all have handles and do not screen capture with iecsSpecifiedWindow but they do work with iecsSpecifiedWindow2. I don't find iecsSpecifiedWindow2 mentioned in the help file, but it seems to work with all normal windows that have handles - so far.

Another detail. Your sample code in the help file includes:

WindowHandle := FindWindow(nil,pChar(sTitleBar));


In addition it needs:

SetForegroundWindow(WindowHandle);


Otherwise, if the desired window is on top of the ImageEn program, screen capture grabs its own program, not the desired window. I wonder if you intended ScreenCapture to automatically do this?



J.R.
Go to Top of Page

xequte

38611 Posts

Posted - Aug 10 2020 :  22:38:45  Show Profile  Reply
Hi JR

Yes, the overlapping is a documented side effect (feature???) of iecsSpecifiedWindow2, but I will add SetForegroundWindow to the example in the help file, thanks.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: