CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Posts
    128

    Question how to get Dialog handle in a dll ?

    I am working in a project where in a dialog is called from a cs project.
    This dialog is in dll (vc project).the dialog's handle is null, due to this i am unable to launch the dialog.

    Code:
          AFX_MANAGE_STATE(AfxGetStaticModuleState())
          CFDialog dlg;
          int responce = dlg.DoModal();
    the dlg handle is NULL(i debugged the Application and found) and the application crashes;

    where am i going wrong ?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: how to get Dialog handle in a dll ?

    dialog window is created within the DoModal call and destroyed just before DoModal returns. So dialog handle exists only between these two "events" and you cannot access it using the code you showed.
    Why do you need the dialog handle?
    Where exactly and how does your application crash?
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2009
    Posts
    128

    Re: how to get Dialog handle in a dll ?

    thanks a lot for the reply.

    [code]
    AFX_MANAGE_STATE(AfxGetStaticModuleState())
    CFDialog dlg;
    int responce = dlg.DoModal(); //it fails here and i am unable to launch dialog.
    [\code]

    i have attached the screen shot.
    Attached Images Attached Images

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: how to get Dialog handle in a dll ?

    The dialog seems failing to create. Which means either dialog resource is wrong/unreachable or the dialog contains common controls while common controls library appears not initialized to he moment of dialog creation. These two are the most frequent reasons of DoModal failure.

    I would suggest to call the dll in debug mode from trivial C++ client and go through dialog creation step by step. Hope you have MFC sources installed along with your Visual Studio.
    Best regards,
    Igor

  5. #5
    Join Date
    Feb 2002
    Posts
    4,640

    Re: how to get Dialog handle in a dll ?

    Quote Originally Posted by dskp View Post
    thanks a lot for the reply.

    [code]
    AFX_MANAGE_STATE(AfxGetStaticModuleState())
    CFDialog dlg;
    int responce = dlg.DoModal(); //it fails here and i am unable to launch dialog.
    [\code]

    i have attached the screen shot.
    I would expect this. The dialog window is not created until you call the "DoModal" function. IIRC, nothing much happens in the CDialog constructor. Your picture shows the state of the dialog instance after the constructor has been called.

    Viggy

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