Solved

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

Posted on 2008-10-14
3
1,049 Views
Last Modified: 2010-04-21
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
Comment
Question by:qfwp
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 251 total points
ID: 22711401
You can use IsWindow() to see if a handle is still valid:
http://msdn.microsoft.com/en-us/library/ms633528(VS.85).aspx

0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 249 total points
ID: 22711448
you can use native window, like:

NativeWindow nw = NativeWindow.FromHandle(handle)

if (nw != null)
{
       // it is valid
}
0
 
LVL 1

Author Closing Comment

by:qfwp
ID: 31505876
thank you
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now