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

📄 setprint.pas

📁 delphi作得信息业进销存源码.功能全面,运行稳定.
💻 PAS
📖 第 1 页 / 共 5 页
字号:
var
  RptEmpty, SrcEmpty, DstEmpty: Boolean;
begin
  RptEmpty := RptList.Items.Count - ReportCount = 0;
  //P1
  btnPreview.Enabled := not (RptList.Items.Count = 0);
  btnPrint.Enabled := btnPreview.Enabled;
  btnSet.Enabled := not RptEmpty;
  btnSaveAs.Enabled := not RptEmpty;
  btnDel.Enabled := not RptEmpty;
  //P2
  SrcEmpty := SrcList.Items.Count = 0;
  DstEmpty := DstList.Items.Count = 0;
  btnRight.Enabled := not SrcEmpty;
  btnLeft.Enabled := not DstEmpty;
  btnUp.Enabled := not DstEmpty;
  btnDown.Enabled := not DstEmpty;
end;

//DYJ
procedure TfrmSetPrint.rbPortraitClick(Sender: TObject);
begin
  img1.Visible := rbPortrait.Checked;
  img2.Visible := not img1.Visible;
  SetPreviewPnl(Sender);
end;

procedure TfrmSetPrint.cbDyjChange(Sender: TObject);
var
  s: string;
begin
  s := printer.Printers[cbDyj.ItemIndex];
end;

procedure TfrmSetPrint.cbPageSizeChange(Sender: TObject);
begin
  case cbPageSize.ItemIndex of
  0: SetPageSize(297, 420);
  1: SetPageSize(210, 297);
  2: SetPageSize(148, 210);
  3: SetPageSize(250, 364);
  4: SetPageSize(182, 257);
  end;
  edtPageWidth.Enabled := cbPageSize.ItemIndex = 5;
  edtPageLength.Enabled := edtPageWidth.Enabled;
end;

procedure TfrmSetPrint.SetPageSize(Width, Length: integer);
begin
  edtPageWidth.Text := IntToStr(Width);
  edtPageLength.Text := IntToStr(Length);
end;

//Odd Line Color
procedure TfrmSetPrint.btnOddClick(Sender: TObject);
begin
  ColorDialog1.Color := pnlOdd.Color;
  if ColorDialog1.Execute then
    pnlOdd.Color := ColorDialog1.Color;
end;

//Even Line Color
procedure TfrmSetPrint.btnEvenClick(Sender: TObject);
begin
  ColorDialog1.Color := pnlEven.Color;
  if ColorDialog1.Execute then
    pnlEven.Color := ColorDialog1.Color;
end;

//YmdyFont.Click
procedure TfrmSetPrint.YmdyFontClick(Sender: TObject);
begin
  FontDialog1.Font := YmdyFont.Font;
  if FontDialog1.Execute then
    YmdyFont.Font := FontDialog1.Font;
end;

//SetPreviewPnl
procedure TfrmSetPrint.SetPreviewPnl(Sender: TObject);
begin
  //Rect
  with pnlPage do
    if rbPortrait.Checked then
      Height := 219
    else
      Height := 135;
  if (edtPageTop.Text <> '') and (edtPageBottom.Text <> '') and
    (edtPageLeft.Text <> '') and (edtPageRight.Text <> '') then
    with pnlClient do
    begin
      Top := edtPageTop.Value;
      Left := edtPageLeft.Value;
      Width := pnlPage.Width - Left - edtPageRight.Value;
      Height := pnlPage.Height - Top - edtPageBottom.Value;
    end;
  //color
  pnlYm.Color := YmColor.Color;
  pnlBt.Color := BtColor.Color;
  pnlBgbt.Color := BgbtColor.Color;
  pnlBw.Color := BwColor.Color;
  pnlYj.Color := YjColor.Color;
  pnlLm.Color := mmoLm.Color;
  pnlNy.Color := mmoNy.Color;
  pnlHj.Color := mmoHj.Color;
  //Font
  pnlLm.Font.Name := mmoLm.Font.Name;
  pnlNy.Font.Name := mmoNy.Font.Name;
  pnlHj.Font.Name := mmoHj.Font.Name;
  //Font.Color
  pnlLm.Font.Color := mmoLm.Font.Color;
  pnlNy.Font.Color := mmoNy.Font.Color;
  pnlHj.Font.Color := mmoHj.Font.Color;
  //Alignment
  ////YM
  if YmRightAlign.Down then
    pnlYm.Alignment := taRightJustify
  else if YmCenterAlign.Down then
    pnlYm.Alignment := taCenter
  else
    pnlYm.Alignment := taLeftJustify;
  ////Bt
  if BtRightAlign.Down then
    pnlBt.Alignment := taRightJustify
  else if BtCenterAlign.Down then
    pnlBt.Alignment := taCenter
  else
    pnlBt.Alignment := taLeftJustify;
  ////Bgbt
  if BgbtRightAlign.Down then
    pnlBgbt.Alignment := taRightJustify
  else if BgbtCenterAlign.Down then
    pnlBgbt.Alignment := taCenter
  else
    pnlBgbt.Alignment := taLeftJustify;
  ////Bw
  if BwRightAlign.Down then
    pnlBw.Alignment := taRightJustify
  else if BwCenterAlign.Down then
    pnlBw.Alignment := taCenter
  else
    pnlBw.Alignment := taLeftJustify;
  ////Yj
  if YjRightAlign.Down then
    pnlYj.Alignment := taRightJustify
  else if YjCenterAlign.Down then
    pnlYj.Alignment := taCenter
  else
    pnlYj.Alignment := taLeftJustify;
end;

procedure TfrmSetPrint.pnlYmClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 0;
  YmRich.SetFocus;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlBtClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 1;
  BtRich.SetFocus;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlBgbtClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 2;
  BgbtRich.SetFocus;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlLmClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 3;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlNyClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 3;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlHjClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 4;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlBwClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 5;
  BwRich.SetFocus;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlYjClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 0;
  self.PageControl2.ActivePageIndex := 6;
  YjRich.SetFocus;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlPageClick(Sender: TObject);
begin
  self.PageControl1.ActivePageIndex := 2;
  edtPageTop.SetFocus;
  SetImageTop(nil);
end;

procedure TfrmSetPrint.pnlClientResize(Sender: TObject);
var
  h: integer;
begin
  h := pnlClient.Height div 8;
  pnlYm.Height := h;
  pnlBt.Height := h;
  pnlBgbt.Height := h;
  pnlLm.Height := h;
  pnlNy.Height := h;
  pnlHj.Height := h;
  pnlBw.Height := h;
end;

procedure TfrmSetPrint.DrawBandFrame(ABand: TQRCustomBand; AItemIndex: Integer);
begin
  with ABand do
    case AItemIndex of
    0:
      begin
        Frame.DrawTop := true;
        Frame.DrawBottom := true;
        Frame.DrawLeft := true;
        Frame.DrawRight := true;
      end;
    1:
      begin
        Frame.DrawTop := true;
        Frame.DrawBottom := true;
        Frame.DrawLeft := false;
        Frame.DrawRight := false;
      end;
    2:
      begin
        Frame.DrawTop := false;
        Frame.DrawBottom := false;
        Frame.DrawLeft := true;
        Frame.DrawRight := true;
      end;
    3:
      begin
        Frame.DrawTop := false;
        Frame.DrawBottom := false;
        Frame.DrawLeft := false;
        Frame.DrawRight := false;
      end;
    end;
end;

procedure TfrmSetPrint.btnColWidthClick(Sender: TObject);
var
  i: integer;
begin
{  dbgColWidth.Columns.Clear;
  for i := 0 to DstList.Items.Count - 1 do
  begin
    strTmp := Copy(DstList.Items[i], 51, Length(DstList.Items[i]) - 50);
    for j := 0 to AGrid.Columns.Count - 1 do
      if AGrid.Columns[j].FieldName = strTmp then
      begin
        with dbgColWidth.Columns.Add do
        begin
          Width := AGrid.Columns[j].Width;
          FieldName := strTmp;
          Title.Alignment := taCenter;
        end;
        break;
      end;
  end;}
  pnlColWidth.Visible := true;
  for i := 0 to dbgColWidth.Columns.Count - 1 do
    dbgColWidth.Columns[i].Visible := DstList.Items.IndexOf(dbgColWidth.Columns[i].Title.Caption + Copy(strSpace, 1, 50 - Length(dbgColWidth.Columns[i].Title.Caption)) + dbgColWidth.Columns[i].FieldName) >= 0;
end;

procedure TfrmSetPrint.btnSaveColWidthClick(Sender: TObject);
begin
{  for i := 0 to dbgColWidth.Columns.Count - 1 do
    for j := 0 to AGrid.Columns.Count - 1 do
      if AGrid.Columns[j].FieldName = dbgColWidth.Columns[i].FieldName then
        AGrid.Columns[j].Width := dbgColWidth.Columns[i].Width;
  self.btnCancelColWidth.Click;}
  pnlColWidth.Visible := false;
end;

procedure TfrmSetPrint.mmoYmKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_F1 then
    self.pmnXm.Popup(0,0);
end;

procedure TfrmSetPrint.SetImageTop(Sender: TObject);
var
  t: integer;
begin
  pnlColWidth.Visible := false;
  //RichEdit
  case PageControl2.ActivePageIndex of
    0:
    begin
      CurrFile := YmRich;
      BoldButton := YmBoldButton;
      ItalicButton := YmItalicButton;
      UnderlineButton := YmUnderlineButton;
      FontColor := YmFontColor;
      FontSize := YmFontSize;
      FontName := YmFontName;
    end;
    1:
    begin
      CurrFile := BtRich;
      BoldButton := BtBoldButton;
      ItalicButton := BtItalicButton;
      UnderlineButton := BtUnderlineButton;
      FontColor := BtFontColor;
      FontSize := BtFontSize;
      FontName := BtFontName;
    end;
    2:
    begin
      CurrFile := BgbtRich;
      BoldButton := BgbtBoldButton;
      ItalicButton := BgbtItalicButton;
      UnderlineButton := BgbtUnderlineButton;
      FontColor := BgbtFontColor;
      FontSize := BgbtFontSize;
      FontName := BgbtFontName;
    end;
    5:
    begin
      CurrFile := BwRich;
      BoldButton := BwBoldButton;
      ItalicButton := BwItalicButton;
      UnderlineButton := BwUnderlineButton;
      FontColor := BwFontColor;
      FontSize := BwFontSize;
      FontName := BwFontName;
    end;
    6:
    begin
      CurrFile := YjRich;
      BoldButton := YjBoldButton;
      ItalicButton := YjItalicButton;
      UnderlineButton := YjUnderlineButton;
      FontColor := YjFontColor;
      FontSize := YjFontSize;
      FontName := YjFontName;
    end;
  end;
  //Preview
  t := 0;
  case PageControl1.ActivePageIndex of
    0:
    begin
      case PageControl2.ActivePageIndex of
        0: t := PnlYm.Top;
        1: t := PnlBt.Top;
        2: t := PnlBgbt.Top;
        3: t := PnlNy.Top;
        4: t := PnlHj.Top;
        5: t := PnlBw.Top;
        6: t := PnlYj.Top;
      end;
      t := pnlPage.Top + pnlClient.Top + t;
    end;
    2: t := pnlPage.Top;
    else
      t := -100;
  end;
  imgLeft.Top := t;
  imgRight.Top := imgLeft.Top;
end;

procedure TfrmSetPrint.edtLmslChange(Sender: TObject);
begin
  edtLf.Enabled := (edtLmsl.Text <> '') and (edtLmsl.Value > 1);
  cbBj.Enabled := not edtLf.Enabled;
  cbBj.Caption := '自动调整左右边距';
  if not cbBj.Enabled then
    cbBj.Caption := cbBj.Caption + ' (设置分栏打印不能使用此功能)';
  edtPageLeft.Enabled := not cbBj.Checked or not cbBj.Enabled;
  edtPageRight.Enabled := edtPageLeft.Enabled;
end;

{-Button 按钮处理-}

//btnNew.Click
procedure TfrmSetPrint.btnNewClick(Sender: TObject);
var
  strItem: string;
begin
  strItem := GetInputString('新增', '报表名称',
    AForm.Caption + FormatFloat('#', RptList.Items.Count));
  if strItem <> '' then
    if RptList.Items.IndexOf(strItem) >= 0 then
      Application.MessageBox('此报表名称已存在, 请重新新增.',
        '新增', MB_OK + MB_ICONINFORMATION)
    else begin
      RptList.ItemIndex := RptList.Items.Add(strItem);
      cbRpt.Items.Add(strItem);
      IniSet;
      FileName := FilePath + AForm.Name + '_' + strItem + '.ini';
      SaveSet(FileName);
    end;
  RptList.SetFocus;
  SetButtons;
end;

//btnSet.Click
procedure TfrmSetPrint.btnSetClick(Sender: TObject);
begin
  if RptList.ItemIndex <= ReportCount - 1 then
  begin
    Application.MessageBox('此份是系统预设的报表, 不能设置.',
        '提示', MB_OK + MB_ICONINFORMATION);
    exit;
  end;
  FileName := FilePath + AForm.Name + '_' + RptList.Items[RptList.ItemIndex] + '.ini';
  LoadSet(FileName);
  SetNotePage('2');
end;

//btnCancelSet.Click
procedure TfrmSetPrint.btnCancelSetClick(Sender: TObject);
begin
  SetNotePage('1');
end;

//btnSaveAs.Click

⌨️ 快捷键说明

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