Jump to content

Given a handle, differentiate between a window and a control


Recommended Posts

Hi

If I have a handle, is there any way to tell if it's referencing a Control or a Window? I know that a Control is just a window but I need to be able to tell the two apart and send different messages depending on which one they are. WindowInfo seems to be able to tell the difference but I can't figure out how it's doing it. Sorry if this is a stupid question.

Link to comment
Share on other sites

How are you getting the handle if you don't know where it's coming from? If you have the handle, generally you've used a function to get it, WinGetHandle gets window handles, ControlGetHandle gets control handles. Also, the AU3Info program will only show control handles on the controls tab, and window handles on the window tab.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi, I got the handle by enumerating child windows, that's why I don't know if it's a real window or a control.

I think GetDlgCtrlID does what I want it to do. It seems to anyway.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645478(v=vs.85).aspx

Although the Class name idea could be good too. Quick googling turned up:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633574(v=vs.85).aspx#types_classes

I was hoping to not have to case through a bunch of types though...

Link to comment
Share on other sites

Look here at CreateWindow function at hMenu parameter description:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632679%28v=vs.85%29.aspx

hMenu [in, optional]

Type: HMENU

A handle to a menu, or specifies a child-window identifier depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be NULL if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window.

Edited by Zedna
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...