Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get an item of a dblookuplist at mouseover?

Status
Not open for further replies.

otalens

IS-IT--Management
Apr 6, 2001
13
NL
Hi,

I want to get the item of a dblookuplist to show in a statusbar or
Hint at the moment I move the cursor over the control.
I was able to do it using other controls like TListbox, TCombobox and
TDBListbox, but I can't get it to work for lookup controls.

The code I use for the other controls is:

procedure TfrmPB_Wizard.ShowComboboxItemText(sender: TObject; var
Done: Boolean);
var
pt: TPoint;
wnd: HWND;
buf: array[0..128] of Char;
i: Integer;

begin
GetCursorPos(pt);
wnd := WindowFromPoint( pt );
buf[0] := #0;
if wnd <> 0 then
begin
Getclassname( wnd, buf, sizeof(buf));

//Check if control is combobox
if StrIComp(buf, 'ComboLBox') = 0 then
begin
Windows.ScreenToClient( wnd, pt );
i:= SendMessage( wnd, LB_ITEMFROMPOINT, 0,lparam(
PointToSmallPoint(pt)));
if i >= 0 Then
begin
sendmessage( wnd, LB_GETTEXT, i, integer(@buf));
//Show in statusbar
PBStatusBar.Panels[0].text := buf;
Exit;
end;
end;
end;
//Clear statusbar
PBStatusBar.Panels[0].text := '';
end;

I call this procedure by an Application OnIdle event.

Can anybody help me to use it in a lookup control?

Thanks,


Regards,

Oliver Talens
*****************************
Abyss I.T. Solutions
Mathildastraat 36B
4901 HC Oosterhout


tel: +31 (0)162-439809
fax: +31 (0)162-439882
O.Talens@Abyss.nl
*****************************
 
Have you tried using the TApplication.onHint event.

Have a look at the delphi help for TApplication.onHelp and in here you could write your code to 'get the item' depending upon the control type, Maybe using TWinControl from which all the controls you are intersted in are inherited from?


X-) Billy H

bhogar@acxiom.co.uk
 
You could use the forms ControlAtPos function to get a TControl at the position, and then do something like

someControl := ControlAtPos(pt, false);
if someControl is TDBLookupComboBox then
begin
PBStatusBar.Panels[0].text := TDBLookupComboBox(someControl).Text;
end; TealWren
 
I can get the control. That is not the problem. The problem is how to get the Item within the control...

Regards,

Oliver Talens
*****************************
Abyss I.T. Solutions
Mathildastraat 36B
4901 HC Oosterhout


tel: +31 (0)162-439809
fax: +31 (0)162-439882
O.Talens@Abyss.nl
*****************************
 
The text property doesn't return the item you're looking for? TealWren
 
A lookupcontrol does not have a text property. Even if it should have one, it would only return the selected item.
Regards,

Oliver Talens
*****************************
Abyss I.T. Solutions
Mathildastraat 36B
4901 HC Oosterhout


tel: +31 (0)162-439809
fax: +31 (0)162-439882
O.Talens@Abyss.nl
*****************************
 
That's what I thought you were looking for, the selected item? According to the source there is a DisplayValue property that you might be able to use. It's public so it should be available. TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top