Solved

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

Posted on 2008-10-14
3
1,057 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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