CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    Candia, NH
    Posts
    374

    Get Dialog Box ID

    I am trying to get the ID of a dialog box inside the callback function. I figured the following should work:

    Upon entry to the dialog callback function:

    dlgidd = GetWindowLong(hwindow, GWL_ID); // Get the dialog ID number
    if(dlgidd == 0)
    {
    radioID = GetLastError();
    }

    But I get the error "Invalid window handle". It happens even if I put it after the WM_INITDIALOG message. I have no problem setting a value (the 'hwindow' value seems okay for the SetWindowLong() function).

    Any ideas? I must be doing something VERY stupid!!

    I am passing different dialog box templates and I thought this would be a good way to get the ID without placing it as a parameter.

    Thanks,

    Brian

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: Get Dialog Box ID

    Toplevel windows cannot have an ID. A resource ID for dialogs is only used to identify the dialog inside the resource section of an application.

    Quote Originally Posted by MSDN
    Although GetDlgCtrlID may return a value if hwndCtl is a handle to a top-level window, top-level windows cannot have identifiers and such a return value is never valid.
    • Check GetDlgCtrlID on MSDN.
    • And please use Code Tags next time you post code!
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    Dec 2002
    Location
    Candia, NH
    Posts
    374

    Re: Get Dialog Box ID

    RATS! Not what I wanted to hear. Thanks for the info, though!

    Brian

  4. #4
    Join Date
    Jul 2005
    Posts
    12

    Re: Get Dialog Box ID

    I think the judgement sentence "dlgidd == 0" is incorrect. The dialog box ID could be 0, like the id of the menu. If you wanna get the handle of the dialog box, you should use the function GetDlgItem();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured