TSelect

 

unit uSelect;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FindDM, Grids, DBGrids, ExtCtrls, StdCtrls, Buttons, DB;

type
  TSelect = class(TForm)
    TFindFrames1: TFindFrames;
    DBGrid1: TDBGrid;
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    DataSource1: TDataSource;
  private
    { Private declarations }
  public
    { Public declarations }
    FDataSet: TDataSet;
  end;

procedure Execute(DataSet: TDataSet);

var
  Select: TSelect;

implementation

{$R *.dfm}

procedure AdjustDropDownForm(AControl: TControl);  //设置下拉窗口位置。
var
  WorkArea: TRect;
  HostP, PDelpta: TPoint;
begin
  SystemParametersInfo(SPI_GETWORKAREA, 0, @WorkArea, 0);
  GetCursorPos(HostP); //根据点击的鼠标位置决定显示的位置
  PDelpta := AControl.ClientToScreen(Point(0, 0));
  AControl.Left := HostP.x - 2;
  AControl.Top := HostP.y - 3;
  if (AControl.Width > WorkArea.Right - WorkArea.Left) then
    AControl.Width := WorkArea.Right - WorkArea.Left;
  if (AControl.Left + AControl.Width > WorkArea.Right) then
    AControl.Left := WorkArea.Right - AControl.Width;
  if (AControl.Left < WorkArea.Left) then
    AControl.Left := WorkArea.Left;
  if (AControl.Top + AControl.Height > WorkArea.Bottom) then
  begin
    if (HostP.y - WorkArea.Top > WorkArea.Bottom - HostP.y ) then
      AControl.Top := HostP.y - AControl.Height;
  end;
  if (AControl.Top < WorkArea.Top) then
  begin
    AControl.Height := AControl.Height - (WorkArea.Top - AControl.Top);
    AControl.Top := WorkArea.Top;
  end;
  if (AControl.Top + AControl.Height > WorkArea.Bottom) then
  begin
    AControl.Height := WorkArea.Bottom - AControl.Top;
  end;
end;

procedure Execute(DataSet: TDataSet);
begin
  if DataSet = nil then Exit;
  if DataSet.IsEmpty then Exit;
  Select := TSelect.Create(Application);
  Select.FDataSet := DataSet;
  Select.DataSource1.DataSet := Select.FDataSet;
  Select.TFindFrames1.DataSet := Select.FDataSet;
  AdjustDropDownForm(Select);
  try
    Select.ShowModal;
  finally
    FreeAndNil(Select);
  end;
end;

end.

转载于:https://www.cnblogs.com/hnxxcxg/archive/2011/09/05/2940587.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值