동적폼에 동적라벨,동적타이머를 생성하고나서
동적라벨에 마우스좌표를 보여주려고하는데
동적 폼 자체가 아예 안보여집니다 T^T
self를 DynamicForm으로 바꿔보기도하고 어쨌든 폼이 안보여집니다
show 를 써봐도 안되구요...
그리고 Destroy에 free를 서주었더니 오류 발생하네요 T^T 왜그런가요?
폼 생성을 잘못한건가요? 고수님들의 조언부탁드립니다요 ^^
즐프되세요~
=======================================================================
unit FormSRC;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TMainForm = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
DynamicForm : TForm;
DynamicLabelX, DynamicLabelY : TLabel;
DynamicTimer : TTimer;
procedure DynamicTimerProc(Sender : TObject);
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure TMainForm.FormCreate(Sender: TObject);
begin
DynamicForm := TForm.Create(self);
with DynamicForm do
begin
DynamicForm.FormStyle := fsStayOnTop;
DynamicForm.Width := 80;
DynamicForm.Height := 16;
DynamicForm.Color := clBtnFace;
DynamicForm.Visible := True;
// DynamicForm.OnDestroy := DynamicFormDestroyProc;
end;
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
DynamicLabelX := TLabel.Create(self);
with DynamicLabelX do
begin
DynamicLabelX.Left := 0;
DynamicLabelX.Top := 0;
DynamicLabelX.Visible := True;
DynamicLabelX.Align := alLeft;
DynamicLabelX.Width := 40;
DynamicLabelX.Font.Size := 8;
DynamicLabelX.Font.Color := clBlue;
DynamicLabelX.Parent := DynamicForm;
end;
DynamicLabelY := TLabel.Create(self);
with DynamicLabelY do
begin
DynamicLabelY.Left := 0;
DynamicLabelY.Top := 0;
DynamicLabelY.Visible := True;
DynamicLabelY.Align := alRight;
DynamicLabelY.Width := 40;
DynamicLabelY.Font.Size := 8;
DynamicLabelY.Font.Color := clBlue;
DynamicLabelY.Parent := DynamicForm;
end;
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
DynamicTimer := TTimer.Create(self);
with DynamicTimer do
begin
DynamicTimer.Interval := 1;
DynamicTimer.Enabled := True;
DynamicTimer.OnTimer := DynamicTimerProc;
Parent := DynamicForm;
end;
end;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure TMainForm.DynamicTimerProc(Sender : TObject);
begin
DynamicLabelX.Caption := 'X: ' + IntToStr(Mouse.CursorPos.X);
DynamicLabelY.Caption := 'Y: ' + IntToStr(Mouse.CursorPos.Y);
end;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
end.
일단 해상도를 1024(width), 768(height)을 기준으로 아래처럼 해보세요.
procedure TMainForm.FormCreate(Sender: TObject);
begin
DynamicForm := TForm.Create(self);
with DynamicForm do
begin
DynamicForm.FormStyle := fsStayOnTop;
DynamicForm.Width := 1024; // Form Width
DynamicForm.Height := 768; // Form Height
DynamicForm.Color := clBtnFace;
DynamicForm.Visible := True;
// DynamicForm.OnDestroy := DynamicFormDestroyProc;
end;