Q&A

  • 소스를 수정하니 컴포넌트를 Remove하겠다는 메시지가 나옵니다.
아래 코드는 상태바에 콤보박스와 프로그래스바를 넣는 것이랍니다.



그래서 폼을 하나 만들고 그곳에다가 아래와 같이 소스를 수정한후 실행을 하니

자꾸 SBbar를 remove하겠다는 메시지가 나옴니다.



그래서 확인을 하면 1번줄이 없어 지구요...

이거 실행하는 방법좀 알려주세요...



unit Unit1;



interface



uses Messages, Windows, SysUtils, CommCtrl, Classes, Controls, Forms,

Menus, Graphics, StdCtrls, RichEdit, ToolWin, ComCtrls;



type

TForm1 = class(TForm)

SBar: TStatusBar; <- ------------ 1번

procedure SBarResize(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure FormShow(Sender: TObject);

private

{ Private declarations }

E : TComboBox;

P : TProgressBar;

public

{ Public declarations }

end;



var

Form1: TForm1;



implementation



{$R *.DFM}



procedure TForm1.SBarResize(Sender: TObject);

var

Rect : TRect;

begin

// 인덱스0번째의 Rect를 가져온다.

SBar.Perform(SB_GETRECT,0,LPARAM(@Rect));

P.Top := Rect.Top;

P.Left := Rect.Left;

P.Width := Rect.Right - Rect.Left;

P.Height := Rect.Bottom - Rect.Top;

P.Visible := True;



// 인덱스1번째의 Rect를 가져온다.

SBar.Perform(SB_GETRECT,1,LPARAM(@Rect));

E.Top := Rect.Top;

E.Left := Rect.Left;

E.Width := Rect.Right - Rect.Left;

E.Height := Rect.Bottom - Rect.Top;

E.Visible := True;

end;



procedure TForm1.FormCreate(Sender: TObject);

begin

// 콤보박스 생성

E := TComboBox.Create(SBar);

E.Parent := SBar;

E.Visible := False;



// 프로그레스바 생성

P := TProgressBar.Create(SBar);

P.Parent := SBar;

P.Position := 100;

P.Visible := False;

end;



procedure TForm1.FormShow(Sender: TObject);

begin

SBar.Perform(WM_SIZE,0,0);

end;



procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

if Assigned(E) then

E.Free;

if Assigned(P) then

P.Free;

end;



end.



2  COMMENTS
  • Profile
    김일영 2000.11.22 19:55
    제가 볼 때는 소스의 탓이 아니고...

    그런 현상이 나타나는 경우는 private 영역 윗부분(쩝. 이부분을 가리키는 표현이 있었는데 까먹었습니다.)에

    SBbar: TStatusBar라는 선언이 컴포넌트를 올려놓음으로서 자동적으로 들어간 내용이 아니라 컴포넌트와

    상관없이 사람이 코딩으로 추가한 것으로서 인식이 되어서 그런 것 같은데요.

    하여간... 일단 OK하셔서 문제의 1번 줄을 날려버리신 후.. 폼에서 SBbar를 지워버리세요.

    그런 다음 StatusBar를 다시 새로 올려놓으시고..SBbar라고 다시 이름을 바꾸시고

    (물론 Object Inspector에서죠...) SBbarResize를 다시 연결하시고... 그러시면 될 것입니다.

    수고하세요.

  • Profile
    시노 2000.11.22 20:30
    답변 감사합니다...

    그렇게 하니 되더군요.

    근데 한곳에서 또....찾아도 모르겠고..

    이것좀 알려주세요.

    SB_GETRECT이것에서 에러가 나오네요.



    아이던디피어래요..뭔가 정의가 안된것 같은데 왜 그려죠?



    procedure TForm1.SBarResize(Sender: TObject);

    var

    Rect : TRect;

    begin

    // 인덱스0번째의 Rect를 가져온다.

    SBar.Perform(SB_GETRECT,0,LPARAM(@Rect));

    P.Top := Rect.Top;

    P.Left := Rect.Left;

    P.Width := Rect.Right - Rect.Left;

    P.Height := Rect.Bottom - Rect.Top;

    P.Visible := True;