How to prompt user to enter input using MessageBox in MFC

abc abc 351 Reputation points
2020-11-03T04:32:32.197+00:00

Hi,

Using MessageBox, how to prompt user to enter input (like number)in MFC?

Developer technologies C++
0 comments No comments
{count} vote

Accepted answer
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2020-11-03T06:19:22.063+00:00

    Hi,

    According to you issue, I wonder if you want to show a Message box to prompt user to enter input? If so, you could create a modal dialog box to prompt user to enter input.

    Here is the code:

    CMyNewDlg  *pDlg = new CMyNewDlg;  
    	pDlg->Create(IDD_DIALOG1, this);  
    	pDlg->ShowWindow(SW_SHOW);  
    

    And you could also try to use AfxMessageBox:

    AfxMessageBox(_T("Please enter input."));  
    

    If I misunderstood your meaning, please explain your issue in more detail.

    Best Regards,

    Jeanine


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. David Lowndes 4,726 Reputation points
    2020-11-03T08:40:02.087+00:00

    MessageBox does not provide any facility to have arbitrary user input - you can only use its allowed set of buttons.

    As Jeanine says, you would need to have a modal dialog box of your own design to enter your data.

    1 person found this answer helpful.
    0 comments No comments

  2. Flaviu_ 1,031 Reputation points
    2020-11-03T09:28:11.167+00:00

    Do you need something like this: https://www.codeproject.com/Articles/1643/CInputBox ?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.