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

📄 wwrcdpnl.pas

📁 InfoPower_Studio 2007 v5.0.1.3 banben
💻 PAS
📖 第 1 页 / 共 5 页
字号:

           ControlPositionLeft:= EditStartOffset; {EditPosition.LeftOffset + LabelWidth + 5;}
           ControlPositionTop:= PrevTop;

           if IsSingleLineEditControl(EditControl) then
              ControlPositionHeight:= EditControl.Height
           else
              ControlPositionHeight:= Bitmap.Canvas.TextHeight('0') * LinesPerMemoControl + 8; {2 lines of Memo}
           { 11/11/99 - Only set enabled to false if recreating control }
           if Recreate and CurFieldReadOnly then enabled:=False;
       end;

       if not Recreate then begin
          if rvopShortenEditBox in Options then begin
             if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
          end;

          if rvopConsistentEditWidth in Options then begin
             if TempWidth<FixedEditWidth then TempWidth:= FixedEditWidth; //!!!
          end;

          ControlPositionWidth:= TempWidth;
          ControlPositionHeight:= EditControl.Height;

          AddControlPosition(EditControl, ControlPositionLeft, ControlPositionTop,
                             ControlPositionWidth, ControlPositionHeight);
       end
       else begin
          EditControl.Left:= ControlPositionLeft;
          EditControl.Top:= ControlPositionTop;
          EditControl.Height:= ControlPositionHeight;

          OldWidth:= EditControl.Width; { 10/22/98 - Respect width change }
          DoOnAfterCreateControl(self, curField, EditControl);
          if EditControl.Width<>OldWidth then TempWidth:= EditControl.Width; { 10/22/98 }

          if rvopShortenEditBox in Options then begin
             if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
          end;

          if rvopConsistentEditWidth in Options then begin
             if TempWidth<FixedEditWidth then TempWidth:= FixedEditWidth; //!!
          end;

          EditControl.Width:= TempWidth;
       end;

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

       EditControl.tabOrder:= NextTabOrder; {9/3/98 - Fix tab order problem }
       inc(NextTabOrder);
       result:= True;

       if recreate then curField.FreeNotification(self);

    end;


begin
   tempControlCount:= 0;
   for i:= 0 to ControlCount-1 do
      if Controls[i].owner=self then inc(TempControlCount);
   if TempControlCount=0 then Recreate:= True;

   if FDataLink.Active or (DataSource=Nil) or (Datasource.dataset=Nil) then
   begin
      if (Recreate) then FreeNonCustomControls(True);
      if (DataSource=nil) or (Datasource.dataset=nil) or (not Datasource.dataset.active) then begin
         exit;
      end
   end
   else begin
//      if (Recreate) then FreeNonCustomControls; { If inactive then don't show controls }
      exit;
   end;

   PrevTop:= Margin.TopOffset;

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

   Bitmap:= TBitmap.create;
   ControlPositions.Clear;

   try
      MaxLabelWidth:= 0;
      Bitmap.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,
                          Bitmap.Canvas.TextWidth(curFieldDisplayLabel));
      end;

      LabelWidth:= MaxLabelWidth;
      Bitmap.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) * Bitmap.Canvas.TextWidth('0') + 3);
      end;

      MaxEditWidth:= 0;
      EditHeight:= 8;
      NextTabOrder:= 0;
      FixedEditWidth:= Width - (EditStartOffset + Margin.RightOffset + FixedEditWidthConst);
      if BorderStyle=bsSingle then FixedEditWidth:= FixedEditWidth - 4;

      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;
         if Recreate then
            DoOnBeforeCreateControl(self, curField, accept);
         if not accept then continue;

         curLabel:= nil;
         curEditControl:= nil;

         if (not Recreate)  then begin
            for j:= 0 to CustomControlList.count-1 do begin
               TwwCustomControlItem(CustomControlList[j]).control.parent:= self;
            end;
            for j:= 0 to ControlCount-1 do begin
               if TControl(Controls[j]) is TWinControl then begin
                  if wwEqualStr(wwGetControlDataField(TWinControl(Controls[j])),
                                curField.fieldname) then
                  begin
                     curEditControl:= Controls[j];
                     break;
                  end
               end
            end;
            if curEditControl<>Nil then begin
               for j:= 0 to ControlCount-1 do begin
                  if TControl(Controls[j]) is TLabel then begin
                     curLabel:= TLabel(Controls[j]);
                     if TLabel(Controls[j]).FocusControl=curEditControl then
                     begin
                        curLabel:= TLabel(Controls[j]);
                        break;
                     end
                  end
               end
            end
            else continue; { 3/11/99 - No edit control exists for this field }
         end;

         if curLabel=Nil then begin
            if (rvopUseCustomControls in Options) and
               wwIsCheckbox(self, curField, checkboxOn, checkboxOff) then
               curLabel:= TwwLabel.create(self)
            else
               curLabel:= TLabel.create(self);
         end;
         self.curlabel:= curLabel;

         with curLabel do begin
            if recreate then begin
              parent:= self;
//              AutoSize:= True; { 12/23/98 - Right alignment for labels }
              AutoSize:= False;
              Width:= LabelWidth;

              font:= self.labelFont;
              Caption:= strReplaceChar(curfieldDisplayLabel, '~', ' ');
              alignment:= taRightJustify;
            end
            else begin
              if AutoSize<>False then AutoSize:= False;
              if Width<>LabelWidth then Width:= LabelWidth;
              if Alignment<>taRightJustify then alignment:= taRightJustify;
            end;

            font:= self.labelFont;

            ControlPositionLeft:= Margin.LeftOffset;
            if (rvopUseCustomControls in Options) and
               wwIsCheckbox(self, curField, checkboxOn, checkboxOff) then
               ControlPositionTop:= PrevTop + 1
            else
               ControlPositionTop:= PrevTop + 4;

            if recreate then
            begin
               Left:= ControlPositionLeft;
               Top:= ControlPositionTop;
            end
            else AddControlPosition(curLabel,
                      ControlPositionLeft, ControlPositionTop, curlabel.Width, curLabel.Height);
         end;

         if Recreate then
         begin
            if rvcTransparentLabels in ControlOptions then curLabel.transparent:= true;
            DoOnAfterCreateControl(self, curField, curLabel);
         end;

         if (rvopUseCustomControls in Options) and
            wwIsCheckbox(self, curField, checkboxOn, checkboxOff) then
         begin
            if (not Recreate) and (curEditControl<>Nil) then
            begin
               checkbox:= TwwDBCheckBox(curEditControl);
               ControlPositionLeft:= EditStartOffset;
               ControlPositionTop:= PrevTop;
               AddControlPosition(CheckBox, ControlPositionLeft, ControlPositionTop,
                                   Checkbox.Width, Checkbox.Height);
            end
            else begin
               checkbox:= TwwDBCheckBox.create(self);
               checkbox.LabelControl:= curLabel;
               curLabel.FocusControl:= checkBox;
               with checkbox do begin
                 parent:= self;
                 datasource:= self.DataSource;
                 datafield:= curfield.fieldName;
                 caption:= '';
                 valueChecked:= checkboxOn;
                 valueUnchecked:= checkboxOff;
                 Width:= 17;
                 left:= EditStartOffset; {EditPosition.LeftOffset + LabelWidth + 5;}
                 Top:= PrevTop;

                 if curFieldReadOnly or Field.calculated then
                 begin
                    tabStop:= False;
                    Enabled:=False; { 3/9/99 - Readonly checkbox }
                 end;
              end;
              if Recreate then
                 DoOnAfterCreateControl(self, curField, checkbox);
            end;

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

            { 9/20/98 - Set tab orders for checkbox }
            checkbox.TabOrder:= NextTabOrder;  { 3/11/99 - Previously didn't have checkbox.taborder }
            inc(NextTabOrder);
         end
         else if UseCustomControls and
            IsCustomEditCell(curField, customEdit) then
         with TEdit(CustomEdit) do begin
            curLabel.FocusControl:= CustomEdit;

            if Recreate then begin
               AddCustomControl(CustomEdit);
               parent:= self;
               if not wwSetControlDataSource(customEdit, datasource) then continue;
               if not wwSetControlDataField(customEdit, '') then continue;
               if not wwSetControlDataField(customEdit, curField.fieldName) then continue;
            end
            else parent:= self;

//            visible:= True; { Causes custom control's to flicker when coming up }
            Ctl3d:= True;
            if not HasFrame(customEdit) then BorderStyle:= bsSingle;
            ControlPositionLeft:= EditStartOffset;
            ControlPositionTop:= PrevTop;

            if (wwisclass(customedit.classtype,'TwwCustomRichEdit')) then
               TempWidth:= FixedEditWidth
            else
               TempWidth:= (curFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3;

            if rvopShortenEditBox in Options then begin
               if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
            end;
            if rvopConsistentEditWidth in Options then begin
               if TempWidth<FixedEditWidth then TempWidth:= FixedEditWidth;
            end;

            TEdit(CustomEdit).HandleNeeded;

            if not Recreate then begin
               ControlPositionWidth:= TempWidth;
               ControlPositionHeight:= CustomEdit.Height;
               AddControlPosition(CustomEdit, ControlPositionLeft, ControlPositionTop,
                                 TempWidth, ControlPositionHeight);
            end
            else begin
               Left:= ControlPositionLeft;
               Top:= ControlPositionTop;
               OldWidth:= CustomEdit.Width; { 10/22/98 - Respect width change }

⌨️ 快捷键说明

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