-
2011. 5. 26. 01:54 Tutorials/IDE]Delphi 7.2
프레임 생성은 파일 메뉴에서 프레임을 선택하는 것으로 간단히 빈 프레임을 생성 할수 있습니다.
프레임 다지인 - 메세지 박스
예제창 디자인 - 메세지 띄우기
인라인 메세지창을 띄워볼 것 입니다.
윈도우 메세지창은 뒤로 숨어버리거나, 창이 잠시 죽는등의 불편한 문제가 생길 수 있는것을
인라인 메세지창을 이용하여 인터페이스를 매우 빠르고 편리하게 만들어줍니다.
우선 프레임 유닛에 반환값을 가져올수 있도록 공용 클래스부분에 변수를 등록 합니다.
type
TFrame2 = class(TFrame)
Label1: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
RETN: Integer;// <- 등록된 변수값
end;
TFrame2 = class(TFrame)
Label1: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
RETN: Integer;// <- 등록된 변수값
end;
다음으로 버튼 이벤트를 등록 합니다.
procedure
TFrame2.SpeedButton1Click(Sender: TObject);begin
RETN := 1;
Self.Visible := not Self.Visible;//프레임 숨김
end;
procedure TFrame2.SpeedButton2Click(Sender: TObject);begin
RETN := 0;
Self.Visible := not Self.Visible;//프레임 숨김
end;
RETN := 1;
Self.Visible := not Self.Visible;//프레임 숨김
end;
procedure TFrame2.SpeedButton2Click(Sender: TObject);begin
RETN := 0;
Self.Visible := not Self.Visible;//프레임 숨김
end;
메인 유닛으로 와서 프레임을 생성 및 반환값을 기다리는데 블러킹 하고,
반환값이 기록되면 프레임을 해제 하겠습니다.
implementation
//하단에 uses 를 따로 선언 해줄 수 있습니다. 차이점은 전역 변수로 클래스를 사용 할수 있거나 없거나 차이 가 있죠.
uses MessageUnit;
{$R *.dfm}
procedure TMainForm.SpeedButton1Click(Sender: TObject);
var msg: TFrame2;
begin
msg := TFrame2.Create(Self);
msg.Parent := Self;//부모창 지정
msg.Top := 50;
msg.Left := Self.Width div 2 - msg.Width div 2;//프레임을 창 가운데로 지정
msg.Label1.Caption := '메세지 내용';
msg.SpeedButton1.Caption := '확인';
msg.SpeedButton2.Caption := '취소';
msg.Visible := True;
repeat Application.ProcessMessages; Sleep(10);//창 메세지를 처리하며 블러킹
until msg.Visible = False;
if msg.RETN = 1 then begin//반환값 확인
//확인
end else begin
//취소
end;
msg.Free;//메세지박스 프레임 메모리 해제
end;
//하단에 uses 를 따로 선언 해줄 수 있습니다. 차이점은 전역 변수로 클래스를 사용 할수 있거나 없거나 차이 가 있죠.
uses MessageUnit;
{$R *.dfm}
procedure TMainForm.SpeedButton1Click(Sender: TObject);
var msg: TFrame2;
begin
msg := TFrame2.Create(Self);
msg.Parent := Self;//부모창 지정
msg.Top := 50;
msg.Left := Self.Width div 2 - msg.Width div 2;//프레임을 창 가운데로 지정
msg.Label1.Caption := '메세지 내용';
msg.SpeedButton1.Caption := '확인';
msg.SpeedButton2.Caption := '취소';
msg.Visible := True;
repeat Application.ProcessMessages; Sleep(10);//창 메세지를 처리하며 블러킹
until msg.Visible = False;
if msg.RETN = 1 then begin//반환값 확인
//확인
end else begin
//취소
end;
msg.Free;//메세지박스 프레임 메모리 해제
end;