Solved

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

Posted on 2008-10-14
3
1,051 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

912 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

18 Experts available now in Live!

Get 1:1 Help Now