ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • MessageDlg
    C++ Builder/함수 2018. 12. 6. 22:32

    #MessageDlg

    //메세지 폼 띄우는 함수(버튼 여러개 가능)

    void __fastcall THRMainF::cxButton1Click(TObject *Sender)

    {

    UnicodeString errorText = "This is a sample message for an error";

    MessageDlg(errorText,mtError,TMsgDlgButtons()<<mbOK<<mbNo<<mbCancel<<mbYes,0);

    }


    extern DELPHI_PACKAGE int __fastcall MessageDlg(const System::UnicodeString Msg, System::Uitypes::TMsgDlgType DlgType, System::Uitypes::TMsgDlgButtons Buttons, int HelpCtx)/* overload */;


    #MessageBoxA

    //메세지 폼 띄우는 함수(caption 지정가능)

    void __fastcall THRMainF::cxButton1Click(TObject *Sender)

    {

    MessageBoxA(Handle, "Termmiasnd", "MessageBox Test", 3);    // , 메세지 내용, caption이름, 버튼 값


    }






    Description

    The messagedlg function is used to display messages to the user. These messages may be informational, or warnings or whatever. There is complete freedom over the choice of buttons that the user may press to acknowledge the dialog. 
     
    For example, the user may be shown an error message, and be allowed to abort, retry or cancel the erroneous process. 
     
    The DialogType may have one of the following enumerated values: 
     

    mtWarning Displays a exclamation symbol
    mtError Displays a red 'X'
    mtInformation Displays an 'i' in a bubble
    mtConfirmation Displays an question mark
    mtCustom Displays just the message


     
    The Buttons value may be one or more of the following enumerated values : 
     

    mbYes Displays a 'Yes' button
    mbNo Displays a 'No' button
    mbOK Displays an 'OK' button
    mbCancel Displays a 'Cancel' button
    mbAbort Displays an 'Abort' button
    mbRetry Displays a 'Retry' button
    mbIgnore Displays an 'Ignore' button
    mbAll Displays an 'All' button
    mbNoToAll Displays a 'No to all' button
    mbYesToAll Displys a 'Yes to all' button
    mbHelp Displays a 'Help' button


     
    You specify these values comma separated in square brackets, as in the second code example. 
     
    Delphi provides a number of predefined button combinations:
     

    mbYesNoCancel = [mbYes,mbNO,mbCancel]
    mbYesAllNoAllCancel =[mbYes,mbYesToAll, mbNo,mbNoToAll,mbCancel]
    mbOKCancel =[mbOK,mbCancel]
    mbAbortRetryCancel =[mbAbort,mbRetry,mbCancel]
    mbAbortIgnore =[mbAbort,mbIgnore]


     
    Now Delphi seem to have made a design error when setting the return value from the dialog box. Instead of specifying the enumeration value of the button pressed, it uses a completely different set of enumeration names: 
     

    mrYes = 6
    mrNo = 7
    mrOK = 1
    mrCancel = 2
    mrAbort = 3
    mrRetry = 4
    mrIgnore = 5
    mrAll = 8
    mrNoToAll = 9
    mrYesToAll = 10


     
    The values given are the numerical values of these enumerations, given in the numerical order that the mbequivalents are defined. This is very odd. 
     
    Additionally, these values are defined in the Controls unit, not the Dialogs unit. 
     
    Note that the Help button has no equivalent return value. This is because it does not terminate the dialog. 
     
    The HelpContext value is used in conjunction with the Helpbutton. It's use is beyond the scope of Delphi Basics.

    728x90

    'C++ Builder > 함수' 카테고리의 다른 글

    SendBuffer //UDP  (0) 2018.12.07
    ZeroMemory & CopyMemory  (0) 2018.12.07
    ShowMessageCenter  (0) 2018.12.06
    foam  (0) 2018.12.06
    ToIntDef  (0) 2018.12.06

    댓글

Designed by Tistory.