Q&A

  • mouse over로 버튼 이미지 바꾸기??
mouse over이벤트로 bitbtn 이미지를 바꿀려구 하는데안되네요

CM_MOUSELEAVE를 안먹는것 같아요 CM_MOUSEENTER는 먹는데

시간때문에 그러나요. font색같은건 단번에 잘 바뀌는데요.

전문가님 아래 소스좀 수정해 주세요



unit Unit1;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, ImgList, Buttons;



type

TForm1 = class(TForm)

BitBtn1: TBitBtn;

ImageList1: TImageList;

BitBtn2: TBitBtn;



private

{ Private declarations }

procedure WndProc(var Message: TMessage); override;



public

{ Public declarations }

procedure ChangeImage(Sender: TObject; Msg: Integer);

end;



var

Form1: TForm1;



implementation

{$R *.DFM}



procedure TForm1.WndProc(var Message: TMessage);

begin





if Message.LParam = Longint(Bitbtn1) then

ChangeImage(Bitbtn1, Message.Msg);

if Message.LParam = Longint(Bitbtn2) then

ChangeImage(Bitbtn2, Message.Msg);



inherited WndProc(Message);

end;





procedure TForm1.ChangeImage(Sender: TObject; Msg: Integer);

Begin

if Sender is Tbitbtn then

begin

if (Msg = CM_MOUSELEAVE) then

begin

imagelist1.GetBitmap(2, TBitbtn(Sender).Glyph );

TBitbtn(Sender).Font.Color := clred;

end;



if (Msg = CM_MOUSEENTER) then

begin

imagelist1.GetBitmap(1 ,TBitbtn(Sender).Glyph ) ;

TBitbtn(Sender).Font.Color := clblue;

end;



end;





end;



end.



3  COMMENTS
  • Profile
    조규춘 2001.10.29 02:43


    반갑습니다.



    이런거에 대한 예제를 보내드리지요..



    아래의 주소입니다.



    http://user.chollian.net/~garam4g/cal.ZIP



    그럼 수고하십시요~



    궁금이 wrote:

    > mouse over이벤트로 bitbtn 이미지를 바꿀려구 하는데안되네요

    > CM_MOUSELEAVE를 안먹는것 같아요 CM_MOUSEENTER는 먹는데

    > 시간때문에 그러나요. font색같은건 단번에 잘 바뀌는데요.

    > 전문가님 아래 소스좀 수정해 주세요

    >

    > unit Unit1;

    >

    > interface

    >

    > uses

    > Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    > StdCtrls, ImgList, Buttons;

    >

    > type

    > TForm1 = class(TForm)

    > BitBtn1: TBitBtn;

    > ImageList1: TImageList;

    > BitBtn2: TBitBtn;

    >

    > private

    > { Private declarations }

    > procedure WndProc(var Message: TMessage); override;

    >

    > public

    > { Public declarations }

    > procedure ChangeImage(Sender: TObject; Msg: Integer);

    > end;

    >

    > var

    > Form1: TForm1;

    >

    > implementation

    > {$R *.DFM}

    >

    > procedure TForm1.WndProc(var Message: TMessage);

    > begin

    >

    >

    > if Message.LParam = Longint(Bitbtn1) then

    > ChangeImage(Bitbtn1, Message.Msg);

    > if Message.LParam = Longint(Bitbtn2) then

    > ChangeImage(Bitbtn2, Message.Msg);

    >

    > inherited WndProc(Message);

    > end;

    >

    >

    > procedure TForm1.ChangeImage(Sender: TObject; Msg: Integer);

    > Begin

    > if Sender is Tbitbtn then

    > begin

    > if (Msg = CM_MOUSELEAVE) then

    > begin

    > imagelist1.GetBitmap(2, TBitbtn(Sender).Glyph );

    > TBitbtn(Sender).Font.Color := clred;

    > end;

    >

    > if (Msg = CM_MOUSEENTER) then

    > begin

    > imagelist1.GetBitmap(1 ,TBitbtn(Sender).Glyph ) ;

    > TBitbtn(Sender).Font.Color := clblue;

    > end;

    >

    > end;

    >

    >

    > end;

    >

    > end.

    >

  • Profile
    궁금이 2001.10.29 04:32
    아래 파일을 풀고 델파이에서 여니까 stream에러가 나네요 form이 안보여요

    조규춘 wrote:

    >

    > 반갑습니다.

    >

    > 이런거에 대한 예제를 보내드리지요..

    >

    > 아래의 주소입니다.

    >

    > http://user.chollian.net/~garam4g/cal.ZIP

    >

    > 그럼 수고하십시요~

    >

    > 궁금이 wrote:

    > > mouse over이벤트로 bitbtn 이미지를 바꿀려구 하는데안되네요

    > > CM_MOUSELEAVE를 안먹는것 같아요 CM_MOUSEENTER는 먹는데

    > > 시간때문에 그러나요. font색같은건 단번에 잘 바뀌는데요.

    > > 전문가님 아래 소스좀 수정해 주세요

    > >

    > > unit Unit1;

    > >

    > > interface

    > >

    > > uses

    > > Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    > > StdCtrls, ImgList, Buttons;

    > >

    > > type

    > > TForm1 = class(TForm)

    > > BitBtn1: TBitBtn;

    > > ImageList1: TImageList;

    > > BitBtn2: TBitBtn;

    > >

    > > private

    > > { Private declarations }

    > > procedure WndProc(var Message: TMessage); override;

    > >

    > > public

    > > { Public declarations }

    > > procedure ChangeImage(Sender: TObject; Msg: Integer);

    > > end;

    > >

    > > var

    > > Form1: TForm1;

    > >

    > > implementation

    > > {$R *.DFM}

    > >

    > > procedure TForm1.WndProc(var Message: TMessage);

    > > begin

    > >

    > >

    > > if Message.LParam = Longint(Bitbtn1) then

    > > ChangeImage(Bitbtn1, Message.Msg);

    > > if Message.LParam = Longint(Bitbtn2) then

    > > ChangeImage(Bitbtn2, Message.Msg);

    > >

    > > inherited WndProc(Message);

    > > end;

    > >

    > >

    > > procedure TForm1.ChangeImage(Sender: TObject; Msg: Integer);

    > > Begin

    > > if Sender is Tbitbtn then

    > > begin

    > > if (Msg = CM_MOUSELEAVE) then

    > > begin

    > > imagelist1.GetBitmap(2, TBitbtn(Sender).Glyph );

    > > TBitbtn(Sender).Font.Color := clred;

    > > end;

    > >

    > > if (Msg = CM_MOUSEENTER) then

    > > begin

    > > imagelist1.GetBitmap(1 ,TBitbtn(Sender).Glyph ) ;

    > > TBitbtn(Sender).Font.Color := clblue;

    > > end;

    > >

    > > end;

    > >

    > >

    > > end;

    > >

    > > end.

    > >

  • Profile
    조규춘 2001.10.29 13:52
    보니깐..



    지금 그 압축파일을 푸니...



    읽기전용으로 되었있어서...



    *.dcu를 만들지 못한다는 에러가 뜨더군요..



    그걸 읽기전용을 해제해서 실행하니.. 잘 되더군요..



    다시한번 해보시겠습니까?



    궁금이 wrote:

    > 아래 파일을 풀고 델파이에서 여니까 stream에러가 나네요 form이 안보여요

    > 조규춘 wrote:

    > >

    > > 반갑습니다.

    > >

    > > 이런거에 대한 예제를 보내드리지요..

    > >

    > > 아래의 주소입니다.

    > >

    > > http://user.chollian.net/~garam4g/cal.ZIP

    > >

    > > 그럼 수고하십시요~

    > >

    > > 궁금이 wrote:

    > > > mouse over이벤트로 bitbtn 이미지를 바꿀려구 하는데안되네요

    > > > CM_MOUSELEAVE를 안먹는것 같아요 CM_MOUSEENTER는 먹는데

    > > > 시간때문에 그러나요. font색같은건 단번에 잘 바뀌는데요.

    > > > 전문가님 아래 소스좀 수정해 주세요

    > > >

    > > > unit Unit1;

    > > >

    > > > interface

    > > >

    > > > uses

    > > > Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    > > > StdCtrls, ImgList, Buttons;

    > > >

    > > > type

    > > > TForm1 = class(TForm)

    > > > BitBtn1: TBitBtn;

    > > > ImageList1: TImageList;

    > > > BitBtn2: TBitBtn;

    > > >

    > > > private

    > > > { Private declarations }

    > > > procedure WndProc(var Message: TMessage); override;

    > > >

    > > > public

    > > > { Public declarations }

    > > > procedure ChangeImage(Sender: TObject; Msg: Integer);

    > > > end;

    > > >

    > > > var

    > > > Form1: TForm1;

    > > >

    > > > implementation

    > > > {$R *.DFM}

    > > >

    > > > procedure TForm1.WndProc(var Message: TMessage);

    > > > begin

    > > >

    > > >

    > > > if Message.LParam = Longint(Bitbtn1) then

    > > > ChangeImage(Bitbtn1, Message.Msg);

    > > > if Message.LParam = Longint(Bitbtn2) then

    > > > ChangeImage(Bitbtn2, Message.Msg);

    > > >

    > > > inherited WndProc(Message);

    > > > end;

    > > >

    > > >

    > > > procedure TForm1.ChangeImage(Sender: TObject; Msg: Integer);

    > > > Begin

    > > > if Sender is Tbitbtn then

    > > > begin

    > > > if (Msg = CM_MOUSELEAVE) then

    > > > begin

    > > > imagelist1.GetBitmap(2, TBitbtn(Sender).Glyph );

    > > > TBitbtn(Sender).Font.Color := clred;

    > > > end;

    > > >

    > > > if (Msg = CM_MOUSEENTER) then

    > > > begin

    > > > imagelist1.GetBitmap(1 ,TBitbtn(Sender).Glyph ) ;

    > > > TBitbtn(Sender).Font.Color := clblue;

    > > > end;

    > > >

    > > > end;

    > > >

    > > >

    > > > end;

    > > >

    > > > end.

    > > >