Reworks the assyncronous modal dialogs interface and adds it to the TCustomForm too. Reimplements the Android support for modal dialogs to support 1 Java implementation for both MessageBox and PromptUser. Implements LCLIntf.PromptUser for Android

git-svn-id: trunk@34127 -
This commit is contained in:
sekelsenmat 2011-12-12 07:30:55 +00:00
parent 33c4eb1f2f
commit 9c38c40343
12 changed files with 227 additions and 201 deletions

View File

@ -98,32 +98,22 @@ public class LCLActivity extends Activity
// LCLType definitions
private final int MB_OK = 0x00000000;
private final int MB_OKCANCEL = 0x00000001;
private final int MB_ABORTRETRYIGNORE = 0x00000002;
private final int MB_YESNOCANCEL = 0x00000003;
private final int MB_YESNO = 0x00000004;
private final int MB_RETRYCANCEL = 0x00000005;
private final int MB_ICONHAND = 0x00000010;
private final int MB_ICONQUESTION = 0x00000020;
private final int MB_ICONEXCLAMATION = 0x00000030;
private final int MB_ICONASTERICK = 0x00000040;
//MB_ICONWARNING = MB_ICONEXCLAMATION;
//MB_ICONERROR = MB_ICONHAND;
//MB_ICONSTOP = MB_ICONHAND;
//MB_ICONINFORMATION = MB_ICONASTERICK;
private final int IDOK = 1; //ID_OK = IDOK;
private final int IDCANCEL = 2; //ID_CANCEL = IDCANCEL;
private final int IDABORT = 3; //ID_ABORT = IDABORT;
private final int IDRETRY = 4; //ID_RETRY = IDRETRY;
private final int IDIGNORE = 5; //ID_IGNORE = IDIGNORE;
private final int IDYES = 6; //ID_YES = IDYES;
private final int IDNO = 7; //ID_NO = IDNO;
private final int IDCLOSE = 8; //ID_CLOSE = IDCLOSE;
private final int IDHELP = 9; //ID_HELP = IDHELP;
private int LCLMessageBoxType; // Stores the type of the last message box
private final int idButtonBase = 0x00000000;
private final int idButtonOk = 0x00000001;
private final int idButtonCancel = 0x00000002;
private final int idButtonHelp = 0x00000003;
private final int idButtonYes = 0x00000004;
private final int idButtonNo = 0x00000005;
private final int idButtonClose = 0x00000006;
private final int idButtonAbort = 0x00000007;
private final int idButtonRetry = 0x00000008;
private final int idButtonIgnore = 0x00000009;
private final int idButtonAll = 0x0000000A;
private final int idButtonYesToAll = 0x0000000B;
private final int idButtonNoToAll = 0x0000000C;
private final int idButtonOpen = 0x0000000D;
private final int idButtonSave = 0x0000000E;
private final int idButtonShield = 0x0000000F;
// input: String lcltext, String lcltitle, int lclconfig (buttons)
// output: nothing, but calles LCLOnMessageBoxFinished
@ -134,32 +124,16 @@ public class LCLActivity extends Activity
@Override
public void onClick(DialogInterface dialog, int which)
{
switch (LCLMessageBoxType)
switch (which)
{
case MB_OK:
LCLOnMessageBoxFinished(IDOK);
case DialogInterface.BUTTON_POSITIVE:
LCLOnMessageBoxFinished(lclbutton1);
break;
case MB_OKCANCEL:
if (which == DialogInterface.BUTTON_POSITIVE) LCLOnMessageBoxFinished(IDOK);
else LCLOnMessageBoxFinished(IDCANCEL);
case DialogInterface.BUTTON_NEUTRAL:
LCLOnMessageBoxFinished(lclbutton2);
break;
case MB_ABORTRETRYIGNORE:
if (which == DialogInterface.BUTTON_POSITIVE) LCLOnMessageBoxFinished(IDRETRY);
else if (which == DialogInterface.BUTTON_NEGATIVE) LCLOnMessageBoxFinished(IDABORT);
else LCLOnMessageBoxFinished(IDIGNORE);
break;
case MB_YESNOCANCEL:
if (which == DialogInterface.BUTTON_POSITIVE) LCLOnMessageBoxFinished(IDYES);
else if (which == DialogInterface.BUTTON_NEGATIVE) LCLOnMessageBoxFinished(IDNO);
else LCLOnMessageBoxFinished(IDCANCEL);
break;
case MB_YESNO:
if (which == DialogInterface.BUTTON_POSITIVE) LCLOnMessageBoxFinished(IDYES);
else LCLOnMessageBoxFinished(IDNO);
break;
case MB_RETRYCANCEL:
if (which == DialogInterface.BUTTON_POSITIVE) LCLOnMessageBoxFinished(IDRETRY);
else LCLOnMessageBoxFinished(IDCANCEL);
case DialogInterface.BUTTON_NEGATIVE:
LCLOnMessageBoxFinished(lclbutton3);
break;
};
}
@ -170,42 +144,17 @@ public class LCLActivity extends Activity
@Override
public void onCancel(DialogInterface dialog)
{
LCLOnMessageBoxFinished(IDCANCEL);
// The Cancel button number matches for LCLIntf.MessageBox and LCLIntf.PromptDialog
LCLOnMessageBoxFinished(idButtonCancel);
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(lcltext);
builder.setTitle(lcltitle);
LCLMessageBoxType = lclconfig;
switch (lclconfig)
{
case MB_OK:
builder.setPositiveButton("OK", dialogClickListener);
break;
case MB_OKCANCEL:
builder.setPositiveButton("OK", dialogClickListener);
builder.setNegativeButton("Cancel", dialogClickListener);
break;
case MB_ABORTRETRYIGNORE:
builder.setNegativeButton("Abort", dialogClickListener);
builder.setPositiveButton("Retry", dialogClickListener);
builder.setNeutralButton("Ignore", dialogClickListener);
break;
case MB_YESNOCANCEL:
builder.setPositiveButton("Yes", dialogClickListener);
builder.setNegativeButton("No", dialogClickListener);
builder.setNeutralButton("Cancel", dialogClickListener);
break;
case MB_YESNO:
builder.setPositiveButton("Yes", dialogClickListener);
builder.setNegativeButton("No", dialogClickListener);
break;
case MB_RETRYCANCEL:
builder.setPositiveButton("Retry", dialogClickListener);
builder.setNegativeButton("Cancel", dialogClickListener);
break;
};
if (lclbutton1 >= 0) builder.setPositiveButton(lclbutton1str, dialogClickListener);
if (lclbutton2 >= 0) builder.setNeutralButton(lclbutton2str, dialogClickListener);
if (lclbutton3 >= 0) builder.setNegativeButton(lclbutton3str, dialogClickListener);
builder.show().setOnCancelListener(dialogCancelListener);
}
@ -214,12 +163,14 @@ public class LCLActivity extends Activity
// -------------------------------------------
public String lcltext;
public String lcltitle;
public String lclpositivebutton;
public String lclnegativebutton;
public String lclneutralbutton;
public String lclbutton1str;
public String lclbutton2str;
public String lclbutton3str;
public int lclwidth;
public int lclheight;
public int lclconfig;
public int lclbutton1;
public int lclbutton2;
public int lclbutton3;
public Bitmap lclbitmap;
static

View File

@ -39,7 +39,7 @@ type
{ public declarations }
SubControl: TSubControl;
ClickCounter: Integer;
procedure HandleMessageBoxExecute(Sender: TObject; AResult: Integer);
procedure HandleMessageDialogFinished(Sender: TObject; AResult: Integer);
end;
{ TSubControl }
@ -137,9 +137,10 @@ end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.OnMessageBoxExecute := @HandleMessageBoxExecute;
Application.OnMessageDialogFinished := @HandleMessageDialogFinished;
DebugLn('Button2Click A');
LCLIntf.MessageBox(0, 'Text', 'Title', MB_ABORTRETRYIGNORE);
// LCLIntf.MessageBox(0, 'Text', 'Title', MB_ABORTRETRYIGNORE);
Application.MessageBox('Text', 'Title', MB_ABORTRETRYIGNORE);
DebugLn('Button2Click B');
end;
@ -177,9 +178,9 @@ begin
Canvas.Rectangle(200, 200, 300, 300);}
end;
procedure TForm1.HandleMessageBoxExecute(Sender: TObject; AResult: Integer);
procedure TForm1.HandleMessageDialogFinished(Sender: TObject; AResult: Integer);
begin
DebugLn(Format('[TForm1.HandleMessageBoxExecute] AResult=%d', [AResult]));
DebugLn(Format('[TForm1.HandleMessageDialogFinished] AResult=%d', [AResult]));
end;
end.

View File

@ -401,6 +401,7 @@ type
TDropFilesEvent = procedure (Sender: TObject; const FileNames: Array of String) of object;
THelpEvent = function(Command: Word; Data: PtrInt; var CallHelp: Boolean): Boolean of object;
TShortCutEvent = procedure (var Msg: TLMKey; var Handled: Boolean) of object;
TModalDialogFinished = procedure (Sender: TObject; AResult: Integer) of object;
TCustomForm = class(TScrollingWinControl)
@ -421,6 +422,7 @@ type
FFormHandlers: array[TFormHandlerType] of TMethodList;
FHelpFile: string;
FIcon: TIcon;
FOnShowModalFinished: TModalDialogFinished;
FPopupMode: TPopupMode;
FPopupParent: TCustomForm;
FSmallIconHandle: HICON;
@ -679,6 +681,7 @@ type
property OnResize stored IsForm;
property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut;
property OnShow: TNotifyEvent read FOnShow write FOnShow;
property OnShowModalFinished: TModalDialogFinished read FOnShowModalFinished write FOnShowModalFinished;
property OnWindowStateChange: TNotifyEvent
read FOnWindowStateChange write FOnWindowStateChange;
property ParentFont default False;
@ -1111,7 +1114,6 @@ type
TIdleEvent = procedure (Sender: TObject; var Done: Boolean) of object;
TOnUserInputEvent = procedure(Sender: TObject; Msg: Cardinal) of object;
TDataEvent = procedure (Data: PtrInt) of object;
TOnMessageBoxExecute = procedure (Sender: TObject; AResult: Integer) of object;
// application hint stuff
TCMHintShow = record
@ -1245,7 +1247,7 @@ type
FMainFormOnTaskBar: Boolean;
FModalLevel: Integer;
FOnGetMainFormHandle: TGetHandleEvent;
FOnMessageBoxExecute: TOnMessageBoxExecute;
FOnMessageDialogFinished: TModalDialogFinished;
FOnModalBegin: TNotifyEvent;
FOnModalEnd: TNotifyEvent;
FShowButtonGlyphs: TApplicationShowGlyphs;
@ -1484,7 +1486,7 @@ type
property OnEndSession: TNotifyEvent read FOnEndSession write FOnEndSession;
property OnQueryEndSession: TQueryEndSessionEvent read FOnQueryEndSession write FOnQueryEndSession;
property OnMinimize: TNotifyEvent read FOnMinimize write FOnMinimize;
property OnMessageBoxExecute: TOnMessageBoxExecute read FOnMessageBoxExecute write FOnMessageBoxExecute;
property OnMessageDialogFinished: TModalDialogFinished read FOnMessageDialogFinished write FOnMessageDialogFinished;
property OnModalBegin: TNotifyEvent read FOnModalBegin write FOnModalBegin;
property OnModalEnd: TNotifyEvent read FOnModalEnd write FOnModalEnd;
property OnRestore: TNotifyEvent read FOnRestore write FOnRestore;

View File

@ -44,7 +44,7 @@ uses
lazcanvas, lazregions,
InterfaceBase, Translations,
Controls, Forms, lclproc, IntfGraphics, GraphType,
LCLType, LMessages, Graphics;
LCLType, LMessages, Graphics, LCLStrConsts;
type
{$ifdef CD_Windows}
@ -229,14 +229,18 @@ var
javaActivityObject: jobject = nil;
// Fields of our Activity
// Strings
javaField_lcltext: JfieldID=nil;
javaField_lcltitle: JfieldID=nil;
javaField_lclpositivebutton: JfieldID=nil;
javaField_lclnegativebutton: JfieldID=nil;
javaField_lclneutralbutton: JfieldID=nil;
javaField_lclbutton1str: JfieldID=nil;
javaField_lclbutton2str: JfieldID=nil;
javaField_lclbutton3str: JfieldID=nil;
// Integers
javaField_lclwidth: JfieldID=nil;
javaField_lclheight: JfieldID=nil;
javaField_lclconfig: JfieldID=nil;
javaField_lclbutton1: JfieldID=nil;
javaField_lclbutton2: JfieldID=nil;
javaField_lclbutton3: JfieldID=nil;
// Methods of our Activity
javaMethod_LCLDoGetTextBounds: jmethodid = nil;

View File

@ -103,20 +103,22 @@ function TQtWidgetSet.AddProcessEventHandler(AHandle: THandle;
begin
// todo
Result := nil;
end;
end;*)
function TQtWidgetSet.AskUser(const DialogCaption, DialogMessage: string;
// This code is for platforms which use the non-native dialogs
{$ifndef CD_Android}
function TCDWidgetSet.AskUser(const DialogCaption, DialogMessage: string;
DialogType: LongInt; Buttons: TDialogButtons; HelpCtx: Longint): LongInt;
const
{const
ButtonResults : array[mrNone..mrYesToAll] of Longint = (
-1, idButtonOK, idButtonCancel, idButtonAbort, idButtonRetry,
idButtonIgnore, idButtonYes,idButtonNo, idButtonAll, idButtonNoToAll,
idButtonYesToAll);
var
BtnIdx, BtnID: LongInt;
QtMessageBox: TQtMessageBox;
QtMessageBox: TQtMessageBox;}
begin
ReleaseCapture;
{ ReleaseCapture;
QtMessageBox := TQtMessageBox.Create(nil);
QtMessageBox.AttachEvents;
try
@ -162,9 +164,9 @@ begin
Result := QtMessageBox.exec;
finally
QtMessageBox.Free;
end;
end;*)
end;}
end;
{$endif}
{------------------------------------------------------------------------------
Function: CreateEmptyRegion
@ -332,7 +334,7 @@ begin
Result := (WindowHandle <> 0) and (TQtWidget(WindowHandle) is TQtDesignWidget);
if Result then
Result := TQtDesignWidget(WindowHandle).DesignContext = DC;
end;
end;*)
{------------------------------------------------------------------------------
Function: PromptUser
@ -341,18 +343,19 @@ end;
Note: Qt appears to map Esc key to Cancel button, so no need for EscapeResult.
------------------------------------------------------------------------------}
function TQtWidgetSet.PromptUser(const DialogCaption : string;
{$ifndef CD_Android}
function TCDWidgetSet.PromptUser(const DialogCaption : string;
const DialogMessage : string;
DialogType : LongInt;
Buttons : PLongInt;
ButtonCount : LongInt;
DefaultIndex : LongInt;
EscapeResult : LongInt) : LongInt;
var
{var
BtnIdx, BtnID: LongInt;
QtMessageBox: TQtMessageBox;
QtMessageBox: TQtMessageBox;}
begin
ReleaseCapture;
(* ReleaseCapture;
QtMessageBox := TQtMessageBox.Create(nil);
QtMessageBox.AttachEvents;
try
@ -392,16 +395,17 @@ begin
Result := QtMessageBox.exec;
finally
QtMessageBox.Free;
end;
end; {TQtWidgetSet.PromptUser}
end;*)
end;
{$endif}
function TQtWidgetSet.RadialPie(DC: HDC; x1, y1, x2, y2, Angle1, Angle2: Integer
function TCDWidgetSet.RadialPie(DC: HDC; x1, y1, x2, y2, Angle1, Angle2: Integer
): Boolean;
begin
Result := IsValidDC(DC);
if Result then
QPainter_drawPie(TQtDeviceContext(DC).Widget, x1, y1, x2, y2, Angle1, Angle2);
end;*)
{ if Result then
QPainter_drawPie(TQtDeviceContext(DC).Widget, x1, y1, x2, y2, Angle1, Angle2);}
end;
{------------------------------------------------------------------------------
Function: RawImage_CreateBitmaps

View File

@ -58,7 +58,7 @@ function PromptUser(const DialogCaption : string;
DefaultIndex : LongInt;
EscapeResult : LongInt) : LongInt; override;
//function RadialPie(DC: HDC; x1, y1, x2, y2, Angle1, Angle2: Integer): Boolean; override;
function RadialPie(DC: HDC; x1, y1, x2, y2, Angle1, Angle2: Integer): Boolean; override;
function RawImage_CreateBitmaps(const ARawImage: TRawImage; out ABitmap, AMask: HBitmap; ASkipMask: Boolean = False): Boolean; override;
function RawImage_DescriptionFromBitmap(ABitmap: HBITMAP; out ADesc: TRawImageDescription): Boolean; override;

View File

@ -124,8 +124,8 @@ function Java_com_pascal_lclproject_LCLActivity_LCLOnMessageBoxFinished(
begin
//__android_log_write(ANDROID_LOG_INFO, 'lclapp', 'LCLOnCreate called by LCLActivity.onCreate');
Result := 0;
if Assigned(Application.OnMessageBoxExecute) then
Application.OnMessageBoxExecute(Application, AResult);
if Assigned(Application.OnMessageDialogFinished) then
Application.OnMessageDialogFinished(Application, AResult);
end;
const NativeMethods: array[0..3] of JNINativeMethod=
@ -181,12 +181,15 @@ begin
// Read all field IDs
JavaField_lcltext := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lcltext', 'Ljava/lang/String;');
JavaField_lcltitle := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lcltitle', 'Ljava/lang/String;');
JavaField_lclpositivebutton := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclpositivebutton', 'Ljava/lang/String;');
JavaField_lclnegativebutton := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclnegativebutton', 'Ljava/lang/String;');
JavaField_lclneutralbutton := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclneutralbutton', 'Ljava/lang/String;');
JavaField_lclbutton1str := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclbutton1str', 'Ljava/lang/String;');
JavaField_lclbutton2str := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclbutton2str', 'Ljava/lang/String;');
JavaField_lclbutton3str := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclbutton3str', 'Ljava/lang/String;');
//
JavaField_lclwidth := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclwidth', 'I');
JavaField_lclheight := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclheight', 'I');
JavaField_lclconfig := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclconfig', 'I');
JavaField_lclbutton1 := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclbutton1', 'I');
JavaField_lclbutton2 := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclbutton2', 'I');
JavaField_lclbutton3 := javaEnvRef^^.GetFieldID(javaEnvRef, javaActivityClass, 'lclbutton3', 'I');
if not assigned(JavaField_lcltext) then
begin
__android_log_write(ANDROID_LOG_FATAL, 'lclapp', 'javaEnvRef^.GetFieldID failed for lcltext');

View File

@ -107,6 +107,7 @@ function DateTimeToMilliseconds(aDateTime: TDateTime): Int64;
function IsValidDC(ADC: HDC): Boolean;
function IsValidGDIObject(AGDIObj: HGDIOBJ): Boolean;
function IsValidBitmap(ABitmap: HBITMAP): Boolean;
function RemoveAccelChars(AStr: string): string;
implementation
@ -494,6 +495,12 @@ begin
Result := ABitmap <> 0;
end;
function RemoveAccelChars(AStr: string): string;
begin
// ToDo convert && to & and keep it
Result := StringReplace(AStr, '&', '', [rfReplaceAll]);
end;
{ TCDBaseControl }
function TCDBaseControl.GetProps(AnIndex: String): pointer;

View File

@ -4788,6 +4788,7 @@ end;*)
function TCDWidgetSet.MessageBox(hWnd: HWND; lpText, lpCaption: PChar; uType: Cardinal): integer;
var
lJavaString: jstring;
BtnText: string;
begin
{$ifdef VerboseCDWinAPI}
DebugLn(Format('[TCDWidgetSet.MessageBox] HWND=%x javaEnvRef=%x lpText=%s lpCaption=%s uType=%d',
@ -4804,8 +4805,96 @@ begin
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcltext, lJavaString);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, lpCaption);
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcltitle, lJavaString);
// int fields
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclconfig, uType);
// Add all buttons
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, -1);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, -1);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton3, -1);
case utype of
MB_OK:
begin
// button1
BtnText := RemoveAccelChars(rsMbYes);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton1str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, IDOK);
end;
MB_OKCANCEL:
begin
// button1
BtnText := RemoveAccelChars(rsMbYes);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton1str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, IDOK);
// button2
BtnText := RemoveAccelChars(rsMbCancel);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton2str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, IDCANCEL);
end;
MB_ABORTRETRYIGNORE:
begin
// button1
BtnText := RemoveAccelChars(rsMbAbort);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton1str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, IDABORT);
// button2
BtnText := RemoveAccelChars(rsMbRetry);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton2str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, IDRETRY);
// button3
BtnText := RemoveAccelChars(rsMbIgnore);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton3str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton3, IDIGNORE);
end;
MB_YESNOCANCEL:
begin
// button1
BtnText := RemoveAccelChars(rsMbYes);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton1str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, IDYES);
// button2
BtnText := RemoveAccelChars(rsMbNo);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton2str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, IDNO);
// button3
BtnText := RemoveAccelChars(rsMbCancel);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton3str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton3, IDCANCEL);
end;
MB_YESNO:
begin
// button1
BtnText := RemoveAccelChars(rsMbYes);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton1str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, IDYES);
// button2
BtnText := RemoveAccelChars(rsMbNo);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton2str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, IDNO);
end;
MB_RETRYCANCEL:
begin
// button1
BtnText := RemoveAccelChars(rsMbRetry);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton1str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, IDRETRY);
// button2
BtnText := RemoveAccelChars(rsMbCancel);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton2str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, IDCANCEL);
end;
end;
// Call the method
javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoShowMessageBox);
@ -6551,6 +6640,7 @@ function TCDWidgetSet.PromptUser(const DialogCaption : string;
var
lJavaString: jstring;
BtnIndex, BtnKind: Integer;
BtnText: string;
begin
{$ifdef VerboseCDWinAPI}
DebugLn(Format('[TCDWidgetSet.PromptUser] javaEnvRef=%x DialogCaption=%s '
@ -6566,24 +6656,54 @@ begin
// String fields
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(DialogMessage));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcltext, lJavaString);
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(DialogMessage));
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(DialogCaption));
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lcltitle, lJavaString);
// Read the buttons
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, -1);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, -1);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton3, -1);
for BtnIndex := 0 to ButtonCount - 1 do
begin
BtnKind := Buttons[BtnIndex];
{$ifdef VerboseCDWinAPI}
DebugLn(Format(':[TCDWidgetSet.PromptUser] BtnKind=%d', [BtnKind]));
{$endif}
case BtnKind of
idButtonOK: BtnText := RemoveAccelChars(rsMbOK);
idButtonCancel: BtnText := RemoveAccelChars(rsMbCancel);
idButtonAbort: BtnText := RemoveAccelChars(rsMbAbort);
idButtonRetry: BtnText := RemoveAccelChars(rsMbRetry);
idButtonIgnore: BtnText := RemoveAccelChars(rsMbIgnore);
idButtonYes: BtnText := RemoveAccelChars(rsMbYes);
idButtonNo: BtnText := RemoveAccelChars(rsMbNo);
idButtonAll: BtnText := RemoveAccelChars(rsMbAll);
idButtonNoToAll: BtnText := RemoveAccelChars(rsMbNoToAll);
idButtonYesToAll:BtnText := RemoveAccelChars(rsMbYesToAll);
end;
lJavaString :=javaEnvRef^^.NewStringUTF(javaEnvRef, PChar(BtnText));
case BtnIndex of
0:
begin
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton1str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton1, BtnKind);
end;
1:
begin
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton2str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton2, BtnKind);
end;
2:
begin
javaEnvRef^^.SetObjectField(javaEnvRef, javaActivityObject, JavaField_lclbutton3str, lJavaString);
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclbutton3, BtnKind);
end;
end;
end;
// int fields
//javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclconfig, uType);
// Call the method
//javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoShowMessageBox);}
javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoShowMessageBox);
end;
//##apiwiz##eps## // Do not remove, no wizard declaration after this line

View File

@ -712,14 +712,14 @@ begin
{ // Form DC
if lFormHandle.Canvas = nil then lFormHandle.Canvas := TLazCanvas.create(nil);
Result := HDC(lFormHandle.Canvas);}
end;*)
end;
function TCDWidgetSet.MessageBox(hWnd: HWND; lpText, lpCaption: PChar; uType: Cardinal): integer;
begin
Result := 0;
end;
(*function TCocoaWidgetSet.SelectObject(ADC: HDC; GDIObj: HGDIOBJ): HGDIOBJ;
function TCocoaWidgetSet.SelectObject(ADC: HDC; GDIObj: HGDIOBJ): HGDIOBJ;
var
dc: TCocoaContext;
gdi: TCocoaGDIObject;
@ -1030,26 +1030,4 @@ begin
end;
end;*)
// In the end routines from customdrawnlclintfh.inc
function TCDWidgetSet.AskUser(const DialogCaption, DialogMessage: string; DialogType:
LongInt; Buttons: TDialogButtons; HelpCtx: Longint): LongInt;
begin
end;
function TCDWidgetSet.PromptUser(const DialogCaption : string;
const DialogMessage : string;
DialogType : LongInt;
Buttons : PLongInt;
ButtonCount : LongInt;
DefaultIndex : LongInt;
EscapeResult : LongInt) : LongInt;
begin
{$ifdef VerboseCDWinAPI}
DebugLn(Format('[TCDWidgetSet.PromptUser] javaEnvRef=%x DialogCaption=%s '
+ 'DialogMessage=%s DialogType=%d ButtonCount=%d',
[PtrInt(javaEnvRef), DialogCaption, DialogMessage, DialogType, ButtonCount]));
{$endif}
end;
//##apiwiz##eps## // Do not remove, no wizard declaration after this line

View File

@ -2504,7 +2504,7 @@ end;
function TWin32WidgetSet.MaskBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Mask: HBITMAP; XMask, YMask: Integer): Boolean;
begin
Result := StretchMaskBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, Width, Height, Mask, XMask, YMask, SRCCOPY);
end;*)
end;
{------------------------------------------------------------------------------
Method: MessageBox
@ -2536,7 +2536,7 @@ begin
PWideChar(WideLPCaption), UType);
end;
(*function TWin32WidgetSet.MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord): HMONITOR;
function TWin32WidgetSet.MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord): HMONITOR;
begin
Result := MultiMon.MonitorFromPoint(ptScreenCoords, dwFlags);
end;
@ -3690,28 +3690,6 @@ begin
end;
end;*)
// In the end routines from customdrawnlclintfh.inc
function TCDWidgetSet.AskUser(const DialogCaption, DialogMessage: string; DialogType:
LongInt; Buttons: TDialogButtons; HelpCtx: Longint): LongInt;
begin
end;
function TCDWidgetSet.PromptUser(const DialogCaption : string;
const DialogMessage : string;
DialogType : LongInt;
Buttons : PLongInt;
ButtonCount : LongInt;
DefaultIndex : LongInt;
EscapeResult : LongInt) : LongInt;
begin
{$ifdef VerboseCDWinAPI}
DebugLn(Format('[TCDWidgetSet.PromptUser] javaEnvRef=%x DialogCaption=%s '
+ 'DialogMessage=%s DialogType=%d ButtonCount=%d',
[PtrInt(javaEnvRef), DialogCaption, DialogMessage, DialogType, ButtonCount]));
{$endif}
end;
//##apiwiz##eps## // Do not remove

View File

@ -4744,7 +4744,7 @@ begin
end;
Result := True;
end;*)
end;
function TCDWidgetSet.MessageBox(hWnd: HWND; lpText, lpCaption: PChar; uType: Cardinal): integer;
begin
@ -4752,7 +4752,7 @@ begin
Result := Application.MessageBox(lpText, lpCaption, uType);
end;
(*{------------------------------------------------------------------------------
{------------------------------------------------------------------------------
Function: MoveToEx
Params: none
Returns: Nothing
@ -6474,26 +6474,4 @@ begin
FLastWFPMousePos := APoint;
end;*)
// In the end routines from customdrawnlclintfh.inc
function TCDWidgetSet.AskUser(const DialogCaption, DialogMessage: string; DialogType:
LongInt; Buttons: TDialogButtons; HelpCtx: Longint): LongInt;
begin
end;
function TCDWidgetSet.PromptUser(const DialogCaption : string;
const DialogMessage : string;
DialogType : LongInt;
Buttons : PLongInt;
ButtonCount : LongInt;
DefaultIndex : LongInt;
EscapeResult : LongInt) : LongInt;
begin
{$ifdef VerboseCDWinAPI}
DebugLn(Format('[TCDWidgetSet.PromptUser] javaEnvRef=%x DialogCaption=%s '
+ 'DialogMessage=%s DialogType=%d ButtonCount=%d',
[PtrInt(javaEnvRef), DialogCaption, DialogMessage, DialogType, ButtonCount]));
{$endif}
end;
//##apiwiz##eps## // Do not remove, no wizard declaration after this line