Windows MFC Application: How do I get user input without using CDialog?

Posted on 2014-07-11
Last Modified: 2014-07-16
I have a  WIndows MFC application. I need to display a MessageBox with OK, Cancel, and take a 10 digit numeric code from user and use it if user clicks OK. How can I do this without using CDialog?
Question by:vakils
    LVL 8

    Assisted Solution

    by:Subrat (C++ windows/Linux)
    Then you have to create your own InputBox() using C, WIN32 APIs. and use GetWindowText() or something siillar APIs to get the text from text box. As I know, in BuilderXE there is API for your purpose. But in Visual studio, MFC there is no such direct APIs available. But you can create a custom one.

    Author Comment

    If so, then it seems CDialog is the only easy way to go as the application uses MFC.
    LVL 30

    Accepted Solution

    Hi vakils,

    why do you want to implement a input dialog without using CDialog? It's the easiest and recommended way to implement any kind of dialog with MFC.

    Of course you can implement a modal dialog without CDialog using DialogBox WIN32 API function, in this case you have to write your own code to create the dialog and you have to implement a message handler function (DLGPROC). This is some effort you can simply avoid using CDialog.


    Author Comment

    Agreed. I was hoping MS would be having an extended AfxMessageBox  which would take input. CDialog is way to go.

    Author Closing Comment

    Implemented CDialog derived class. Thanks for clarifying and confirming.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Many companies are making the switch from Microsoft to Google Apps ( Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now