Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 TCombobox drop down size.


How can I tell the actual size of a TComboBox in it's dropped down state before it drops down?   

    During the FormShow event, send the combo box a CB_SHOWDROPDOWN message twice, once to drop it down, and once to retract it. Then send a CB_GETDROPPEDCONTROLRECT message, passing the address of a TRect. When the SendMessage call returns, the TRect will contain the rectangle that would enclose the ComboBox in it's dropped down state, relative to the screen. You can then call ScreenToClient to convert the TRect's coordinates to be relative to the client area of the form.

    Example:

    var R : TRect;

    procedure TForm .FormShow(Sender: TObject); var T : TPoint; begin SendMessage(ComboBox .Handle, CB_SHOWDROPDOWN, , 0); SendMessage(ComboBox .Handle, CB_SHOWDROPDOWN, 0, 0); SendMessage(ComboBox .Handle, CB_GETDROPPEDCONTROLRECT, 0, LongInt(@r)); t := ScreenToClient(Point(r.Left, r.Top)); r.Left := t.x; r.Top := t.y; t := ScreenToClient(Point(r.Right, r.Bottom)); r.Right := t.x; r.Bottom := t.y; end;

    procedure TForm .Button Click(Sender: TObject); begin Form .Canvas.Rectangle(r.Left, r.Top, r.Right, r.Bottom ); end; 7/ 6/98 4:3 :28 PM

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use