Board index » delphi » TComboBox OwnerDraw->Other Style Focus problem

TComboBox OwnerDraw->Other Style Focus problem

Hi,
Sorry the header isn't a little more clearer describing what I am talking
about.

I have a combobox, which I am doing owner draw fixed style. I am drawing
some text with color behind it.
When my user selects an item, I toggle the style to drop down so that the
user can type something in the combo boxes edit control.

The only problem is that after the user has selected the item in the combo
box, I can't seem to get it to focus on it. That is type in anything in the
edit control, all it does is beep.

Here's
procedure TForm1.cmboClick(Sender: TObject);
var
  selStr: string;
begin
  SelStr := Cmbo.Items[Cmbo.ItemIndex];

// First 4 items we let them pick a color, but they cannot edit it. Anything
after 4 the cmbo should become editable.
  if Cmbo.ItemIndex > 4

    Cmbo.Style := csDropDown;
  else
    Cmbo.Style := csOwnerDrawFixed;

end;

I suspect that there is some issue I need to handle since the control's
window is being recreated when you toggle the style.

Is there some win proc I need to handle?

thanks for any tips and your help in advance,

Sincerely,

John  Scalco

 

Re:TComboBox OwnerDraw->Other Style Focus problem


Quote
In article <3bd96875$1_1@dnews>, John Scalco wrote:
> I have a combobox, which I am doing owner draw fixed style. I am drawing
> some text with color behind it.
> When my user selects an item, I toggle the style to drop down so that the
> user can type something in the combo boxes edit control.

Ouch <g>. I would rather place a genuine edit control on top of the comboboxes
fixed portion in this case. Hide it again when its OnExit event fires.

Quote
> The only problem is that after the user has selected the item in the combo
> box, I can't seem to get it to focus on it. That is type in anything in the
> edit control, all it does is beep.
> I suspect that there is some issue I need to handle since the control's
> window is being recreated when you toggle the style.

The problem may be that you do this style change from inside a method that is
triggered by a message send to the control you change. So try to delay the
style change until the message processing has completed. post a user message
to the form and change the style in the message handler.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Other Threads