Featured Posts

MessageBox Function Visual Programming

Posted by admin | Posted in Theory Subjects, Visual Programming | Posted on 31-10-2009

0

The MessageBox function is designed to display short messages.

Syntax

int MessageBox(
HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType
);

Parameters

hWnd –> Handle to the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.

lpText –> Pointer to a null-terminated string that contains the message to be displayed. If the string consists of more than one line, you can separate the lines using a carriage return and/or linefeed character between each line.

lpCaption –> Pointer to a null-terminated string that contains the dialog box title. If this parameter is NULL, the default title is Error.

uType –> Specifies the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.

You can pick one constant from the first set to indicate what buttons you wish to appear in the dialog box:

  • #define MB_OK                       0x00000000L
  • #define MB_OKCANCEL                 0x00000001L
  • #define MB_ABORTRETRYIGNORE         0x00000002L
  • #define MB_YESNOCANCEL              0x00000003L
  • #define MB_YESNO                    0x00000004L
  • #define MB_RETRYCANCEL              0x00000005L

When you set the fourth argument to 0 in HELLOMSG, only the OK button appears.

Return Value

If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC has no effect.

If the function fails, the return value is zero. To get extended error information, call GetLastError

If the function succeeds, the return value is one of the following menu-item values.

IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDCONTINUE Continue button was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDTRYAGAIN Try Again button was selected.
IDYES Yes button was selected.

#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
MessageBox (NULL, TEXT (“Hello, vdiscussion.com”), TEXT (“Vdiscussion.com”), 0) ;

return 0 ;
}

Output

Helloprogramoutput

Helloprogramoutput

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)