类似于VB的DROPDOWN控件 请问在 DELPHY 里面有没有 下拉控件可直接连数据库的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit RDBLookupComboBox;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DBCtrls;type TRDBLookupComboBox = class(TDBLookupComboBox) private { Private declarations } HiBkColorSaved:boolean; HiBkColor:TColor; MouseEntered: Boolean; procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE; procedure DrawFocused; procedure DrawUnfocus; procedure OnPaint(var Message: TWMPaint); message WM_PAINT ; procedure OnCreate(var Message: TWMCreate); message WM_CREATE; protected { Protected declarations } procedure DoEnter;override; procedure DoExit;override; end;procedure Register;implementation//const// ParentBkColor = $00F6FEFF;procedure Register;begin RegisterComponents('Ross', [TRDBLookupComboBox]);end;procedure TRDBLookupComboBox.OnCreate(var Message: TWMCreate);begin inherited; tag :=1;end;procedure TRDBLookupComboBox.DoEnter;begin inherited; DrawFocused;end;procedure TRDBLookupComboBox.DoExit;begin inherited; DrawUnfocus;end;procedure TRDBLookupComboBox.CMMouseEnter(var Message: TMessage);begin inherited; if not MouseEntered and Enabled then begin MouseEntered := True; DrawFocused; end;end;procedure TRDBLookupComboBox.CMMouseLeave(var Message: TMessage);begin inherited; if MouseEntered and Enabled then begin MouseEntered := False; DrawUnfocus; end;end;procedure TRDBLookupComboBox.DrawFocused;var DC: HDC; R: TRect; WindowBrush,b: HBRUSH;begin// if not(focused or mouseEntered) then exit; if not HiBkColorSaved then begin HiBkColor := color; HiBkColorSaved := true; end; color := ColorToRGB(HiBkColor); DC := GetWindowDC(Handle); GetWindowRect(Handle, R); OffsetRect(R, -R.Left, -R.Top); try// WindowBrush := CreateSolidBrush(getParentForm(self).color ); WindowBrush := CreateSolidBrush( ColorToRGB(Parent.Brush.Color) ); FrameRect(DC, R, WindowBrush); b := CreateSolidBrush(clOlive ); InflateRect(R, -1, -1); FrameRect(DC, R, b); finally ReleaseDC(Handle, DC); end; DeleteObject(WindowBrush); DeleteObject(b);end;procedure TRDBLookupComboBox.DrawUnfocus;var DC: HDC; R: TRect; WindowBrush,b: HBRUSH; //tc:TCustomForm;begin if focused or mouseEntered then exit; if not HiBkColorSaved then begin HiBkColor := color; HiBkColorSaved := true; end;// tc := getParentForm(self); if [csDesigning] <> ComponentState then color := ColorToRGB(parent.brush.color); DC := GetWindowDC(Handle); GetWindowRect(Handle, R); OffsetRect(R, -R.Left, -R.Top);// Dec(R.Right, 1); try WindowBrush := CreateSolidBrush(ColorToRGB(parent.Brush.Color )); FrameRect(DC, R, WindowBrush); InflateRect(R, -1, -1); FrameRect(DC, R, WindowBrush); R.Top := r.Bottom -1; b := CreateSolidBrush(clOlive ); FrameRect(DC, R, b); finally ReleaseDC(Handle, DC); end; DeleteObject(WindowBrush); DeleteObject(b);// color := getparentform(self).Color;end;procedure TRDBLookupComboBox.OnPaint(var Message: TWMPaint);begin inherited; if MouseEntered or Focused then DrawFocused else DrawUnfocus;end;end. DELPHI+SQL怎么做登陆? 调试VC动态库的问题? 如何释放窗体?? 我是个傻蛋对代码老不开窍,斑竹和高手们帮个忙吧! 如何把bmp图像文件转化为8位色图。 急!DELPHI开发的系统中调用DLL的问题! 怎样将数据加入到Quickrep中去的? 谁有用delphi做b/s结构程序的说明。 dephi开发ASP组件时,如何返回一个记录集? 怎样使用动态图标.ani文件? 怎么解决delphi与网上数据库连接慢的问题 cxGrid里的CardView能不能一次只显示一条记录?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBCtrls;type
TRDBLookupComboBox = class(TDBLookupComboBox)
private
{ Private declarations }
HiBkColorSaved:boolean;
HiBkColor:TColor;
MouseEntered: Boolean;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure DrawFocused;
procedure DrawUnfocus; procedure OnPaint(var Message: TWMPaint); message WM_PAINT ;
procedure OnCreate(var Message: TWMCreate); message WM_CREATE; protected
{ Protected declarations }
procedure DoEnter;override;
procedure DoExit;override;
end;procedure Register;implementation
//const
// ParentBkColor = $00F6FEFF;procedure Register;
begin
RegisterComponents('Ross', [TRDBLookupComboBox]);
end;procedure TRDBLookupComboBox.OnCreate(var Message: TWMCreate);
begin
inherited;
tag :=1;
end;
procedure TRDBLookupComboBox.DoEnter;
begin
inherited;
DrawFocused;
end;procedure TRDBLookupComboBox.DoExit;
begin
inherited;
DrawUnfocus;
end;procedure TRDBLookupComboBox.CMMouseEnter(var Message: TMessage);
begin
inherited;
if not MouseEntered and Enabled then begin
MouseEntered := True;
DrawFocused;
end;
end;procedure TRDBLookupComboBox.CMMouseLeave(var Message: TMessage);
begin
inherited;
if MouseEntered and Enabled then begin
MouseEntered := False;
DrawUnfocus;
end;
end;procedure TRDBLookupComboBox.DrawFocused;
var
DC: HDC;
R: TRect;
WindowBrush,b: HBRUSH;
begin
// if not(focused or mouseEntered) then exit;
if not HiBkColorSaved then
begin
HiBkColor := color;
HiBkColorSaved := true;
end;
color := ColorToRGB(HiBkColor); DC := GetWindowDC(Handle);
GetWindowRect(Handle, R);
OffsetRect(R, -R.Left, -R.Top);
try
// WindowBrush := CreateSolidBrush(getParentForm(self).color );
WindowBrush := CreateSolidBrush( ColorToRGB(Parent.Brush.Color) );
FrameRect(DC, R, WindowBrush); b := CreateSolidBrush(clOlive );
InflateRect(R, -1, -1);
FrameRect(DC, R, b); finally
ReleaseDC(Handle, DC);
end; DeleteObject(WindowBrush);
DeleteObject(b);
end;
procedure TRDBLookupComboBox.DrawUnfocus;
var
DC: HDC;
R: TRect;
WindowBrush,b: HBRUSH;
//tc:TCustomForm;
begin
if focused or mouseEntered then exit; if not HiBkColorSaved then
begin
HiBkColor := color;
HiBkColorSaved := true;
end;// tc := getParentForm(self);
if [csDesigning] <> ComponentState then
color := ColorToRGB(parent.brush.color);
DC := GetWindowDC(Handle); GetWindowRect(Handle, R);
OffsetRect(R, -R.Left, -R.Top);
// Dec(R.Right, 1);
try WindowBrush := CreateSolidBrush(ColorToRGB(parent.Brush.Color ));
FrameRect(DC, R, WindowBrush); InflateRect(R, -1, -1);
FrameRect(DC, R, WindowBrush); R.Top := r.Bottom -1; b := CreateSolidBrush(clOlive );
FrameRect(DC, R, b); finally
ReleaseDC(Handle, DC);
end;
DeleteObject(WindowBrush);
DeleteObject(b);// color := getparentform(self).Color;
end;procedure TRDBLookupComboBox.OnPaint(var Message: TWMPaint);
begin
inherited;
if MouseEntered or Focused then
DrawFocused
else
DrawUnfocus;
end;end.