BEGIN
If MessageDlg('Cancel?', mtConfirmation,
[mbYes, mbNo], 0) = mrNo Then
Abort;
END;
Delphi says "Statement expected, but expression of type 'integer' found."
It's strange because I always used the ABORT procedure to cancel the TTable's Before procedures, but now in Delphi 3.0 it won't compile. I tried to put the ABORT procedure in other codes, it just shows the same error.
I think the problem has something to do with either the order of the units USES clause or a unit is missing from the unit.
try using my "Message" unit, (this isolates the call to MessageDlg) add it to the form;s uses clause which is causing the problem. Then use the function called "Question".
Caveat: Each of my routines allow you to do multi-lines in the messages by using a semi-colon rather then #13.
For example:
'This is line 1' + #13 + 'Line 2' ;
My method
'This is line 1;Line 2' ;
Demo call
procedure TfrmMain.Table1BeforeCancel(DataSet: TDataSet);
begin
if not Question('Cancel?') then
abort ;
end;
-------------Source code -------------------------
unit kg_MsgDlg ;
interface
uses
Windows, Messages, Classes, Graphics;
function Confirmation(const S: String): Word ;
function Question(const S: String):Boolean ;
procedure Information(const S: String) ;
procedure InformationPos(const S: String;nRow,nCol:Integer) ;
procedure Alert(const S: String) ;
procedure ErrMsg(const S: String) ;
function RetryBox(const S: String):Boolean ;
function StrCrLf(const cMsg:String):String ;
implementation
uses SysUtils, Controls, Forms, Consts, Dialogs ;
function StrCrLf(const cMsg:String):String ;
var nLen,i:Integer ;
begin
nLen := Length(cMsg) ;
i := 1 ;
while i <= nLen do begin
if cMsg[i] in [';','~'] then
Result := Result + #13
else
Result := Result + cMsg[i] ;
Inc(i) ;
end ;
end ;
function Confirmation(const S: String): Word ;
begin
case MessageDlg(StrCrLf(S),mtConfirmation,[mbYes,mbNo,mbCancel],0) of
IDYES : Result := mrYes ;
IDNO : Result := mrNo ;
IDCANCEL : Result := mrCancel ;
else Result := mrCancel ;
end
end ;
procedure Alert(const S: String) ;
begin
MessageDlg(StrCrLf(S),mtWarning,[mbOk],0) ;
end ;
procedure Information(const S: String) ;
begin
MessageDlg(StrCrLf(S),mtInformation,[mbOk],0) ;
end ;
procedure InformationPos(const S: String;nRow,nCol:Integer) ;
begin
MessageDlgPos(StrCrLf(S),mtInformation,[mbOk],0,nCol,nRow) ;
end ;
procedure ErrMsg(const S: String) ;
begin
MessageDlg(StrCrLf(S),mtError,[mbOk],0) ;
end ;
function Question(const S: String):Boolean ;
begin
case MessageDlg(StrCrLf(S),mtConfirmation,[mbYes,mbNo],0) of
IDYES : Result := True ;
IDNO : Result := False ;
else Result := False ;
end ;
end ;
function RetryBox(const S: String):Boolean ;
begin
case MessageDlg(StrCrLf(S),mtConfirmation,[mbRetry,mbNo],0) of
IDRETRY : Result := True ;
IDNO : Result := False ;
else Result := False ;
end ;
end ;
ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.
One of a set of tools we're offering as a way to say thank you for being a part of the community.
try using my "Message" unit, (this isolates the call to MessageDlg) add it to the form;s uses clause which is causing the problem. Then use the function called "Question".
Caveat: Each of my routines allow you to do multi-lines in the messages by using a semi-colon rather then #13.
For example:
'This is line 1' + #13 + 'Line 2' ;
My method
'This is line 1;Line 2' ;
Demo call
procedure TfrmMain.Table1BeforeCance
begin
if not Question('Cancel?') then
abort ;
end;
-------------Source code -------------------------
unit kg_MsgDlg ;
interface
uses
Windows, Messages, Classes, Graphics;
function Confirmation(const S: String): Word ;
function Question(const S: String):Boolean ;
procedure Information(const S: String) ;
procedure InformationPos(const S: String;nRow,nCol:Integer) ;
procedure Alert(const S: String) ;
procedure ErrMsg(const S: String) ;
function RetryBox(const S: String):Boolean ;
function StrCrLf(const cMsg:String):String ;
implementation
uses SysUtils, Controls, Forms, Consts, Dialogs ;
function StrCrLf(const cMsg:String):String ;
var nLen,i:Integer ;
begin
nLen := Length(cMsg) ;
i := 1 ;
while i <= nLen do begin
if cMsg[i] in [';','~'] then
Result := Result + #13
else
Result := Result + cMsg[i] ;
Inc(i) ;
end ;
end ;
function Confirmation(const S: String): Word ;
begin
case MessageDlg(StrCrLf(S),mtCo
IDYES : Result := mrYes ;
IDNO : Result := mrNo ;
IDCANCEL : Result := mrCancel ;
else Result := mrCancel ;
end
end ;
procedure Alert(const S: String) ;
begin
MessageDlg(StrCrLf(S),mtWa
end ;
procedure Information(const S: String) ;
begin
MessageDlg(StrCrLf(S),mtIn
end ;
procedure InformationPos(const S: String;nRow,nCol:Integer) ;
begin
MessageDlgPos(StrCrLf(S),m
end ;
procedure ErrMsg(const S: String) ;
begin
MessageDlg(StrCrLf(S),mtEr
end ;
function Question(const S: String):Boolean ;
begin
case MessageDlg(StrCrLf(S),mtCo
IDYES : Result := True ;
IDNO : Result := False ;
else Result := False ;
end ;
end ;
function RetryBox(const S: String):Boolean ;
begin
case MessageDlg(StrCrLf(S),mtCo
IDRETRY : Result := True ;
IDNO : Result := False ;
else Result := False ;
end ;
end ;
end.
Kevin S. Gallagher