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

📄 wwrcdvw.pas

📁 InfoPower_Studio 2007 v5.0.1.3 banben
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      begin
        ButtonPanelHeight:= 0;
      end;

      if FuseTFields or (selected.count=0) then numFields:= DataSource.DataSet.FieldCount
      else numFields:= Selected.count;

      MaxLabelWidth:= 0;
      Canvas.Font := LabelFont;
      for i:= 0 to numFields-1 do begin
         if (Selected.count=0) or FuseTFields then begin
            curField:= DataSource.dataset.fields[i];
            curFieldDisplayLabel:= curField.DisplayLabel;
            curFieldReadOnly:= curfield.ReadOnly;
         end
         else begin
            APos:= 1;
            curField:= DAtaSource.dataset.findField(strGetToken(Selected[i], #9, APos));
            if curfield<>nil then begin
               strGetToken(Selected[i], #9, APos);
               curFieldDisplayLabel:= strGetToken(Selected[i], #9, APos);  { 6/4/97}
               curFieldReadOnly := (strGetToken(Selected[i], #9, APos) = 'T');
            end
         end;
         if not ShowField(curfield, curFieldReadOnly) then continue;
         MaxLabelWidth:= wwMax(MaxLabelWidth,
                           Canvas.TextWidth(curFieldDisplayLabel));
      end;

      LabelWidth:= MaxLabelWidth;
      Canvas.Font := Font;
            { Limit form length }
      EditStartOffset:= Margin.LeftOffset + labelWidth + EditSpacing.VerticalView.BetweenLabelEdit;

      { Compute desired form length }
      MaxEditWidth:= 0;
      curFieldDisplayWidth:= 0;

      for i:= 0 to numFields-1 do begin
         if (Selected.count=0) or FuseTFields then
         begin
            curField:= DAtaSource.dataset.fields[i];
            curFieldDisplayWidth:= curField.DisplayWidth;
            curFieldReadOnly:= curField.ReadOnly;
         end
         else begin
            APos:= 1;
            curField:= DAtaSource.dataset.findField(strGetToken(Selected[i], #9, APos));
            if curfield<>nil then
            begin
               curFieldDisplayWidth:= strToInt(strGetToken(Selected[i], #9, APos));
               strGetToken(Selected[i], #9, APos); { Display label }
               curFieldReadOnly := (strGetToken(Selected[i], #9, APos) = 'T')
            end
         end;
         if not ShowField(curfield, curFieldReadOnly) then continue;

         MaxEditWidth:= wwmax(MaxEditWidth,
               (CurFieldDisplayWidth+1) * Canvas.TextWidth('0') + 3);
      end;


      ARect := wwGetWorkingRect;

      if FormPosition.Width>0 then
         FormWidth:= wwMax(FormPosition.Width, NavigatorWidth + (FixedEditWidthConst-6) + Margin.RightOffset)
      else begin
         FormWidth:= RecordPanel.Left + ScrollBox.left + EditStartOffset + MaxEditWidth +
                  (FixedEditWidthConst-6) + Margin.RightOffset;
         FormWidth:= wwMax(FormWidth, NavigatorWidth + (FixedEditWidthConst-6) + Margin.RightOffset);
      end;

      Width:= wwmin(FormWidth, (ARect.Right-ARect.Left)-((FixedEditWidthConst-6) + Margin.RightOffset));

      MaxEditWidth:= 0;
      EditHeight:= 8;

      FixedEditWidth:= RecordViewForm.width - (EditStartOffset + (FixedEditWidthConst + Margin.RightOffset));

      for i:= 0 to numFields-1 do begin
         if (Selected.count=0) or FuseTFields then
         begin
            curField:= DAtaSource.dataset.fields[i];
            curFieldDisplayWidth:= curField.displayWidth;
            curFieldDisplayLabel:= curField.displayLabel;
            curFieldReadOnly:= curField.readonly;
         end
         else begin
            APos:= 1;
            curField:= DAtaSource.dataset.findField(strGetToken(Selected[i], #9, APos));
            if curfield<>nil then begin
               curFieldDisplayWidth:= strToInt(strGetToken(Selected[i], #9, APos));
               curFieldDisplayLabel:= strGetToken(Selected[i], #9, APos);  { 6/4/97}
               curFieldReadOnly :=strGetToken(Selected[i], #9, APos) = 'T'
            end
         end;
         if not ShowField(curfield, curFieldReadOnly) then continue;

         accept:= True;
         DoOnBeforeCreateControl(RecordViewForm, curField, accept);
         if not accept then continue;

         if (rvoUseCustomControls in Options) and
            IsCheckbox(curField, checkboxOn, checkboxOff) then
            curLabel:= TwwLabel.create(Scrollbox)
         else
            curLabel:= TLabel.create(Scrollbox);
         self.curlabel:= curlabel;

         with curLabel do begin
            parent:= ScrollBox;
            font:= self.labelFont;
            { Move caption assigment before left assignment for bidi support }
            Caption:= strReplaceChar(curfieldDisplayLabel, '~', ' ');
            left:= Margin.LeftOffset;
            if (rvoUseCustomControls in Options) and
               IsCheckbox(curField, checkboxOn, checkboxOff) then
            begin
               Top:= PrevTop + 1
            end
            else
               Top:= PrevTop + 4;

            AutoSize:= False;
            Width:= LabelWidth;
            alignment:= taRightJustify;
         end;

         if rvcTransparentLabels in ControlOptions then curLabel.transparent:= true;
         DoOnAfterCreateControl(RecordViewForm, curField, curLabel);

         if (rvoUseCustomControls in Options) and
            IsCheckbox(curField, checkboxOn, checkboxOff) then
         begin
            checkbox:= TwwDBCheckBox.create(ScrollBox);
            checkbox.LabelControl:= curLabel;
            curLabel.FocusControl:= checkBox;
            with checkbox do begin
               parent:= ScrollBox;
               datasource:= self.DataSource;
               datafield:= curfield.fieldName;
               left:= EditStartOffset; {EditPosition.LeftOffset + LabelWidth + 5;}
               Top:= PrevTop;
               caption:= '';
               valueChecked:= checkboxOn;
               valueUnchecked:= checkboxOff;
               Width:= 17;
               if curFieldReadonly or Field.calculated then
               begin
                  tabStop:= False;
               end;
            end;
            DoOnAfterCreateControl(RecordViewForm, curField, checkbox);

            MaxEditWidth:= wwmax(MaxEditWidth, checkbox.Width);
            PrevTop:= Prevtop + checkbox.Height + EditSpacing.VerticalView.BetweenRow;
            EditHeight:= checkbox.Height;

         end
         else if (rvoUseCustomControls in Options) and
            wwIsCustomEditCell(self, wwGetOwnerFrameOrForm(self), curField, customEdit) then
         with TEdit(CustomEdit) do begin

            { Save previous position and restore when dialog is closed }
            AddCustomControl(CustomEdit);
            curLabel.FocusControl:= CustomEdit;

            parent:= ScrollBox;
            visible:= True;
            if not wwSetControlDataSource(customEdit, datasource) then continue;
            if not wwSetControlDataField(customEdit, curField.fieldName) then continue;
            if CustomEdit is TwwDBCustomLookupCombo then
            begin
               if not (curField.calculated or curfield.lookup) then
                  TwwDBLookupCombo(CustomEdit).RefreshDisplay;
            end;
            Ctl3d:= True;

            if not HasFrame(customEdit) then BorderStyle:= bsSingle;

            left:= EditStartOffset;
            top:= PrevTop;

            if (wwisclass(customedit.classtype,'TwwCustomRichEdit')) then begin
{               Height:= Canvas.TextHeight('0')*2+8;}
               Width:= RecordViewForm.width - EditStartOffset - (FixedEditWidthConst + Margin.RightOffset);
            end
            else
            begin
               Width:= (curFieldDisplayWidth+1) * Canvas.TextWidth('0') + 3;
               if (Width < Canvas.TextWidth(curFieldDisplayLabel)) and (rvoSetControlMinWidth in Options) then
                  Width:= Canvas.TextWidth(curFieldDisplayLabel) + 1;
            end;

            if rvoShortenEditBox in Options then begin
               if Width>FixedEditWidth then Width:= FixedEditWidth;
            end;
            if rvoConsistentEditWidth in Options then begin
               if Width<FixedEditWidth then Width:= FixedEditWidth;
            end;
            TEdit(CustomEdit).HandleNeeded;
            FControlList.add(CustomEdit);
            DoOnAfterCreateControl(RecordViewForm, curField, customEdit);

            if rvoShortenEditBox in Options then begin
               if customEdit.Width>FixedEditWidth then
                  customEdit.Width:= FixedEditWidth;
            end;
            if rvoConsistentEditWidth in Options then begin
               if customEdit.Width<FixedEditWidth then customEdit.Width:= FixedEditWidth;
            end;
            MaxEditWidth:= wwmax(MaxEditWidth, customEdit.Width);
            PrevTop:= Prevtop + customEdit.Height + EditSpacing.VerticalView.BetweenRow;
            EditHeight:= customEdit.Height;
         end
         else if (curField is TDateTimeField) and
                 (rvoUseDateTimePicker in Options) then
         begin
            EditControl:= TwwDBDateTimePicker.create(ScrollBox);
            if not CreateEditControl(EditControl) then continue;
         end
         else if wwIsRichEditField(curField, True) then begin
            EditControl:= TwwDBRichEdit.create(ScrollBox);
            if not CreateEditControl(EditControl) then continue;
         end
         else if (curField.dataType = ftMemo) then begin
            if EditFrame.IsFrameEffective then
               EditControl:= TwwDBEditMemo.create(ScrollBox)
            else
               EditControl:= TwwDBEditMemo.create(ScrollBox);
            if not CreateEditControl(EditControl) then continue;
         end
         else if (curField.dataType = ftGraphic) then
         begin { 8/27/98 - Support images }
            editControl:= TDBImage.create(ScrollBox);
            if not CreateEditControl(EditControl) then continue;
         end
         else begin
            EditControl:= CreateDefaultEditControl(ScrollBox);
            EditControl.controlStyle:= EditControl.ControlStyle + [csNoDesignVisible];
            if not CreateEditControl(EditControl) then continue;
         end
      end;

      CreateMainMenu(RecordViewForm, self.menu);
      PrevTop := PrevTop + Margin.BottomOffset - EditSpacing.VerticalView.BetweenRow;


//      FormHeight:= (PrevTop  + RecordPanel.Top)+ 21+getsystemmetrics(SM_CYCAPTION) + ButtonPanelHeight;

      // vista
      FormHeight:= (PrevTop  + RecordPanel.Top)+ FixedEditWidthConst  + getsystemmetrics(SM_CYCAPTION) + ButtonPanelHeight;
      if (self.menu<>nil) and (BorderStyle<>bsDialog) then
         FormHeight:= FormHeight +  GetSystemMetrics(SM_CYMENU);
      if FormPosition.height>0 then Height:= wwMin(FormPosition.Height, FormHeight)
      else Height:= FormHeight;

      { Adjust width/height based on visibility of scrollbars }
      if Height>ARect.Bottom-ARect.Top-12 then
      begin
         Height:= ARect.Bottom-ARect.Top-12;
         {$ifdef wwDelphi4Up}
         ShowingVertScrollBar:= True;
         {$else}
         ShowingVertScrollBar:= False;
         {$endif}
      end
      else ShowingVertScrollBar:= False;

      ScrollBox.VertScrollBar.Margin:= 6;
      ScrollBox.VertScrollBar.Increment:= EditHeight + EditSpacing.VerticalView.BetweenRow;
      ScrollBox.VertScrollBar.Range := PrevTop;
      if (RecordPanel.Height-12)<PrevTop then Width:= Width + GetSystemMetrics(SM_CXHThumb);

      FormWidth:= RecordPanel.Left + ScrollBox.left + EditStartOffset + MaxEditWidth +
                  (FixedEditWidthConst-6) + Margin.RightOffset;
      if Width>ARect.Right-ARect.Left then Width:= ARect.Right-ARect.Left;

      if Width<FormWidth then
         Height:= Height + GetSystemMetrics(SM_CYVThumb);
      ScrollBox.HorzScrollBar.Margin:= 6;
      if (rvoConsistentEditWidth in Options) then
         ScrollBox.HorzScrollBar.Range := MaxEditWidth
      else
         ScrollBox.HorzScrollBar.Range := EditStartOffset + MaxEditWidth + Margin.RightOffset;

      if ShowingVertScrollBar then
         ScrollBox.HorzScrollBar.Range:=
            ScrollBox.HorzScrollBar.Range - GetSystemMetrics(SM_CXHThumb);

      if (rvokShowOKCancel in OKCancelOptions) then begin
         ButtonPanel.Width := Width;
         OKBtn.Left:= (ButtonPanel.Width - 10) - ((OKBtn.Width + Spacing) * 2);
         CancelBtn.Left:= (ButtonPanel.Width-10) - ((OKBtn.Width + Spacing) * 1);
      end;
   end
end;


{*****************************************************}

Procedure TwwRecordViewDialog.DisplayHorizontal;
var
    OrigMaxEditWidth, MaxEditWidth: integer;
    APos, i, numFields: integer;
    curFieldDisplayWidth: integer;

    curFieldEditWidth: integer;
    curFieldLabelWidth: integer;
    curFieldDisplayLabel: wwSmallString;
    curFieldReadOnly: boolean;
    RealMaxLineWidth, MaxLineWidth,curLineWidth: integer;
    LastEditHeight:integer;
    LastLabelHeight:integer;
    ARect:TRect;

    curField: TField;
    curLabel: Tlabel;
    customEdit: TWinControl;
    checkbox: TwwDBCheckBox;
    NavigatorWidth: integer;
    ButtonPanelHeight: integer;
    EditHeight: integer;
    FixedEditWidth: integer;
    accept: boolean;
    PrevTop: integer;
    checkboxOn, checkboxOff: wwSmallString;
    editControl: TWinControl; //CustomEdit;
    ShowingVertScrollBar: boolean;

    Function CreateEditControl(EditControl: TWinControl): boolean;
    var TempWidth: integer;
        ControlPositionLeft, ControlPositionTop,
        ControlPositionHeight: integer;
        OldWidth: integer;
    begin
        result:= False;

        with EditControl do begin
           curLabel.FocusControl:= EditControl;
           parent:= RecordViewForm.Scrollbox;
           if not wwSetControlDataSource(EditControl, self.datasource) then exit;
           if not wwSetControlDataField(EditControl, curField.fieldName) then exit;

⌨️ 快捷键说明

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