Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8701779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:29:04+00:00 2026-06-13T02:29:04+00:00

I have an MFC view, and I have another project which implements and MFC

  • 0

I have an MFC view, and I have another project which implements and MFC dialog.
I want to host the dialog in my view.
My view is of class CFormView.

I did it that way in my view code:

m_myDialog->Create(myDialog::IDD, this);

Now, I see my dialog, but I can’t set focus on it and can’t use it.

What do I have to change in order to host my dialog in my view, and be able to use it and set focus to it, just as part of the view?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:29:05+00:00Added an answer on June 13, 2026 at 2:29 am

    I know this is a few weeks old, but you need to provide more code or a better context of what is taking place.

    I had a similar problem to yourself & found this hard to find info on when I first tried this. Following is an abstract of something I’ve used. I’m sure there’s probably a better way to do this, but I find it works the way I want;

            //MyApp.h
    
            class MyDialogClass;
    
            class MyApp : public CWinAppEx
            {
            public:
                MyApp();
                virtual BOOL InitInstance();
                //code etc
                MyDialogClass *p_myDlg;
            };
    
    
            //MyApp.cpp
            #include "MyApp.h"
            #include "CMyView.h"
            #include "mydialogclass.h"
    
    
            BOOL MyApp::InitInstance()
            {
            //code etc
    
                p_myDlg = CMyView::GetView()->p_myDlg;  
    
            //can be used here or elsewhere. I have mine linked with a button
                p_myDlg->ShowWindow(true);
    
            };
    
    
            //CMyView.h
    
            class MyDialogClass;
    
            class CMyView : public CFormView
            {
             protected: // create from serialization only
                CMyView();
                DECLARE_DYNCREATE(CMyView)
    
             public:
                enum{ IDD = IDD_CMyView_VIEW };
    
                    static CMyView* GetView();
                    MyDialogClass *p_myDlg;
                afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
            };
    
    
            //CMyView.cpp
            #include "MyApp.h"
            #include "CMyView.h"
            #include "mydialogclass.h"
    
            int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
            {
                if (CFormView::OnCreate(lpCreateStruct) == -1)
                    return -1;
    
                p_myDlg = new MyDialogClass(this);
    
                return 0;
            }
    
            void CMyView::DisplayDialogFoo()
            {
    
               //can be used here or elsewhere. I have mine linked with a button
               p_myDlg->ShowWindow(true);
    
            }
    
            //mydialogclass.h
            class MyDialogClass : public CDialog
            {
                DECLARE_DYNAMIC(MyDialogClass)
             public:
                MyDialogClass(CWnd* pParent /*= NULL*/);
                enum { IDD = IDD_MyDialog_DLG };
            };
    
            //mydialogclass.cpp
            #include "mydialogclass.h"
    
            MyDialogClass::MyDialogClass(CWnd* pParent /*=NULL*/)
                : CDialog(MyDialogClass::IDD, pParent)
            {
                Create(IDD, pParent);
            }
    

    There’s also an article here I just found:
    http://www.codeproject.com/Articles/1651/Tutorial-Modeless-Dialogs-with-MFC

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MFC dialog based project,Now I want to add database with that
I have an MFC application, which i don't want to be closed during the
I have a MFC dialog based application in which I use ::system() function to
I have a MFC/C++ project that uses the ActiveX Document (Automation) approach for opening
I have a dialog in mfc and my main view. The view starts a
I have an MFC dialog in which there are two radio buttons. I have
I have a MFC extension DLL which I want to use in a C#
I'm working on a win32/MFC project. I have a custom CListCtrl control that I
I have a MFC application, which has a worker thread, what I want to
I have created a MFC SDI application, and the view is derived from CFormView,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.