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

📄 mainunit.~pas

📁 发射台 控制台 dephi编写 大家可以随便可看看, 可以做dephi入门实例学习
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
  TKDB[5].Value.Value2[11] := $400;
  TKDB[5].Value.Value3[11] := $101;
  TKDB[5].Value.Value4[11] := 0;
  TKDB[5].Value.Value5[11] := 0;
  TKDB[5].Value.Value1[12] := $8002;
  TKDB[5].Value.Value2[12] := $400;
  TKDB[5].Value.Value3[12] := $8102;
  TKDB[5].Value.Value4[12] := 0;
  TKDB[5].Value.Value5[12] := 0;
  TKDB[5].Value.Value1[13] := $8002;
  TKDB[5].Value.Value2[13] := $400;
  TKDB[5].Value.Value3[13] := $6102;
  TKDB[5].Value.Value4[13] := 0;
  TKDB[5].Value.Value5[13] := $802;
  TKDB[5].Value.Value1[14] := $8002;
  TKDB[5].Value.Value2[14] := $400;
  TKDB[5].Value.Value3[14] := $6102;
  TKDB[5].Value.Value4[14] := $0;
  TKDB[5].Value.Value5[14] := $1004;
  TKDB[5].Value.Value1[15] := $8002;
  TKDB[5].Value.Value2[15] := $400;
  TKDB[5].Value.Value3[15] := $5142;
  TKDB[5].Value.Value4[15] := 0;
  TKDB[5].Value.Value5[15] := 0;
  TKDB[5].Value.Value1[16] := $4000;
  TKDB[5].Value.Value2[16] := $4000;
  TKDB[5].Value.Value3[16] := 0;
  TKDB[5].Value.Value4[16] := $1;
  TKDB[5].Value.Value5[16] := 0;
  TKDB[5].Value.Value1[17] := $4000;
  TKDB[5].Value.Value2[17] := $8000;
  TKDB[5].Value.Value3[17] := 0;
  TKDB[5].Value.Value4[17] := $40;
  TKDB[5].Value.Value5[17] := 0;

end;

procedure TFrmMain.RefreshAInUseList;
begin
  AInUseList.Clear;
  AInUseList.Add(self.BoxA1.Text);
  AInUseList.Add(self.BoxA2.Text);
  AInUseList.Add(self.BoxA3.Text);
  AInUseList.Add(self.BoxA4.Text);
  AInUseList.Add(self.BoxA5.Text);
  AInUseList.Add(self.BoxA6.Text);
end;

procedure TFrmMain.RefreshComBoxList(nowBox : integer);
var
  i, tmpn, tmpn1 : integer;
  s : string;
begin
  if nowBox <> 0 then   //当前的combox不用刷新
  begin
    self.BoxA1.Items.Clear;
    tmpn := FindSInSlist(self.AInUseList[2], TKDB[0].AList);
    if (tmpn <> -1) and (tmpn <> 0) then    
      begin
        self.BoxA1.Items.Add(TKDB[0].AList.Strings[0]);
      end else
      begin
        for i := 0 to TKDB[0].AList.Count-1 do
        begin
          s := TKDB[0].AList.Strings[i];
          if JudgeIsInUse(s, 0) = false then
            begin
              self.BoxA1.Items.Add(s);
            end;
        end;
      end;
  end;

  if nowBox <> 1 then   //当前的combox不用刷新
  begin
    self.BoxA2.Items.Clear;
    tmpn := FindSInSlist(self.AInUseList[2], TKDB[1].AList);
    if (tmpn <> -1) and (tmpn <> 0) then    
    begin
      self.BoxA2.Items.Add(TKDB[1].AList.Strings[0]);
    end else
    begin
      for i := 0 to TKDB[1].AList.Count-1 do
      begin
        s := TKDB[1].AList.Strings[i];
        if JudgeIsInUse(s, 1) = false then
          begin
            self.BoxA2.Items.Add(s);
          end;
      end;
    end;
  end;

  if nowBox <> 2 then   //当前的combox不用刷新
  begin
    self.BoxA3.Items.Clear;
    if (self.AInUseList[0] <> '未使用') and (self.AInUseList[1] = '未使用')then
    begin
      for i := 0 to TKDB[2].AList.Count-1 do
      begin
        s := TKDB[2].AList.Strings[i];
        if JudgeIsInUse(s, 2) = false then
          begin
            tmpn := FindSInSList(s, TKDB[0].AList);
            if (tmpn = -1) or (tmpn = 0) then
              begin
                self.BoxA3.Items.Add(s);
              end;
          end;
      end
    end;

    if (self.AInUseList[0] = '未使用') and (self.AInUseList[1] <> '未使用') then
      begin
        for i := 0 to TKDB[2].AList.Count-1 do
        begin
          s := TKDB[2].AList.Strings[i];
          if JudgeIsInUse(s, 2) = false then
            begin
              tmpn := FindSInSList(s, TKDB[1].AList);
              if (tmpn = -1) or (tmpn = 0) then
                begin
                  self.BoxA3.Items.Add(s);
                end;
            end;
        end;
      end;

    if (self.AInUseList[0] <> '未使用') and (self.AInUseList[1] <> '未使用') then
      begin
        for i := 0 to TKDB[2].AList.Count-1 do
        begin
          s := TKDB[2].AList.Strings[i];
          if JudgeIsInUse(s, 2) = false then
            begin
              tmpn := FindSInSList(s, TKDB[1].AList);
              tmpn1 := FindSInSList(s, TKDB[0].AList);
              if ((tmpn = -1) and (tmpn1 = -1)) or (s = '未使用') then
                begin
                  self.BoxA3.Items.Add(s);
                end;
            end;
        end;
      end;

    if (self.AInUseList[0] = '未使用') and (self.AInUseList[1] = '未使用') then
      begin
        for i := 0 to TKDB[2].AList.Count-1 do
        begin
          s := TKDB[2].AList.Strings[i];
          if JudgeIsInUse(s, 2) = false then
            begin
              self.BoxA3.Items.Add(s);
            end;
        end;
      end;
 end;

 if nowBox <> 3 then   //当前的combox不用刷新
  begin
    self.BoxA4.Items.Clear;
    tmpn := FindSInSlist(self.AInUseList[5], TKDB[3].AList);
    if (tmpn <> -1) and (tmpn <> 0) then
      begin
        self.BoxA4.Items.Add(TKDB[3].AList.Strings[0]);
      end else
      begin
        for i := 0 to TKDB[3].AList.Count-1 do
        begin
          s := TKDB[3].AList.Strings[i];
          if JudgeIsInUse(s, 3) = false then
            begin
              self.BoxA4.Items.Add(s);
            end;
        end;
      end;
  end;

  if nowBox <> 4 then   //当前的combox不用刷新
  begin
    self.BoxA5.Clear;
    tmpn := FindSInSlist(self.AInUseList[5], TKDB[4].AList);
    if (tmpn <> -1) and (tmpn <> 0) then
      begin
        self.BoxA5.Items.Add(TKDB[4].AList.Strings[0]);
      end else
      begin
        for i := 0 to TKDB[4].AList.Count-1 do
        begin
          s := TKDB[4].AList.Strings[i];
          if JudgeIsInUse(s, 4) = false then
            begin
              self.BoxA5.Items.Add(s);
            end;
        end;
      end;
  end;

  if nowBox <> 5 then   //当前的combox不用刷新
  begin
    self.BoxA6.Clear;
    if (self.AInUseList[3] <> '未使用') and (self.AInUseList[4] = '未使用') then  
    begin
      for i := 0 to TKDB[5].AList.Count-1 do
      begin
        s := TKDB[5].AList.Strings[i];
        if JudgeIsInUse(s, 5) = false then
          begin
            tmpn := FindSInSList(s, TKDB[3].AList);
            if (tmpn = -1) or (tmpn = 0) then
              begin
                self.BoxA6.Items.Add(s);
              end;
          end;
      end
    end;

    if (self.AInUseList[3] = '未使用') and (self.AInUseList[4] <> '未使用') then
      begin
        for i := 0 to TKDB[5].AList.Count-1 do
        begin
          s := TKDB[5].AList.Strings[i];
          if JudgeIsInUse(s, 5) = false then
            begin
              tmpn := FindSInSList(s, TKDB[4].AList);
              if (tmpn = -1) or (tmpn = 0) then
                begin
                  self.BoxA6.Items.Add(s);
                end;
            end;
        end;
      end;

    if (self.AInUseList[3] <> '未使用') and (self.AInUseList[4] <> '未使用') then
      begin
        for i := 0 to TKDB[5].AList.Count -1 do
          begin
            s := TKDB[5].AList.Strings[i];
            if JudgeIsInUse(s, 5) = false then
              begin
                tmpn := FindSInSList(s, TKDB[3].AList);
                tmpn1 := FindSInSList(s, TKDB[4].AList);
                if ((tmpn = -1) and (tmpn1 = -1)) or (s = '未使用') then
                  begin
                    self.BoxA6.Items.Add(s);
                  end;
              end;
          end;
      end;

    if (self.AInUseList[3] = '未使用') and (self.AInUseList[4] = '未使用') then
      begin
        for i := 0 to TKDB[5].AList.Count-1 do
        begin
          s := TKDB[5].AList.Strings[i];
          if JudgeIsInUse(s, 5) = false then
            begin
              self.BoxA6.Items.Add(s);
            end;
        end;
      end;
  end;
end;

function TFrmMain.JudgeIsInUse(AName: string; Index : integer): boolean;
var
  i : integer;
begin
  result := false;
  if AName = '未使用' then
    begin
      exit;
    end;
  i := FindSInSList(AName, AInUseList);
  if (i <> -1) and (i <> Index)then
    begin
      result := true;
      exit;
    end;
end;

procedure TFrmMain.BtnKeyClick(Sender: TObject);
begin
  if locked = true then
    begin
      FrmPW.Show;
      while self.IsPWCorrect = -1 do
        begin
          Application.ProcessMessages;
        end;

      self.FormStyle := fsStayOnTop;
      if self.IsPWCorrect = 1 then
        begin
          self.BtnKey.Caption := '加锁';
          locked := false;
          SystemLocked(locked);
  //        self.Timer1.Enabled := true;
          self.IsPWCorrect := -1;
        end else
        begin
          self.IsPWCorrect := -1;
        end;
    end else
    begin
      self.BtnKey.Caption := '解锁';
      locked := true;
      SystemLocked(locked);
//      self.Timer1.Enabled := false;
    end;
end;

procedure TFrmMain.SystemLocked(IsLocked: boolean);
begin
  self.DTSwitch.Enabled := not IsLocked;
  self.BoxA1.Enabled := not IsLocked;
  self.BoxA2.Enabled := not IsLocked;
  self.BoxA3.Enabled := not IsLocked;
  self.BoxA4.Enabled := not IsLocked;
  self.BoxA5.Enabled := not IsLocked;
  self.BoxA6.Enabled := not IsLocked;
  self.BtnAdd.Enabled := not IsLocked;
  self.BtnModify.Enabled := not IsLocked;
  self.BtnDelete.Enabled := not IsLocked;
  self.BtnOK.Enabled :=  false;
  self.BtnCancel.Enabled := false;
  self.StringGrid1.Enabled := not IsLocked;
  self.NSet.Enabled := not IsLocked;
end;

procedure TFrmMain.BtnAddClick(Sender: TObject);
begin
//  self.Timer1.Enabled := false;
 // self.ClearComBox;
  BtnStateSwitch(false);
//  self.Timer1.Enabled := true;
  self.OperateType := 0;
end;

procedure TFrmMain.BtnStateSwitch(OperateBtnState: boolean);
begin
  self.BtnAdd.Enabled := OperateBtnState;
  self.BtnModify.Enabled := OperateBtnState;
  self.BtnDelete.Enabled := OperateBtnState;
  self.StringGrid1.Enabled := OperateBtnState;
  self.BtnOK.Enabled := not OperateBtnState;
  self.BtnCancel.Enabled := not OperateBtnState;
end;

//在slist中查找s,返回index,如果查不到返回-1
function TFrmMain.FindSInSList(s: string; sList: TStrings): integer;
var
  i : integer;
begin
  result := -1;
  for i := 0 to sList.Count -1 do
    begin
      if s = sList.Strings[i] then
        begin
          result := i;
          exit;
        end;
    end;
end;

procedure TFrmMain.BoxA1Click(Sender: TObject);
var
  sList : TStrings;
begin
//  self.Timer1.Enabled := false;
  sList := TStringList.Create;
  sList.Add(self.BoxA2.Text);
  sList.Add(self.BoxA3.Text);
  sList.Add(self.BoxA4.Text);
  sList.Add(self.BoxA5.Text);
  sList.Add(self.BoxA6.Text);
  self.RefreshAInUseList;
  self.RefreshComBoxList(0);
  if sList.Strings[0] = self.BoxA1.Text then
    begin
      self.BoxA2.ItemIndex := 0;
    end else
    begin
      self.BoxA2.ItemIndex := FindSInSlist(sList.Strings[0], self.BoxA2.Items);
    end;
  if sList.Strings[1] = self.BoxA1.Text then
    begin
      self.BoxA3.ItemIndex := 0;
    end else
    begin
      self.BoxA3.ItemIndex := FindSInSlist(sList.Strings[1], self.BoxA3.Items);
    end;
  if sList.Strings[2] = self.BoxA1.Text then
    begin
      self.BoxA4.ItemIndex := 0;
    end else
    begin
      self.BoxA4.ItemIndex := FindSInSlist(sList.Strings[2], self.BoxA4.Items);
    end;
  if sList.Strings[3] = self.BoxA1.Text then
    begin
      self.BoxA5.ItemIndex := 0;
    end else
    begin
      self.BoxA5.ItemIndex := FindSInSlist(sList.Strings[3], self.BoxA5.Items);
    end;
  if sList.Strings[4] = self.BoxA1.Text then
    begin
      self.BoxA6.ItemIndex := 0;
    end else
    begin
      self.BoxA6.ItemIndex := FindSInSlist(sList.Strings[4], self.BoxA6.Items);
    end;
    sList.Free;
//    self.Timer1.Enabled := true;
end;

procedure TFrmMain.BoxA2Click(Sender: TObject);

⌨️ 快捷键说明

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