A question regarding AFX_MANAGE_STATE - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23

Thread: A question regarding AFX_MANAGE_STATE

  1. #16
    Join Date
    Jul 2005
    Posts
    910

    Re: A question regarding AFX_MANAGE_STATE

    Quote Originally Posted by Igor Vartanov View Post
    The sample goes. Resource only DLL includes IDD_YOUR dialog template. Regular DLL includes IDD_MY dialog template, but implements both classes, CMyDialog and CYourDialog. Hope this close enough to what you're trying to implement.
    Thanks for your sample. Actually CMyDialog and CYourDialog are defined in two different dll. Basically what happens is that an exe launches CMyDialog defined in MyDll.dll and then when CMyDialog is NOT dismissed, CYourDialog is launched from defined in YourDll.dll. I would really appreciate it if you can post a sample by using MFC. Thank you very much!

  2. #17
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: A question regarding AFX_MANAGE_STATE

    Basically what happens is that an exe launches CMyDialog defined in MyDll.dll and then when CMyDialog is NOT dismissed, CYourDialog is launched from defined in YourDll.dll. I would really appreciate it if you can post a sample by using MFC.
    I wonder if you weren't able to look at the sample. In there, exe launches CMyDialog defined in regular dll, and CYourDialog is launched from the CMyDialog when the latter is NOT dismissed. And the sample is all about using MFC classes. Larry, you really should pay some more attention to communication you're participating in.
    Best regards,
    Igor

  3. #18
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: A question regarding AFX_MANAGE_STATE

    Quote Originally Posted by LarryChen View Post
    Basically what happens is that an exe launches CMyDialog defined in MyDll.dll and then when CMyDialog is NOT dismissed, CYourDialog is launched from defined in YourDll.dll.
    It doesn't matter where you launch your dialog from. Once you know how to launch it from exe, the same technique is applicable to launching from dll. Sample attached. Here you can see how CYourDialog gets launched from client.exe and my.dll using the same AFX_MANAGE_STATE.
    Attached Files Attached Files
    Last edited by Igor Vartanov; September 10th, 2012 at 01:51 AM.
    Best regards,
    Igor

  4. #19
    Join Date
    Jul 2005
    Posts
    910

    Re: A question regarding AFX_MANAGE_STATE

    Quote Originally Posted by Igor Vartanov View Post
    It doesn't matter where you launch your dialog from. Once you know how to launch it from exe, the same technique is applicable to launching from dll. Sample attached. Here you can see how CYourDialog gets launched from client.exe and my.dll using the same AFX_MANAGE_STATE.
    Thanks for your sample code. When I run the make file in my computer from command line, the system complained that "rc" and "cl" is not recognized as an external or internal command. And then I create a MFC dialog based project in VC2010 and put all of your files into the project. When I build this project, I got a linker error " LNK1104: cannot open file 'my.lib' ". I attached this project with this post. Would you please tell me what I am missing? Thanks.
    Attached Files Attached Files

  5. #20
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: A question regarding AFX_MANAGE_STATE

    Well, the answer to the make issue is Visual Studio Command Prompt.
    Best regards,
    Igor

  6. #21
    Join Date
    Jul 2005
    Posts
    910

    Re: A question regarding AFX_MANAGE_STATE

    Quote Originally Posted by Igor Vartanov View Post
    Well, the answer to the make issue is Visual Studio Command Prompt.
    Actually I tried to run vcvarsall.bat from the folder C:\Program Files\Microsoft Visual Studio 10.0\VC. Then if I run your make.bat in project folder, I still got the same errors. It looks like vcvarsall.bat didn't set up the environment for me to run make.bat. What am I missing here?

    BTW, I have fixed the dialog launching problem. It turns out that one of my DLLs to launch the dialog is a MFC extension dll. I couldn't use AFX_MANAGE_STATE like regular dll. So I have to manually set up the resource handle for this dll. It works. Thank you very much!

  7. #22
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: A question regarding AFX_MANAGE_STATE

    Actually I tried to run vcvarsall.bat from the folder C:\Program Files\Microsoft Visual Studio 10.0\VC. Then if I run your make.bat in project folder, I still got the same errors. It looks like vcvarsall.bat didn't set up the environment for me to run make.bat. What am I missing here?
    I'm currently able to build with the make.bat same successfully in standard Command Prompts of VS2010 and VS2012 Tools, as well as VS .NET2003. In fact I use this approach to make since Visual Studio 4, and never had any problem with this.
    Best regards,
    Igor

  8. #23
    Join Date
    Apr 2005
    Posts
    2

    Re: A question regarding AFX_MANAGE_STATE

    Hi LarryChen,

    Its interesting and , I feel that you want to just check out all possibilities in MFC and VC++ .

    Anyways,
    Your scenarios is Application A loads dll D1 contains dialog "Mydialog"
    then dll D1 loads D2 that contains "YourDialog".
    Now App is able to load MyDialog from D1 and you want to load YourDialog from D2 in the code of D1.

    I agree to the solutions given by Igor , Victor and all others.
    Apart from that just one suggestion is instead of doing DOModal() on YourDialog try to invoke it as modal less.
    or may be invoking both the dialogs modal less.

Page 2 of 2 FirstFirst 12

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center