vcdcx.pas

来自「一个关于VCD销售的系统」· PAS 代码 · 共 345 行

PAS
345
字号
unit vcdcx;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Menus, ComCtrls, ToolWin, Buttons, StdCtrls, AppEvnts,
  LabelButton, TradeImage, MaskImageButton, MoveImageButton, DB, DBCtrls,
  Grids, DBGrids;

type
  Tfrm_vcdcx = class(TForm)
    palUp: TPanel;
    palLeftUp: TPanel;
    imgLeftUp: TImage;
    palRightUp: TPanel;
    imgRightUp: TImage;
    palUpMid: TPanel;
    imgCaption: TImage;
    palDown: TPanel;
    imgLeftDown: TImage;
    imgRightDown: TImage;
    imgDownMin: TImage;
    palLeft: TPanel;
    palRight: TPanel;
    imgRight: TImage;
    imgCloseButton: TImage;
    imgMinButton: TImage;
    imgSizeButton: TImage;
    imgMaxButton: TImage;
    imgRestoreButton: TImage;
    imgSysIcon: TImage;
    popSystemMenu: TPopupMenu;
    N_Restore: TMenuItem;
    N_Max: TMenuItem;
    N_Min: TMenuItem;
    N_Move: TMenuItem;
    N_Size: TMenuItem;
    N_Speater: TMenuItem;
    N_Close: TMenuItem;
    palClient: TPanel;
    lbCaption: TLabel;
    CoolBarMenu: TCoolBar;
    ToolBarMenu: TToolBar;
    imgLeft: TImage;
    imgColorLeftUp: TImage;
    imgGrayCaption: TImage;
    imgGrayMenuBar: TImage;
    imgGrayRightUp: TImage;
    imgColorCaption: TImage;
    imgGrayLeftUp: TImage;
    imgColorRightUp: TImage;
    imgRightUp1: TImage;
    imgLeftUp1: TImage;
    imgColorMenubar: TImage;
    cxtj: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    e_lbx: TComboBox;
    e_lbd: TComboBox;
    e_name: TEdit;
    e_dy: TEdit;
    e_zy: TEdit;
    DataSource1: TDataSource;
    GroupBox1: TGroupBox;
    DBGrid1: TDBGrid;
    b_cx: TMoveImgBtn;
    b_exit: TMoveImgBtn;
    blabel_cx: TLabelBtn;
    blabel_exit: TLabelBtn;
    procedure imgMinButtonClick(Sender: TObject);
    procedure imgSizeButtonClick(Sender: TObject);
    procedure imgCloseButtonClick(Sender: TObject);
    procedure imgCaptionMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure imgCaptionMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure imgCaptionMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);
    procedure imgSysIconMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure popSystemMenuPopup(Sender: TObject);
    procedure N_SizeClick(Sender: TObject);
    procedure N_MoveClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure b_cxClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure b_exitClick(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
    canmove:boolean;
    curPoint:TPoint;
    oldPoint:TPoint;
    Canvas:TCanvas;
  protected
    procedure CreateParams(var Params:TCreateParams);override;
    procedure WMActivate(var Msg:TWMACTIVATE); message WM_ACTIVATE;
  public
    { Public declarations }
  end;

var
  frm_vcdcx: Tfrm_vcdcx;

implementation

uses datam;

{$R *.dfm}

procedure Tfrm_vcdcx.CreateParams(var Params:TCreateParams);
begin
  inherited CreateParams(Params);
  if BorderStyle<>bsNone then
    Params.Style :=WS_THICKFRAME or WS_POPUP or WS_BORDER;
end;

procedure Tfrm_vcdcx.imgMinButtonClick(Sender: TObject);
begin
  if Application.MainForm =self then
    Application.Minimize
  else
    DefWindowProc(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;

procedure Tfrm_vcdcx.imgSizeButtonClick(Sender: TObject);
begin
  if self.WindowState = wsNormal then
  begin
    DefWindowProc(Handle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
    imgSizeButton.Picture :=imgRestoreButton.Picture;
  end
  else
  begin
    DefWindowProc(Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
    imgSizeButton.Picture :=imgMaxButton.Picture;
  end;

end;

procedure Tfrm_vcdcx.imgCloseButtonClick(Sender: TObject);
begin
  DefWindowProc(Handle, WM_SYSCOMMAND, SC_CLOSE, 0);
end;

procedure Tfrm_vcdcx.imgCaptionMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if (Button=mbLeft)and(ssLeft in Shift)then
  begin
    canmove:=true;
    Canvas:=TCanvas.Create;
    with Canvas do
    begin
      pen.Style :=psdot;
      brush.Style :=bsClear;
      pen.Width :=2;
      Pen.Mode :=pmNotXor;
      Handle :=GetDC(0);
      Rectangle(left,top,Left+width,top+height);
      curPoint.X :=X;
      curPoint.Y :=Y;
      oldPoint.X :=Left;
      oldPoint.Y :=Top;
    end;        //end with
  end;  //end if
end;

procedure Tfrm_vcdcx.imgCaptionMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  if not canmove then exit;
  with Canvas do
  begin
    Rectangle(oldPoint.x,oldPoint.y,oldPoint.x+Width,oldPoint.y+Height);
    oldPoint.x :=Left +X-curPoint.x;
    oldPoint.y :=Top +Y-curPoint.y;
    Rectangle(oldPoint.x,oldPoint.y,oldPoint.x+Width,oldPoint.y+Height);
  end;
end;

procedure Tfrm_vcdcx.imgCaptionMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if not canmove then exit;
  with Canvas do
  begin
    Rectangle(oldPoint.x,oldPoint.y,oldPoint.x+Width,oldPoint.y+Height);
    Left :=oldPoint.x;
    Top :=oldPoint.y;
    Free;
  end;
  canmove:=not canmove;
end;

procedure Tfrm_vcdcx.FormCreate(Sender: TObject);
begin
  lbCaption.Caption :=Caption;
  dm.ado_lb.open;
  dm.ADO_lb.Sort:='编号';
  e_lbx.Items.Add('所有');
  while not dm.ado_lb.Eof do
    begin
     e_lbx.items.add(dm.ADO_lb.fieldbyname('类别').AsString);
     dm.ADO_lb.Next;
    end;
    dm.ado_lb.close;
    e_lbx.ItemIndex:=0;
end;

procedure Tfrm_vcdcx.imgSysIconMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  PopSystemMenu.Popup(Left+ImgSysIcon.Left,Top+ImgSysIcon.Top+ImgSysIcon.Height);
end;

procedure Tfrm_vcdcx.popSystemMenuPopup(Sender: TObject);
begin

  N_Restore.Enabled :=imgSizeButton.Visible and (WindowState =wsMaximized);
  N_Max.Enabled :=imgSizeButton.Visible and (WindowState =wsNormal);
  N_Size.Enabled :=imgSizeButton.Visible ;
  n_min.Enabled:=imgMinButton.Visible;
end;

procedure Tfrm_vcdcx.N_SizeClick(Sender: TObject);
begin
  DefWindowProc(Handle, WM_SYSCOMMAND, SC_SIZE, 0);
end;

procedure Tfrm_vcdcx.N_MoveClick(Sender: TObject);
begin
  DefWindowProc(Handle, WM_SYSCOMMAND, SC_MOVE, 0);
end;

procedure Tfrm_vcdcx.FormShow(Sender: TObject);
begin
  if WindowState=wsNormal then
    imgSizeButton.Picture.Bitmap :=imgMaxButton.Picture.Bitmap
  else if WindowState=wsMaximized then
    imgSizeButton.Picture.Bitmap :=imgRestoreButton.Picture.Bitmap;
  e_name.SetFocus();  
end;

procedure Tfrm_vcdcx.WMActivate(var Msg: TWMACTIVATE);
begin
  if (Msg.Active =WA_ACTIVE) or (Msg.Active =WA_CLICKACTIVE) then
  begin
    imgCaption.Picture.Bitmap :=imgColorCaption.Picture.Bitmap;
    imgLeftUp1.Picture.Bitmap :=imgColorLeftUp.Picture.Bitmap;
    imgRightUp1.Picture.Bitmap :=imgColorRightUp.Picture.Bitmap;
    coolBarMenu.Bitmap :=imgColorMenubar.Picture.Bitmap;
  end
  else begin
    imgCaption.Picture.Bitmap :=imgGrayCaption.Picture.Bitmap;
    imgLeftUp1.Picture.Bitmap :=imgGrayLeftUp.Picture.Bitmap;
    imgRightUp1.Picture.Bitmap :=imgGrayRightUp.Picture.Bitmap;
    coolBarMenu.Bitmap :=imgGrayMenubar.Picture.Bitmap;
  end;
end;

procedure Tfrm_vcdcx.Button1Click(Sender: TObject);
var
 cxtj:string;
begin
 if e_lbd.Text<>'所有' then
   cxtj:=cxtj+'大类='+'"'+e_lbd.Text+'"';
 if e_lbx.Text<>'所有' then
   cxtj:=cxtj+' and '+'小类='+'"'+e_lbx.Text+'"';
 if e_name.Text<>'' then
   cxtj:=cxtj+' and '+'名称 like'+'"'+'%'+e_name.Text+'%'+'"';
 if e_dy.Text<>'' then
   cxtj:=cxtj+' and '+'作者导演 like'+'"'+'%'+e_dy.Text+'%'+'"';
 if e_zy.Text<>'' then
   cxtj:=cxtj+' and '+'主演 like'+'"'+'%'+e_zy.Text+'%'+'"';
 if copy(trim(cxtj),1,3)='and' then
    cxtj:=copy(trim(cxtj),4,500);
    cxtj:='where '+cxtj;
 if cxtj='where ' then
    cxtj:='';
  dm.adoq_cx.close;
  dm.adoq_cx.SQL.Clear;
  dm.adoq_cx.sql.add('select 货位号,状态,大类,小类,名称,作者导演,主演 from tsvcd');
  dm.adoq_cx.sql.add(cxtj);
  dm.ADOQ_cx.ExecSQL;
  dm.ADOQ_cx.Close;
  dm.ADOQ_cx.Open;
end;

procedure Tfrm_vcdcx.b_cxClick(Sender: TObject);
var
 cxtj:string;
begin
 if e_lbd.Text<>'所有' then
   cxtj:=cxtj+'大类='+'"'+e_lbd.Text+'"';
 if e_lbx.Text<>'所有' then
   cxtj:=cxtj+' and '+'小类='+'"'+e_lbx.Text+'"';
 if e_name.Text<>'' then
   cxtj:=cxtj+' and '+'名称 like'+'"'+'%'+e_name.Text+'%'+'"';
 if e_dy.Text<>'' then
   cxtj:=cxtj+' and '+'作者导演 like'+'"'+'%'+e_dy.Text+'%'+'"';
 if e_zy.Text<>'' then
   cxtj:=cxtj+' and '+'主演 like'+'"'+'%'+e_zy.Text+'%'+'"';
 if copy(trim(cxtj),1,3)='and' then
    cxtj:=copy(trim(cxtj),4,500);
    cxtj:='where '+cxtj;
 if cxtj='where ' then
    cxtj:='';
  dm.adoq_cx.close;
  dm.adoq_cx.SQL.Clear;
  dm.adoq_cx.sql.add('select 货位号,状态,大类,小类,名称,作者导演,主演 from tsvcd');
  dm.adoq_cx.sql.add(cxtj);
  dm.ADOQ_cx.ExecSQL;
  dm.ADOQ_cx.Close;
  dm.ADOQ_cx.Open;
end;

procedure Tfrm_vcdcx.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  dm.ADOQ_cx.SQL.Clear;
  dm.ADOQ_cx.Close;
  release;
end;

procedure Tfrm_vcdcx.b_exitClick(Sender: TObject);
begin
   close;
end;

procedure Tfrm_vcdcx.FormKeyPress(Sender: TObject; var Key: Char);
begin
   if key=#13 then
   begin
    key:=#0;
    perform(wm_nextdlgctl,0,0);
   end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?