Thread: Get a Window HWND by only knowing the ID.

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310

    Get a Window HWND by only knowing the ID.

    I created a few comboboxes in runtime...

    I know the ID of the each control, but I don't know how to get its HWND... I try GetDlgItem but didn't work...anyideas?

    Right know, my main idea is use std::map or std::vector, but I trying to not use the c++ runtime...
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    For a valid child window identifier and a valid parent window handle, GetDlgItem will return the window handle for the child window with the given id. If that function is failing to return a valid handle then either the parent handle you are using with it is invalid or there's a problem with the id.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    But GetDlgItem is for dialog controls...my comboboxes are created by CreateWindowEx...does it matter?
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Not in the slightest.
    Quote Originally Posted by msdn, GetDlgItem; remarks
    You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes.
    See GetDlgItem.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    Ah! ok!

    Thanks!
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  4. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM