shekou
asked on
How to display Tlistview hints
I am using Tlistview writing a report, my questions is how
to display differents hints when mouse point to differents rows.
Example:
Description Price where to buy
========= ========= ===========
Kodak DC210 USD 110.00 Ebay
Kodak DC220 USD 220.00 Ebay
Kodak DC230 USD 300.00 Ebay
.
.
.
When I use mouse point to Kodak DC210, I want to display
a full feature descriptions of Kodak DC210 as hints. and when
point to Kodak DC220, display Kodak DC220's features, and
when point to Kodak DC230, display Kodak DC230's features
How to do it? I am using Tlistview.
Thanks & Rgds
Shekou
to display differents hints when mouse point to differents rows.
Example:
Description Price where to buy
========= ========= ===========
Kodak DC210 USD 110.00 Ebay
Kodak DC220 USD 220.00 Ebay
Kodak DC230 USD 300.00 Ebay
.
.
.
When I use mouse point to Kodak DC210, I want to display
a full feature descriptions of Kodak DC210 as hints. and when
point to Kodak DC220, display Kodak DC220's features, and
when point to Kodak DC230, display Kodak DC230's features
How to do it? I am using Tlistview.
Thanks & Rgds
Shekou
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Shekou
I know :o( You will need to make a component (which inherits from TListView) to catch the mouseLeave message. If you dont know how to do this, I can probably guide you through.
Regards,
Pede
I know :o( You will need to make a component (which inherits from TListView) to catch the mouseLeave message. If you dont know how to do this, I can probably guide you through.
Regards,
Pede
ASKER
Please kindly guide me through.
Thanks & Rgds
Shekou
Thanks & Rgds
Shekou
Ok, to make a new component, do the following (this is with Delphi5, similar to Delphi3 and 4, if I remember correctly):
Select Component/New Component from the menu
Select (or type) TListView as ancestor type
As classname you type whatever you will like the class to be called. TMyListView or something...
Palette page is where you want the component to be placed, in the component palette (the 'Standard, Additional, Win32, System'-thing). You can leave it at samples, which I believe is default.
A unit filename will be suggested for you. It is probably a good idea to make a directory called 'components' or the like, where you place your own components.
Click install.
Chose 'Install into new package'
Type a packagename. A package can contain several components. You could name it MyPackage... You dont need to supply a description, but do it if you please.
Click ok
Your new component should be installed under 'Samples', and you should be able to see the source code for it.
I have added some code to give you the desired event:
unit MyListview;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls;
type
TMouseLeaveEvent = procedure(Sender: TObject) of object;
TMyListview = class(TListView)
private
FOnMouseLeave : TMouseLeaveEvent;
{ Private declarations }
protected
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
{ Protected declarations }
public
{ Public declarations }
published
property OnMouseLeave : TMouseLeaveEvent read FOnMouseLeave write FOnMouseLeave;
{ Published declarations }
end;
procedure Register;
implementation
procedure TMyListView.CMMouseLeave(v ar Message: TMessage);
begin
if Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
end;
procedure Register;
begin
RegisterComponents('Sample s', [TMyListView]);
end;
end.
You now need to compile the component again. There might be a package window open (is has 'Package' in the caption bar). Here you can click compile. If it is not open, chose Component/Install component, and install into existing package. Package filename is the name you chose earlier, I suggested 'MyPackage'. If you cant find it, search for the filename.
After this you can select it from 'Samples' and drop it on your form.
Phew... Im never going to be a teacher, I guess... This was harder to explain than I thought. Please read about components and packages in the help files. You wont regret it.
If you cant get it to work, let me know, but please give it a try first ;)
Regards,
Pede
Select Component/New Component from the menu
Select (or type) TListView as ancestor type
As classname you type whatever you will like the class to be called. TMyListView or something...
Palette page is where you want the component to be placed, in the component palette (the 'Standard, Additional, Win32, System'-thing). You can leave it at samples, which I believe is default.
A unit filename will be suggested for you. It is probably a good idea to make a directory called 'components' or the like, where you place your own components.
Click install.
Chose 'Install into new package'
Type a packagename. A package can contain several components. You could name it MyPackage... You dont need to supply a description, but do it if you please.
Click ok
Your new component should be installed under 'Samples', and you should be able to see the source code for it.
I have added some code to give you the desired event:
unit MyListview;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls;
type
TMouseLeaveEvent = procedure(Sender: TObject) of object;
TMyListview = class(TListView)
private
FOnMouseLeave : TMouseLeaveEvent;
{ Private declarations }
protected
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
{ Protected declarations }
public
{ Public declarations }
published
property OnMouseLeave : TMouseLeaveEvent read FOnMouseLeave write FOnMouseLeave;
{ Published declarations }
end;
procedure Register;
implementation
procedure TMyListView.CMMouseLeave(v
begin
if Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
end;
procedure Register;
begin
RegisterComponents('Sample
end;
end.
You now need to compile the component again. There might be a package window open (is has 'Package' in the caption bar). Here you can click compile. If it is not open, chose Component/Install component, and install into existing package. Package filename is the name you chose earlier, I suggested 'MyPackage'. If you cant find it, search for the filename.
After this you can select it from 'Samples' and drop it on your form.
Phew... Im never going to be a teacher, I guess... This was harder to explain than I thought. Please read about components and packages in the help files. You wont regret it.
If you cant get it to work, let me know, but please give it a try first ;)
Regards,
Pede
ASKER
Great!
Thank you very much
Shekou
Thank you very much
Shekou
pede,
I just tried your MouseLeave solution however I can't seem to get the notification. I copied your unit and instructions exactly.
Thanks,
I just tried your MouseLeave solution however I can't seem to get the notification. I copied your unit and instructions exactly.
Thanks,
Hi Johnn
I know this works, so I dont know why you cant get it to work.
If you can give me some more details, maybe we can solve it.
Was the component installed properly? If you can select it from samples, then it is installed.
Does it have the new event, MouseLeave?
Regards,
Pede
I know this works, so I dont know why you cant get it to work.
If you can give me some more details, maybe we can solve it.
Was the component installed properly? If you can select it from samples, then it is installed.
Does it have the new event, MouseLeave?
Regards,
Pede
ASKER
Thanks & Rgds
Shekou