About Messagebox and DialogBox

szx0427 101 Reputation points
2020-08-29T06:15:58.477+00:00

I created a dialog box by DialogBox() function. But there was a problem when I tried to add a message box to my DialogProc. The message box could show but I couldn't close it. I noticed that it also couldn't be active (Its title bar was always white).
How to solve this problem? Plz tell me Thanks a lot.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,654 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,762 questions
0 comments No comments
{count} vote

Accepted answer
  1. szx0427 101 Reputation points
    2020-08-29T06:42:35.217+00:00

    OK I found the solution. I called DefWindowProc in "default" label before. That causes the problem. Dialog box is different from a window. If an application processes a message of a dialog box, it should return TRUE. If the application wants the system to process the message, it should return FALSE (not DefWindowProc). Like this:
    21274-image.png

    Thanks for helping


1 additional answer

Sort by: Most helpful
  1. Vishal Gawale 1 Reputation point
    2020-08-29T06:35:02.487+00:00

    The contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.
    To indicate the buttons displayed in the message box, specify one of the following values.

    TABLE 1
    Value Meaning
    MB_ABORTRETRYIGNORE
    0x00000002L
    The message box contains three push buttons: Abort, Retry, and Ignore.
    MB_CANCELTRYCONTINUE
    0x00000006L
    The message box contains three push buttons: Cancel, Try Again, Continue. Use this message box type instead of MB_ABORTRETRYIGNORE.
    MB_HELP
    0x00004000L
    Adds a Help button to the message box. When the user clicks the Help button or presses F1, the system sends a WM_HELP message to the owner.
    MB_OK
    0x00000000L
    The message box contains one push button: OK. This is the default.
    MB_OKCANCEL
    0x00000001L
    The message box contains two push buttons: OK and Cancel.
    MB_RETRYCANCEL
    0x00000005L
    The message box contains two push buttons: Retry and Cancel.
    MB_YESNO
    0x00000004L
    The message box contains two push buttons: Yes and No.
    MB_YESNOCANCEL
    0x00000003L
    The message box contains three push buttons: Yes, No, and Cancel.

    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.