• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1064
  • Last Modified:

C# API - Checking if a control exists, given it's Handle

Hi - I'm adding items to a listbox in an external app using the SendMessage API.

What is the best method finding out if my handle for list listbox is still valid?  Is there an API call that will take the handle for the listbox and give me a return code to indicate if the control for the handle still exists?
0
qfwp
Asked:
qfwp
2 Solutions
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You can use IsWindow() to see if a handle is still valid:
http://msdn.microsoft.com/en-us/library/ms633528(VS.85).aspx

0
 
Jaime OlivaresSoftware ArchitectCommented:
you can use native window, like:

NativeWindow nw = NativeWindow.FromHandle(handle)

if (nw != null)
{
       // it is valid
}
0
 
qfwpAuthor Commented:
thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now