예를들어 이런 코드를 만들려고 합니다.
원래는 아래와 같은 코드인데요
procedure TFormMain.mnuLessonsClick(Sender: TObject);
var
f: TFormLessons;
begin
//이미 있는 폼이 해당 폼이면 최대화시키고
//아니면 종료시키고 새 폼을 만든다.
if ActiveMDIChild <> nil then
begin
if ActiveMdichild is TFormLessons then
begin
ActiveMdiChild.WindowState := wsMaximized;
Exit;
end else
ActiveMDIChild.Close;
end;
//새 폼을 만든다.
f := TFormLessons.Create(self);
f.WindowState := wsMaximized;
end;
이런 코드를 아래와 같이 만들려고 합니다.
function TFormMain.CheckActiveForm(_t : type): boolean;
begin
if ActiveMDIChild <> nil then
begin
if ActiveMdichild is _t then
begin
ActiveMdiChild.WindowState := wsMaximized;
Result := true;
Exit;
end else
ActiveMDIChild.Close;
end;
Result := false;
end;
procedure TFormMain.mnuLessonsClick(Sender: TObject);
var
f: TFormLessons;
begin
//이미 있는 폼이 해당 폼이면 최대화시키고
//아니면 종료시키고 새 폼을 만든다.
if CheckActiveForm (TFormLessons) then
Exit;
//새 폼을 만든다.
f := TFormLessons.Create(self);
f.WindowState := wsMaximized;
end;
헌데 함수 파라미터에 type이름을 넘기는 방법을 모르겠습니다.
함수선언시에
(_t : type)
이 부분에서 에러가 납니다.
그리고 혹시나
c++의 #define과 매크로가 델파이에 있나요?
|