procedure TDBLookupComboPlus.WMPaint(
var Message: TWMPaint);
var
{$IFNDEF Win32}
S:
array[0..255]
of Char;
{$ELSE}
S : Variant;
//String;
{$ENDIF}
PS: TPaintStruct;
ARect: TRect;
TextLeft, TextTop: Integer;
Focused: Boolean;
DC: HDC;
Metrics : TTextMetric;
{new 1/23/96}
begin
if (Editable
or (fstyle = csIncSearch))
and (Text <> '
')
{$IFDEF Win32}
and not (csPaintCopy
in ControlState)
{$ENDIF}
then
begin
inherited;
Exit;
end;
{ if not editable with focus, need to do drawing to show proper focus }
if FCanvas =
nil then
begin
FCanvas := TControlCanvas.Create;
FCanvas.Control := Self;
end;
DC :=
Message.DC;
if DC = 0
then DC := BeginPaint(
Handle, PS);
FCanvas.Handle :=
DC;
try
Focused := (GetFocus =
Handle)
{$IFDEF Win32}and not(csPaintCopy
in ControlState)
{$ENDIF};
FCanvas.Font := Font;
with FCanvas
do
begin
ARect := ClientRect;
if (BorderStyle = bsSingle)
then
begin
Brush.Color := clWindowFrame;
{$IFNDEF Win32}
FrameRect(ARect);
{ draw the border }
{$ENDIF}
InflateRect(ARect, -1, -1);
end;
if not (Editable
or (fstyle = csIncSearch))
or
((Text = '
')
and (fstyle = csIncSearch))
{$IFDEF Win32}
or (csPaintCopy
in ControlState)
{$ENDIF}
then
begin
Brush.Style := bsSolid;
{fill the recttangle inside the boarder with color}
Brush.Color := Color;
FillRect (ARect);
if (BorderStyle = bsSingle)
then
TextTop := FTopTextMargin
else {bsNone}
TextTop := FTopTextMargin;
if ShowSpeedButton
then
ARect.Right := FBtnControl.Left - 1
else
ARect.Right := ClientWidth - 2;
{new 1/21/96 Deven report added '- 2'}
{$IFNDEF Win32}
StrPCopy (S, Text);
{$ENDIF}
TextLeft := FLeftTextMargin;
if Focused
then {draw the focus rectangle}
begin
Brush.Color := clHighlight;
Font.Color := clHighlightText;
ARect.Top := ARect.Top + FTopTextMargin;
{} GetTextMetrics(FCanvas.Handle, Metrics);
{new 1/23/96}
ARect.Bottom := ARect.Top + Metrics.tmHeight;
end;
{$IFDEF Win32}
{CtlGrid} if (csPaintCopy
in ControlState)
and (FFieldLink.Field <>
nil)
and
{CtlGrid} (LookupSource <>
nil)
then
{CtlGrid} begin
{CtlGrid} If (LookupField = LookupDisplay)
or (FFieldLink.Field.DisplayText = '
')
then {don't do the lookup if not necessary}
{CtlGrid} S := FFieldLink.Field.DisplayText
{CtlGrid} else
{CtlGrid} S := LookupSource.DataSet.Lookup(LookupField, FFieldLink.Field.DisplayText,
{CtlGrid} LookupDisplay);
{CtlGrid} If VarIsNull(S)
then
{CtlGrid} S := '
'
{CtlGrid} else if not VarIsEmpty(S)
then S := '
';
{CtlGrid} ExtTextOut(FCanvas.Handle, TextLeft, TextTop, ETO_OPAQUE
or ETO_CLIPPED, @ARect,
{CtlGrid} PChar(
String(S)), Length(
String(S)),
nil);
{CtlGrid} end
{CtlGrid} else
ExtTextOut(FCanvas.Handle, TextLeft, TextTop, ETO_OPAQUE
or ETO_CLIPPED, @ARect,
PChar(Text), Length(Text),
nil);
{$ELSE}
ExtTextOut(FCanvas.Handle, TextLeft, TextTop, ETO_OPAQUE
or ETO_CLIPPED, @ARect,
S, StrLen(S),
nil);
{$ENDIF}
If assigned(FBtnControl)
then FBtnControl.refresh;
if Focused
then
DrawFocusRect (ARect);
end;
end;
finally
FCanvas.Handle := 0;
if Message.DC = 0
then EndPaint(
Handle, PS);
end;
end;