Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to simulate combobox behavior with a TEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Aug-02
Category
VCL-General
Language
Delphi All Versions
Views
99
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I'm trying to make a component that acts in certain cases like a combobox, i.e. 
when the user presses a button, a list box is shown and the user can select an 
item. The problem I have is that I need the list to hide itself whenever the user 
clicks the mouse outside the list (including clicks in non-windowed controls).

Answer:

One way you can do this is by listening for CM_CANCELMODE messages in the parent of 
your drop-down list (presumably an edit control or something similar). You will 
probably then have to work out whether the message originated from a click on the 
drop-down list or elsewhere. In the code below, FPopup points to the list component:
1   
2   procedure TMyPopupEdit.CMCancelMode(var message: TCMCancelMode);
3   var
4     P: TPoint;
5     R: TRect;
6   begin
7     {Get the top-left coordinate of the Sender and see if it is within the popup
8     control. If not, close the popup without changing the text in the edit box.}
9     P.X := message.Sender.Left;
10    P.Y := message.Sender.Top;
11    R := Rect(0, 0, FPopup.Width, FPopup.Height);
12    if not PtInRect(R, P) then
13      if FPopupVisible then
14        PopupCloseUp(FPopup, False);
15  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC