1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to get handle of child window

Discussion in 'MFC' started by ankurk, Sep 21, 2007.

  1. ankurk

    ankurk New Member

    Joined:
    Aug 8, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    hi guys i am creating many child windows using cdialog pointer at run time , depending upon the combo box selection in parent window; now i have to disable some controls of child window; using getdlgitem( control id, handle_of_child_window)->enable(FALSE);

    so prob is how do i obtain the handle_of_child_window;


    thanks in advance

    ankur :D
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    There are lots of ways to be doing it

    1. In your dialog you will have the control ddx'ed variables of your child window.
    2. You know the control ID of the window's and can get the handle to the window.
    3. You can go the hard way by enumerating the child window's as well.
     
  3. ankurk

    ankurk New Member

    Joined:
    Aug 8, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    suppose i have the ID of the child window , then how can i get it's handel please explain.
    i am just a beginner

    thanks
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    GetDlgItem should help you get the Handle to the controls from the resource ID.
     
  5. ankurk

    ankurk New Member

    Joined:
    Aug 8, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    na it's not working

    GetDlgItem(IDC_NAME, IDD_CHILD_DLG)->EnableWindow(FALSE);

    IDC_NAME is id of edit box , and the IDD_CHILD_DLG is id of chld dialog;

    i want to disable the edit box depending upon some value in main dialog


    thanks
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    If the API's are not working you are somewhere really wrong because they are tested over times to work correctly. Debug your code and see if you are getting the handle correctly and see if you have the parameters correctly.
     
  7. ankurk

    ankurk New Member

    Joined:
    Aug 8, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    ok got the things right , it's working now


    Thanks

    Keep up the good work .
     

Share This Page