Board index » delphi » owner-draw combo box w/ manual edit

owner-draw combo box w/ manual edit

I'm trying to build an owner-draw combo box where the user can also edit the
text in the editbox directly, but I'm having some trouble.

Once I set the style to OwnerDrawFixed, I lose the "manual edit" capability;
i.e., the user is unable to edit the text directly, but instead is forced to
select one of the items in the drop-down

How can I do an owner-draw and keep the manual edit?

Thanks in advance,

Nandan Kalle
--

Q U E S T   F I N A N C I A L   S E R V I C E S
The premier financial modeling company

Nandan Kalle
Principal
T 212.242.6686 * F 212.308.0010 * E nka...@questfs.com *
http://www.questfs.com

 

Re:owner-draw combo box w/ manual edit


Quote
> I'm trying to build an owner-draw combo box where the user can also edit the
> text in the editbox directly, but I'm having some trouble.

> Once I set the style to OwnerDrawFixed, I lose the "manual edit" capability;
> i.e., the user is unable to edit the text directly, but instead is forced to
> select one of the items in the drop-down

> How can I do an owner-draw and keep the manual edit?

Nandan,

you cannot, a owner-drawn combo box acts like a combo with csDropDownList
style. This is a Windows limitation, not a Delphi one. You have to build a
combobox workalike, or find one (i'm sure you can find something on one of the
sites below). If you have the VCL source, look at the implementation if
TDBLookupCOmbobox, that is such a workalike, not owner-drawn, however.

Delphi Super Page       http://sunsite.icm.edu.pl/delphi/
  US mirror site:       http://www.cdrom.com/pub/delphi_www/
  German mirror :        
http://ftp.uni-erlangen.de/pub/source/MIRRORS/sunsite.icm.edu.pl/pub/...
Torry's Delphi Pages    http://www.torry.ru/  
The Delphi EXchange     http://www.delphiexchange.com/

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Re:owner-draw combo box w/ manual edit


Peter & Nandan,

I have managed to create an editable owner-draw combo box. I create a
class, say TMyConbo,  derived from TComboBox, and over-ride the following
methods.

procedure TMyCombo.Create
  Style := csDropDown;  // This makes it editable

procedure TMyCombo.CreateParams
  Params.Style := Params.Style or CBS_OWNERDRAWFIXED;  // This makes it
owner-drawn

procedure TMyCombo.DrawItem
  with Canvas do
  if DroppedDown then
       // draw Combo item for list box part
  else
      // draw Combo item for edit box part

It works for me.

Regards,
Edward Benson

Peter Below <100113.1...@compuserve.com> wrote in article

Quote

> you cannot, a owner-drawn combo box acts like a combo with csDropDownList
> style. This is a Windows limitation, not a Delphi one. You have to build
a
> combobox workalike, or find one (i'm sure you can find something on one
of the
> sites below). If you have the VCL source, look at the implementation if
> TDBLookupCOmbobox, that is such a workalike, not owner-drawn, however.

Other Threads