Thread: Win32 way of Getting Dialog Control Type?

  1. #1
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195

    Win32 way of Getting Dialog Control Type?

    I made a dialog and I handle the way it works (non MFC) and I was wondering if there is a way to get the type of control based on the handle I receive:

    Code:
    HWND hwndEditBoxName = GetDlgItem (m_hWnd, IDC_EDIT_NAME);
    Is this possible without MFC and without manually parsing my resource script?


    EDIT: More specifically, I do the following:
    Code:
    	HWND hwnd = GetTopWindow(m_hWnd);
    	UINT id;
    
    	// Loop through all the controls on the Window and save it's functions
    	while (hwnd)
    	{
    		// Grab the next "Window" control
    		hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
    
    		// ** HOW DO I GET THE CONTROL TYPE?? **
    		// I want to do:
    		// CButton btn;
    		// if (GetDlgItemType() == PUSHBUTTON) btn = hwnd; ????
    	}
    Last edited by Mastadex; 03-13-2009 at 09:05 AM.
    Founder and avid member of the Internationsl Typo Associateion

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    291
    I haven't tryed it, but take a look at 'GetClassName' function. Just provide it a window handle and a buffer for the result:

    Code:
    char bff[512];
    GetClassName(hwnd,bff,sizeof(bff)-1);
    'hwnd' will be the window handle obtained on the GetNextWindow; as I understand it should return a text definition of the window's class name (BUTTON,EDIT,etc).

    If you want to take the specific styles declared for that window, just use 'GetWidowLong' using 'GWL_STYLE' as style values to get, or 'GWL_EXSTYLE' for the WS_EX_ styles.

    Hope that helps
    Niara

  3. #3
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    That worked. Thanks!
    Founder and avid member of the Internationsl Typo Associateion

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. What type of control should I use
    By MPSoutine in forum Windows Programming
    Replies: 2
    Last Post: 10-02-2003, 11:59 PM
  5. SDI Menu App - MSVC 6
    By Unregistered in forum Windows Programming
    Replies: 7
    Last Post: 10-16-2001, 09:59 PM