Arsip: Tanya tentang komponen Image

 
user image
more 10 years ago

bonny_rayfoxs

Para suhu... mau tanya nih.. cara bkin event saat mouse diarahin ke suatu image gmn ya? gw uda cb bkin di event OnMouseMove... saat arahin mouse ke image memang ada event, tp saat mouse di pindahkan dr image event nya gmn y biar bisa balik ke semula?
user image
more 10 years ago

DelphiExpert

Balik ke semula gimana maksudnya om? Coba dijelaskan dengan lebih jelas :o
user image
more 10 years ago

bonny_rayfoxs

Misal nya begini mas.. saya isi picture ke 1 Timage.. trus saya mau bkin Klo kita arahin pointer mouse ke image, picture dr image ny brubah.. trus klo pointer di pindahin dari Timage, picture nya kmbali sprti awal kira2 gmn ya?
user image
more 10 years ago

Goen

@bonny_rayfoxs: Misal nya begini mas.. saya isi picture ke 1 Timage.. trus saya mau bkin Klo kita arahin pointer mouse ke image, picture dr image ny brubah.. trus klo pointer di pindahin dari Timage, picture nya kmbali sprti awal kira2 gmn ya?
Bro, Pakai event OnMouseEnter dan OnMouseLeave saja.
user image
more 10 years ago

bonny_rayfoxs

@Goen:
@bonny_rayfoxs: Misal nya begini mas.. saya isi picture ke 1 Timage.. trus saya mau bkin Klo kita arahin pointer mouse ke image, picture dr image ny brubah.. trus klo pointer di pindahin dari Timage, picture nya kmbali sprti awal kira2 gmn ya?
Bro, Pakai event OnMouseEnter dan OnMouseLeave saja.
Gw cari di properties gak ada mas event OnMouseEnter.. perlu deklarasi sndri atau gmn ya? Udah tanya tmn sana sini pada bingung denger OnMouseEnter... minta contoh nya donk mas
user image
more 10 years ago

luckynvic

kalo komponen standart image delphi 7 memang nggak ada event onMouseEnter dan onMouseLeave, tapi Delphi 2009 ada gan (nggak tau kalo versi yg lain, harusnya makin baru versinya tetap ada. :) ) kalo agan pake delphi 7, bisa pake komponen image dari komponen tambahan. kalo nggak mau bisa akal2 gan! :wink: buat saja label di atas sebesar image, set transparant=true, trus event onMouseEnter dan onMouseLeave dipake untuk rubah gambarnya..
user image
more 10 years ago

Goen

@bonny_rayfoxs:
@Goen: [quote:8464fa06f6="bonny_rayfoxs"]Misal nya begini mas.. saya isi picture ke 1 Timage.. trus saya mau bkin Klo kita arahin pointer mouse ke image, picture dr image ny brubah.. trus klo pointer di pindahin dari Timage, picture nya kmbali sprti awal kira2 gmn ya?
Bro, Pakai event OnMouseEnter dan OnMouseLeave saja.[/quote:8464fa06f6] Gw cari di properties gak ada mas event OnMouseEnter.. perlu deklarasi sndri atau gmn ya? Udah tanya tmn sana sini pada bingung denger OnMouseEnter... minta contoh nya donk mas
Sorry Bro, Ane kira ada event OnMouseEnter & OnMouseLeave di TImage ente. Mungkin seperti Bro Luckynvic bilang, ente pake versi Delphi 7 ke bawah. Berhubung ane pake Delphi XE2, ane gak bisa reproduce TImage yang gak ada OnMouseEnter & OnMouseLeave. Tapi, ane coba cari komponen visual yang gak ada OnMouseEnter & OnMouseLeave dan nemu TRadioGroup. Ane coba tambahin fitur OnMouseEnter & OnMouseLeave ke dalamnya. Gampang, kok. Ente tinggal copy aja dari TControl:

TControl = class(TComponent)
private
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
.
.
.
end;
Buat class baru turunan TRadioGroup (dalam kasus ente berarti, TImage):

interface
uses
  ExtCtrls, ...;
type
  TXRadioGroup = class(TRadioGroup)
  private
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  end;
implementation
procedure TXRadioGroup.CMMouseEnter(var Message: TMessage);
begin
  Caption := 'Mouse Enter Radio Group!';
end;
procedure TXRadioGroup.CMMouseLeave(var Message: TMessage);
begin
  Caption := 'Mouse Leave Radio Group!';
end;
end.
Masalahnya, ente gak bisa create component ini secara design-time lagi. Kudu run-time. Kalau mau bisa design-time, ente buat component baru dan install ke component pallete. Terserah ente mau gimana. Tapi, ane lebih prefer create saat run-time, biar source codenya lebih mobile (gampang dibawa kemana-kemana tanpa harus install component tambahan):

unit Unit1;
interface
uses
  ExtCtrls,...;
type
  TXRadioGroup = class(TRadioGroup)
  private
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  end;
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
{ TXRadioGroup }
procedure TXRadioGroup.CMMouseEnter(var Message: TMessage);
begin
  Caption := 'Mouse Enter Radio Group!';
end;
procedure TXRadioGroup.CMMouseLeave(var Message: TMessage);
begin
  Caption := 'Mouse Leave Radio Group!';
end;
 { TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
  with TXRadioGroup.Create(Self) do
  begin
    Left := 10;
    Top  := 10;
    Parent := Self;
  end;
end;
end.
HTH
user image
more 10 years ago

Goen

Tambahan, Tolong dicek kalau TControl di Delphi ente ada protected property OnMouseEnter & OnMouseLeave. Kalau ada, ente gak perlu bikin message procedure baru buat nangkep Mouse saat masuk dan keluar. Karena, sudah dimiliki sama parentnya, TControl. Ente cukup override ke public scope aja biar bisa di assign sama parentnya (dalam hal ini, TForm). Ini lebih OOP, ketimbang bikin message procedure baru. Dari source di atas, ane modifikasi sedikit:

unit Unit1;
interface
uses
  Extctrls, ...;
type
  // Modifikasi Pertama
  TXRadioGroup = class(TRadioGroup)
  private
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  end;
  // Modifikasi Kedua
  TX2RadioGroup = class(TRadioGroup)
  public
    property OnMouseEnter;
    property OnMouseLeave;
  end;
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    procedure RadioGroupMouseEnter(Sender: TObject);
    procedure RadioGroupMouseLeave(Sender: TObject);
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
{ TXRadioGroup }
procedure TXRadioGroup.CMMouseEnter(var Message: TMessage);
begin
  Caption := 'Mouse Enter Radio Group!';
end;
procedure TXRadioGroup.CMMouseLeave(var Message: TMessage);
begin
  Caption := 'Mouse Leave Radio Group!';
end;
 { TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
  with TXRadioGroup.Create(Self) do
  begin
    Left := 10;
    Top  := 10;
    Parent := Self;
  end;
  with TX2RadioGroup.Create(Self) do
  begin
    Left := 100;
    Top  := 100;
    Parent := Self;
    OnMouseEnter := RadioGroupMouseEnter;
    OnMouseLeave := RadioGroupMouseLeave;
  end;
end;
procedure TForm1.RadioGroupMouseEnter(Sender: TObject);
begin
  TRadioGroup(Sender).Caption := 'Mouse Enter!';
end;
procedure TForm1.RadioGroupMouseLeave(Sender: TObject);
begin
  TRadioGroup(Sender).Caption := 'Mouse Leave!';
end;
end.
HTH
user image
more 10 years ago

bonny_rayfoxs

wah.. Makasih uda share mas.. gw nyoba dulu nih :D
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com