From a494c8a15740f28ba771b33ba0d58da2dcd39092 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 12 Sep 2012 21:53:30 +0000 Subject: [PATCH] LCL: fpgui: implements the Windows API function MessageBox(), issue #22865 git-svn-id: trunk@38627 - --- lcl/include/messagedialogs.inc | 2 +- lcl/interfaces/fpgui/fpguiwinapi.inc | 59 +++++++++++++++++++++++++++ lcl/interfaces/fpgui/fpguiwinapih.inc | 3 +- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/lcl/include/messagedialogs.inc b/lcl/include/messagedialogs.inc index 8ea2b48860..682a47ba16 100644 --- a/lcl/include/messagedialogs.inc +++ b/lcl/include/messagedialogs.inc @@ -86,7 +86,7 @@ const idButtonClose); DialogResults : Array[idButtonOK..idButtonNoToAll] of TModalResult = ( - mrOk, mrCancel, + mrOk, mrCancel, mrNone{Help - when a mbHelp button is pressed the help system is started, the dialog does not close }, mrYes, mrNo, mrClose, mrAbort, mrRetry, diff --git a/lcl/interfaces/fpgui/fpguiwinapi.inc b/lcl/interfaces/fpgui/fpguiwinapi.inc index 4b6333422d..4cb76d3524 100644 --- a/lcl/interfaces/fpgui/fpguiwinapi.inc +++ b/lcl/interfaces/fpgui/fpguiwinapi.inc @@ -469,6 +469,65 @@ begin Result:=true; end; +{ Most of the functionality is implemented. As described in MSDN: + http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505%28v=vs.85%29.aspx } +function TFpGuiWidgetSet.MessageBox(hWnd: HWND; lpText, lpCaption: PChar; + uType: Cardinal): integer; +var + Str: AnsiString; + TitleStr: AnsiString; + Buttons : TfpgMsgDlgButtons; + BtnType: Cardinal; + DlgType: Cardinal; +begin + BtnType := (uType and $0000000F); { mask the button type } + + if (BtnType = MB_OKCANCEL) then + Buttons := mbOKCancel + else + if (BtnType = MB_ABORTRETRYIGNORE) then + Buttons := mbAbortRetryIgnore + else + if (BtnType = MB_YESNOCANCEL) then + Buttons := mbYesNoCancel + else + if (BtnType = MB_YESNO) then + Buttons := mbYesNo + else + if (BtnType = MB_RETRYCANCEL) then + Buttons := [mbRetry, mbCancel] + else + if (BtnType = MB_CANCELTRYCONTINUE) then + Buttons := mbAbortRetryIgnore + else + Buttons := [mbOK]; + + { shoud we had a Help button too? - again as per MSDN } + if (uType and MB_HELP) = MB_HELP then + Include(Buttons, mbHelp); + + Str := lpText; + TitleStr := lpCaption; + if lpCaption = nil then + TitleStr := 'Error'; // as per MSDN + + DlgType := (uType and $000000F0); { mask the dialog type } + + if (DlgType and MB_ICONINFORMATION) = MB_ICONINFORMATION then + TfpgMessageDialog.Information(TitleStr, Str, Buttons) + else + if (DlgType and MB_ICONWARNING) = MB_ICONWARNING then + TfpgMessageDialog.Warning(TitleStr, Str, Buttons) + else + if (DlgType and MB_ICONQUESTION) = MB_ICONQUESTION then + TfpgMessageDialog.Question(TitleStr, Str, Buttons) + else + if (DlgType and MB_ICONERROR) = MB_ICONERROR then + TfpgMessageDialog.Critical(TitleStr, Str, Buttons) + else + TfpgMessageDialog.Information(TitleStr, Str, Buttons); +end; + function TFpGuiWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; var ADC: TFpGuiDeviceContext absolute DC; diff --git a/lcl/interfaces/fpgui/fpguiwinapih.inc b/lcl/interfaces/fpgui/fpguiwinapih.inc index cb0ceef20b..570bdfee8f 100644 --- a/lcl/interfaces/fpgui/fpguiwinapih.inc +++ b/lcl/interfaces/fpgui/fpguiwinapih.inc @@ -138,8 +138,9 @@ function IsWindowVisible(Handle: HWND): boolean; override; procedure LeaveCriticalSection(var CritSection: TCriticalSection); override; function LineTo(DC: HDC; X, Y: Integer): Boolean; override; - +} function MessageBox(hWnd: HWND; lpText, lpCaption: PChar; uType: Cardinal): integer; override; +{ function MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean; override; function PeekMessage(var lpMsg : TMsg; Handle : HWND; wMsgFilterMin, wMsgFilterMax,wRemoveMsg : UINT): Boolean; override;