Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot catch errors in CreateCaptureItemForWindow #126

Open
rjx-ray opened this issue Jan 8, 2024 · 3 comments
Open

Cannot catch errors in CreateCaptureItemForWindow #126

rjx-ray opened this issue Jan 8, 2024 · 3 comments

Comments

@rjx-ray
Copy link

rjx-ray commented Jan 8, 2024

Whillst developing our app we are sometimes mistakenly passing a handle for a window that cannot be captured through to CreateCaptureItemForWindow (eg a child window).
I am trying to catch and debug such errors, but the catch never works, instead I get an exception.
This is my current code and the exception:

image

We hope to eliminate all such errors but if it happens in future we would like to catch rather than crash.

How can I do that?

I'm using VS2022 under Windows 11 V23H2

@robmikh
Copy link
Member

robmikh commented Jan 8, 2024

There was a bug in earlier versions of Windows which would cause this behavior. However it should be patched in the latest Windows 10 and 11 releases.

Which version of Windows are you seeing this on? Could you provide the OS build number from the About section in the Settings app?

@robmikh
Copy link
Member

robmikh commented Jan 8, 2024

Oh sorry, I didn't see the last sentence. This shouldn't happen in Win11... I'll see if I can repro.

@rjx-ray
Copy link
Author

rjx-ray commented Jan 9, 2024

Thanks for looking at this. I need to build my own list of windows that can be captured, using IsAltTabWindow to filter the enumeration. But some are sneaking through, eg this Chrome popup
image
and this spy++ properties window.

image

They are not shown by GraphicsCapturePicker, is that filtering on a different basis?
I'm concerned that I'm just playing whack-a-mole right now.

I'm thinking about also filtering out popups, but do you think that might exclude any windows that should be be included?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants