안녕하세요...
다음 두가지에 관련된 질문입니다.
1. 요상한 exception(?)의 exception handler 만들기
2. 에러 메시지 박스 안 보이게 하기
다음 라인에서 에러가 발생하였습니다.
image1.picture.assign(myJpeg);
메시지는 JPEG Error #52 입니다.
델파이에서 보면 EJPEG Exception이 발생했다고 합니다.
그런데 다음과 같이 Exception handler를 만들면 컴파일할 때 에러가 납니다.
try
image1.picture.assign(myJpeg);
except
on EJPEG do ; //do nothing in order not to show the error message box.
end;
컴파일 에러 메시지는 "Undeclared Identifier EJPEG" 입니다.
에러 메시지에는 EJPEG 이라고 하고서는 EJPEG을 모르다니 어떻게 된 건가요?
아시는 분의 한 말씀을 듣고 싶습니다.
그리고,
이러한 exception은 어떻게 핸들링해야 하는지요?
try
image1.picture.assign(myJpeg);
except
; //do nothing in order not to show the error message box.
end;
위와 같이 하면 모든 exception 에 대한 핸들러가 되다고 하던데 그렇지 않더군요.
그리고
try
image1.picture.assign(myJpeg);
except
on EOverFlow do ;
else ; //do nothing in order not to show the error message box.
end;
위와 같이 해도 마찬가지입니다.
Exception handler를 만들 수 없다면 에러 메시지 박스를 디스플레이 하지 않게는 할 수 없나요?
관심가져 주신 것에 대해 감사드립니다.
그럼...
그리고 메세지를 안 나타나게 하려면 글로벌 예외처리를 해서
예외를 그냥 무시하면 됩니다.
예제]
type
TForm1 = class(TForm)
.
.
.
public
{ Public declarations }
procedure MyExceptionHandler(Sender: TObject; E: Exception);//선언
end;
implementation
{$R *.DFM}
procedure TForm1.MyExceptionHandler( Sender : TObject; E : Exception );
begin
//아무 것도 안쓰면 됨
end;
//TForm1의 Create의 이벤트에 다음과 같이
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException := MyExceptionHandler;
end;