Board index » delphi » making left click and right click equal?

making left click and right click equal?

I have a listbox with a popup menu that is displayed when you right click on
the list box.  What I want to make happen is when the user right clicks on an
item in the list box it not only displayes the popup menu but also selectes
that item in the list box.  I'm totaly stuck...any suggestions?

-david

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

 

Re:making left click and right click equal?


In article <7bfdti$j3...@nnrp1.dejanews.com>,

Quote
  djo...@walcoff.com wrote:
> I have a listbox with a popup menu that is displayed when you right click on
> the list box.  What I want to make happen is when the user right clicks on an
> item in the list box it not only displayes the popup menu but also selectes
> that item in the list box.  I'm totaly stuck...any suggestions?

I'm not where I can try it, but I think there's an OnPopup event for the
popup menu. When it fires, you can calculate which item the mouse is over
from its vertical position in the list box, the top item displayed in the
box, and the itemheight. Then you can set listbox.itemindex accordingly--that
should serve to select the item.

Another approach might be to send a Windows message that indicates the left
mouse button has been clicked, followed by one indicating it's been released.
I don't recall which message it is, but if you check Delphi help for the
Messages unit, you'll get a list of those to pick from. Something like
WM_LMBHITTEST, I think.

Elliott

"I don't want to achieve immortality through my work. I want to achieve
it by not dying." -- Woody Allen

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Re:making left click and right click equal?


In article <7bfdti$j3...@nnrp1.dejanews.com>,

Quote
  djo...@walcoff.com wrote:
> I have a listbox with a popup menu that is displayed when you right click on
> the list box.  What I want to make happen is when the user right clicks on an
> item in the list box it not only displayes the popup menu but also selectes
> that item in the list box.  I'm totaly stuck...any suggestions?

I'm not where I can try it, but I think there's an OnPopup event for the
popup menu. When it fires, you can calculate which item the mouse is over
from its vertical position in the list box, the top item displayed in the
box, and the itemheight. Then you can set listbox.itemindex accordingly--that
should serve to select the item.

Another approach might be to send a Windows message that indicates the left
mouse button has been clicked, followed by one indicating it's been released.
I don't recall which message it is, but if you check Delphi help for the
Messages unit, you'll get a list of those to pick from. Something like
WM_LMBHITTEST, I think.

Elliott

"I don't want to achieve immortality through my work. I want to achieve
it by not dying." -- Woody Allen

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Other Threads