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

📄 mdibase.pas

📁 用delphi编写的数据库管理软件
💻 PAS
字号:
unit MDIBase;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  StdCtrls, Mask, DBCtrlsEh, ComCtrls, Grids, DBGridEh, db, Base_Dll;

type
  TfrmMDIBase = class(TfrmBase_DLL)
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure GetDataFromMain(var T:TWMCopyData);message WM_COPYDATA;
    { Private declarations }
  protected
    bCanNew,bCanModify,bCanDelete,bCanPrint,bCanConfirm,bCanCounteract,bCanBegin,bCanFinish :Boolean;
    Procedure GetPermiss ; virtual; 
    function isEdit():Boolean;virtual;
  public
    { Public declarations }
  end;

var
  frmMDIBase: TfrmMDIBase;

implementation

uses Global;

{$R *.dfm}

function TfrmMDIBase.isEdit: Boolean;
begin
  if (ActiveControl is Tcustomedit) or
    (ActiveControl is Tcustomcombobox) or
    (Activecontrol is TDateTimepicker) or
    (Activecontrol is Tedit) or
    (Activecontrol is TdbeditEH) then
    Result:=True
    else
    Result:=False;
end;

procedure TfrmMDIBase.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
    begin
      if IsEdit then
        begin
          key:=#0;
          perform(WM_NEXTDLGCTL,0,0);
        end
        else
        begin
          if (activecontrol is TDBGrideh) then
            with tdbgrideh(activecontrol) do
              begin
                if selectedindex<(fieldcount-1) then
                  selectedindex:=selectedindex+1
                  else
                  selectedindex:=0;
              end;
        end;
    end;
end;

procedure TfrmMDIBase.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  SendDataToMain(formhandle,self.Caption,1);
  action:=caFree;
end;

procedure TfrmMDIBase.FormShow(Sender: TObject);
var
  formHwn:Hwnd;
  SMSG:String;
begin
  formHwn:=Self.Handle;
  SMSG:=self.Caption+'#'+intToStr(formHwn);
  SendDataToMain(formhandle,SMSG,0);
  application.ProcessMessages;
end;

procedure TfrmMDIBase.GetDataFromMain(var T: TWMCopyData);
var
  ReceiptMsg:String;
  i,j,k:integer;
begin
  ReceiptMsg :=StrPas(t.COPYDATASTRUCT.lpData);
  if ReceiptMsg = m_showform then
    begin
      self.Show;
    end;
  if ReceiptMsg = m_LockColumn then
    begin
      for i:=0 to self.ComponentCount - 1 do
        begin
          if (self.Components[i] is TDBGridEH) then
            begin
              if (self.Components[i] as TDBGridEH).Tag=0 then
                begin
                  LockCount:=LockCount+1;
                   if LockCount=(self.components[i] as TDBGridEH).columns.Count-1 then
                      LockCount:=0;
                   if LockCount>=0 then
                   begin
                     (self.Components[i] as TDBGridEH).frozenCols:=LockCount;
                      for k:=0 to (self.Components[i] as TDBGridEH).Columns.Count-1 do
                        (self.Components[i] as TDBGridEH).Columns[K].Font.Color:=clblack;
                      for j:=0 to LockCount-1 do
                        (self.Components[i] as TDBGridEH).Columns[j].Font.Color:=clBlue;
                    end;
                end;
            end;
        end;
    end;
  if ReceiptMsg = m_unLockColumn then
    begin
      for i:=0 to self.ComponentCount - 1 do
        begin
          if (self.Components[i] is TDBGridEH) then
            begin
              if (self.Components[i] as TDBGridEH).Tag=0 then
                begin
                  LockCount:=LockCount-1;
                  if LockCount<1 then
                    LockCount:=0;
                   if LockCount>=0 then
                   begin
                     (self.Components[i] as TDBGridEH).frozenCols:=LockCount;
                      for k:=0 to (self.Components[i] as TDBGridEH).Columns.Count-1 do
                        (self.Components[i] as TDBGridEH).Columns[K].font.Color:=clblack;
                      for j:=0 to LockCount-1 do
                        (self.Components[i] as TDBGridEH).Columns[j].font.Color:=clBlue;
                    end;
                end;
            end;
        end;
    end;
  if ReceiptMsg = m_Close then
    begin
      self.Close;
    end;
end;

procedure TfrmMDIBase.FormCreate(Sender: TObject);
begin
  LockCount:=0;
  GetPermiss;
end;

procedure TfrmMDIBase.GetPermiss;
begin
bCanNew :=G_bAdmin;
bCanModify :=G_bAdmin;
bCanDelete :=G_bAdmin;
bCanPrint :=G_bAdmin;
bCanConfirm :=G_bAdmin;
bCanCounteract :=G_bAdmin;
bCanBegin :=G_bAdmin;
bCanFinish :=G_bAdmin;

if G_bAdmin then
begin
  bCanNew :=G_bAdmin;
  bCanModify :=G_bAdmin;
  bCanDelete :=G_bAdmin;
  bCanPrint :=G_bAdmin;
  bCanConfirm :=G_bAdmin;
  bCanCounteract :=G_bAdmin;
  bCanBegin :=G_bAdmin;
  bCanFinish :=G_bAdmin;
end
else
with DLLCDS do
  if Locate('fModuleID;fActionName',varArrayOf([iModuleID,sFunctionName]),[loCaseInsensitive]) then
     begin
     bCanNew := FieldByName('fInsert').AsBoolean;
     bCanModify := FieldByName('fEdit').AsBoolean;
     bCanDelete := FieldByName('fDelete').AsBoolean;
     bCanPrint := FieldByName('fPrint').AsBoolean;
     bCanConfirm := FieldByName('fConfirm').AsBoolean;
     bCanCounteract := FieldByName('fCancel').AsBoolean;
     bCanBegin :=FieldByName('fStart').AsBoolean;;
     bCanFinish := FieldByName('fFinish').AsBoolean;
     end
end;


procedure TfrmMDIBase.FormDestroy(Sender: TObject);
begin
  inherited;
  frmMDIBase:=nil;
end;

end.

⌨️ 快捷键说明

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