ColCombo enhancements

I've made a couple of enhancements to colcombo that you might want to consider for future versions.

  1. Showlookup, when edit field is -1 showlookup now shows lookup text as underline in lookup column
  2. Showlookup now showing proper case compared to data in lookup column
  3. Added lookupdelay timer to prevent onchange event handler from firing until no keypress for x miliseconds so lookups can complete before onchange events that may be database or process intensive fire.
  4. Clearing FLookup onchange
  5. Add onchange on enterkey press on lookup

I've attached the source here. I'm not an VCL control expert so you may find more optimal ways to handle codewise.
colcombo.pas (66.3 KB)

Thanks for these enhancement suggestions. We'll investigate & sync where possible.

We can confirm these will be integrated in the next release. In addition we added properties to control display of Lookup in the edit part (LookupUnderline, LookupBkColor, LookupTextColor)

Thank you Bruno,

Can't wait to see updates.

Hi Bruno, Just installed the latest version and its great to see the new functionality for ColumnCombo. I did have 1 issue with the LookupBKColor and LookupTextColor and I'm not sure if it is a Delphi 11 issue or not. When setting the LookupBkColor or LookupTextColor to clNone in the IDE for the column controls when saving the form the reference to LookupBkColor and LookupTextColor is removed from the DFM file. The assumption is that since the default for these properties are clNone the IDE is removing them on save. With these properties removed and on compile the code is setting the values of these properties to 0 instead of clNone (which is $1FFFFFFF). This was making both the text and background colors black.

I put the following in the TColumnComboBox.Create function

LookupBkColor := clNone;
LookupTextColor := clNone;

which fixed the issue.

Thanks for reporting. We applied this improvement. It will be included in the next update.

Hi Bruno,

Wanted to reply to this thread about the colcombo lookup. I found an issue with using the ESC key while doing an incremental lookup, the underlying record is changed but the OnChange event isn't firing if you hit escape. Leaving the pulldown with a new value but any code running on OnChange not firing. Could you please change the following code in the ColCombo WMChar function around line 1984 and add Key #27 in to the Key = #13 code in that same area.

if Key in [#13,#27] then
begin
if Assigned(Onchange) then Onchange(self);
FLookup := '';
Exit;
end;

Thanks,
Rich

Thanks, we'll integrate this improvement in the next release

Found one more issue. If the colcombo is in dropdown state and you use the up or down arrows to switch entries, then click out of the control the selection changes but the onchange event does fire. I think it has to do with the if Assigned(OnChange) then Onchange(Self) code being within the if not bool(SendMessage(Handle,CB_GETDROPPEDSTATE,0,0)) then segment where it should be outside that if.

Updated CNCommand function to address:

procedure TColumnComboBox.CNCommand(var Message: TWMCommand);
begin
case Message.NotifyCode of
CBN_DROPDOWN:
begin
DropDown;
AdjustDropDown;
MoveWindow(Handle,Left,Top,Width,EditHeight + FDropheight,True);
FItemIndex := SendMessage(Handle,CB_GETCURSEL,0,0);
FDropped := True;
message.Result := 0;
end;

CBN_SELCHANGE:
begin
if FDisableSelChange then
inherited
else
begin
FDropped := False;

    FItemIndex := SendMessage(self.Handle,CB_GETCURSEL,0,0);

    if not bool(SendMessage(Handle,CB_GETDROPPEDSTATE,0,0)) then
    begin

      FLookup := '';
      if Assigned(OnClick) then
      begin
        OnClick(Self);
      end;

    end;

// Invalidate;
Refresh;
end;
if Assigned(OnChange) then OnChange(Self);

  if Assigned(OnSelect) then
  begin
    OnSelect(Self);
  end;

  message.Result := 0;
end;

else
inherited;
end;
end;

You're correct about this and we will apply the suggested improvement.