⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dw.pas

📁 一个关于VCD销售的系统
💻 PAS
字号:
unit dw;

interface

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

type
  Tfrm_dw = 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;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    e_name: TDBEdit;
    e_addr: TDBEdit;
    e_tel: TDBEdit;
    e_man: TDBEdit;
    blabel_ok: TLabelBtn;
    b_ok: TMoveImgBtn;
    DataSource1: TDataSource;
    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 b_okClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  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_dw: Tfrm_dw;

implementation

uses datam, publicvar, main;

{$R *.dfm}

procedure Tfrm_dw.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_dw.imgMinButtonClick(Sender: TObject);
begin
  if Application.MainForm =self then
    Application.Minimize
  else
    DefWindowProc(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;

procedure Tfrm_dw.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_dw.imgCloseButtonClick(Sender: TObject);
begin
  if e_name.Text='' then
  begin
     messagebox(mb_ok,'单位名称不能为空!',
     '错误',0+MB_ICONSTOP);
     exit;
  end;
  dm.ADO_dw.Cancel;
  dm.ADO_dw.Close;
  DefWindowProc(Handle, WM_SYSCOMMAND, SC_CLOSE, 0);
end;

procedure Tfrm_dw.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_dw.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_dw.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_dw.FormCreate(Sender: TObject);
begin
  lbCaption.Caption :=Caption;
  dm.ADO_dw.Open;
  dm.ADO_dw.First;
  dm.ADO_dw.Edit;
end;

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

procedure Tfrm_dw.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_dw.N_SizeClick(Sender: TObject);
begin
  DefWindowProc(Handle, WM_SYSCOMMAND, SC_SIZE, 0);
end;

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

procedure Tfrm_dw.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
end;

procedure Tfrm_dw.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_dw.b_okClick(Sender: TObject);
begin
  if e_name.Text='' then
    begin
     application.messagebox(pchar('单位名称不能为空!')
     ,pchar('错误'),MB_ICONSTOP);
     exit;
    end;
  dm.ado_dw.Post;
  dwname:=e_name.text;
  dm.ADO_dw.close;
  frm_main.ztl.Panels[0].Text:='单位名称:'
   +dwname;
  frm_main.ztl.Refresh;
  close;

end;

procedure Tfrm_dw.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  dm.ADO_dw.Cancel;
  dm.ADO_dw.Close;
  release;
end;

end.

⌨️ 快捷键说明

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