Getting more window information with the handle

  • Thread starter Thread starter mottebelke
  • Start date Start date
M

mottebelke

Hi all,

I'm currently P/Invoking the GetForegroundWindow function in C# to get
the handle to the active window.
But is it possible to get more information about that window like the
title, the type or access to the controls?
I searched on MSDN and the groups, but couldn't find any functions that
will do this.


Thanks!
 
GetWindowText() will get the title, at least for an overlapped-style window.
The "type" could mean anything. You'll have to be more specific than that.

In MSDN, look up GetWindowText() and then use the Locate button in the tool
bar. That should set the index to the section of the help showing all of
the window-related API functions.

Paul T.
 
You should buy and read a book on general Win32 and/or Windows CE
development.
 
Doh, it's even in the same MSDN 'directory' as GetForegroundWindow. I
feel like an idiot that I missed that.

Thanks for the help guys!
 
Right, a little follow-up with another question.

I now have the window handle and the window text, but is it also
possible to access the controls in that window? Let me explain what I
want to do.

We're currently developing an application which is now being tested by
the client. But sometimes an unexpected error shows up. We want to log
these errors and therefore we built a second monitoring app which
monitors the main app and also notices when an error window shows up.
We want to get the error message from the window and store it somewhere
else, before programmatically stopping and restarting the main
application.

I hope this makes sense to you, and hopefully there is a solution for
this.


Thanks!
 
Back
Top