-
November 10th, 2003, 01:59 AM
#1
How to Know the handle is for Window or control
Hi,
I am having a Handle. The handle can be a handle to a control or a window. I want to see whether the handle is a handle to Control or a handle to window How can I do this. Is there any API for this?
Regards
Siva
-
November 10th, 2003, 04:32 AM
#2
A control is a window as well, but with a specific behavior (like an Edit-Control). You can use GetClassName to retrieve the class-name (for example "EDIT" for an edit-control) to see if your window-handle is some kind of control.
-
November 10th, 2003, 05:10 AM
#3
Generally speaking controls have no captions and windows do. You could provide this as your condition to find out.
I.e.
Code:
if ((::GetWindowLong(hWnd, GWL_STYLE) & WS_CAPTION) != 0)
{
// I'm a window
}
else
{
// I'm a control
}
Darwen.
-
November 10th, 2003, 05:24 AM
#4
Originally posted by darwen
Generally speaking controls have no captions and windows do. You could provide this as your condition to find out.
I'd be careful about that. There are many windows (just think of MFC CView windows or other embedded windows, like panes) which have no caption, and still aren't controls.
-
November 10th, 2003, 05:43 AM
#5
You are correct gstercken, There are many windows which does not have caption. More over a window does not have a constant class name. For example a dialog have a class name "#3770", A MDI and SDI application have a dynamic classname starting with "Afx:"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|