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

📄 wwrcdpnl.pas

📁 InfoPower_Studio 2007 v5.0.1.3 banben
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    Sender: TObject; curField: TField; Control: TControl);
var ButtonEffects: TwwButtonEffects;
    Frame: TwwEditFrame;
//    OldHeight: integer;


 procedure UpdatePositions;
 begin
   if (style=rvpshorizontal) then begin
      if (Control is TwwRadioGroup) and TwwRadioGroup(Control).ShowGroupCaption then
      begin
         curLabel.visible:= False;
         control.top:= curlabel.top;
         TwwRadioGroup(control).caption:= curlabel.caption;
      end;
      if (rvopLabelsBeneathControl in Options) then
      begin
         if not (control is TLabel) then
         begin
            control.top:= curLabel.Top;
            curLabel.Top:=
              control.top + control.Height + EditSpacing.HorizontalView.BetweenLabelEdit-1;
         end
      end;
   end;
{
   if (rvopLabelsBeneathControl in Options) and (style=rvpsHorizontal) then
   begin
      if not (control is TLabel) then
      begin
         control.top:= curLabel.Top;
         curLabel.Top:=
            control.top + control.Height + EditSpacing.HorizontalView.BetweenLabelEdit-1;
      end
   end;
}
 end;

begin
   ButtonEffects:= TwwButtonEffects.Get(Control);
   Frame:= TwwEditFrame.Get(Control);

   if ButtonEffects<>nil then with buttoneffects do begin
      transparent:= rvcTransparentButtons in ControlOptions;
      flat:= rvcFlatButtons in ControlOptions;
   end;
   if Frame<>nil then Frame.Assign(EditFrame);

   try
     if (Frame<>nil) then
        DoSetControlEffects(Sender, curfield, control, Frame, ButtonEffects);

//      OldHeight:= Control.Height;
      if Assigned(FOnAfterCreateControl) then
         FOnAfterCreateControl(Sender, curfield, control);
      {if Control.Height<>OldHeight then }
      UpdatePositions;
   finally
   end;


end;

procedure TwwRecordViewPanel.DoOnBeforeCreateControl(
    Sender: TObject; curField: TField; var accept: boolean);
begin
   if Assigned(FOnBeforeCreateControl) then
      FOnBeforeCreateControl(Sender, curfield, accept);
end;


procedure TwwRecordViewPanel.FreeNonCustomControls(DestroyControls: boolean);
var i, j: integer;
   DeleteControl: boolean;
   customItem: TwwCustomControlItem;
   skipSetParent: boolean;
   curControl: TControl;

    Function IsChildOfDBCGrid(control:TControl): boolean;
    var tc: TWinControl;
    begin
       result:=false;
       if not (control is TWinControl) then exit;
       tc:= control as TWinControl;
       if not (wwIsClass(tc.ClassType, 'TDBCtrlGrid')) then
       begin
          repeat
             tc:= tc.parent;
          until ((tc=nil) or wwIsClass(tc.ClassType, 'TDBCtrlGrid'))
       end;

       if tc=nil then result:=false
       else result:=  wwIsClass(tc.ClassType, 'TDBCtrlGrid');
    end;

begin
   for i:= ControlCount-1 downto 0 do begin
      DeleteControl:= True;
      curControl:= controls[i];
      if Controls[i].owner<>self then DeleteControl:= False;

      for j:= 0 to CustomControlList.count-1 do begin
         customItem:= TwwCustomControlItem(CustomControlList[j]);
         if Controls[i]=CustomItem.control then
         begin
            DeleteControl:= False;
            if (Controls[i].Owner is TWinControl) then
            begin
               Controls[i].visible:= CustomItem.Oldvisible;
               Controls[i].left:= CustomItem.left;
               Controls[i].top:= CustomItem.top;
               Controls[i].width:= CustomItem.width;
               Controls[i].height:= CustomItem.height;

               if (CustomItem.OldParent=Nil) or { 10/1/98 }
                  not (csDestroying in CustomItem.OldParent.ComponentState) then
               begin
                 if HasButtonEffects(TWinControl(Controls[i])) then
                 begin
                    TwwButtonEffects.Get(Controls[i]).Transparent:= customItem.ButtonTransparent;
                    TwwButtonEffects.Get(Controls[i]).Flat:= customItem.ButtonFlat;
                 end;

                 skipSetParent:= false;
                 if csDesigning in ComponentState then
                 begin
                    if CustomItem.OldParent = Controls[i].Parent then
                    begin
                       if (GetParentForm(Controls[i])<>nil) then
                       begin
                          Controls[i].Parent := GetParentForm(Controls[i]);
                          skipSetParent:= true;
                       end
                    end
                 end;

                 if not skipSetParent then
                    Controls[i].parent:= CustomItem.OldParent; //ValidParentForm(self)

                 // 9/28/06 - Don't set DataSource if owned by TwwRecordViewPanel
                 if (CustomItem.OldParent<>nil) then
                 begin
                   // Make sure TDBCTrlGrid is not any parent
                   if not IsChildOfDBCGrid(curControl) then
                   begin
                     if not (csDesigning in ComponentState) then
                     begin
                       wwSetControlDataSource(TWinControl(curControl), nil);
                       wwSetControlDataField(TWinControl(curControl), '');
                     end
                   end;
                 end;

               end
            end;
            break;
         end
      end;
      if DeleteControl then begin
         if DestroyControls then curControl.Free
         else begin
            if curControl is TWinControl then
            begin
               if not wwSetControlDataField(curControl as TWinControl, '') then continue;
            end
         end
      end
   end;

   for i:= 0 to CustomControlList.count-1 do TwwCustomControlItem(CustomControlList[i]).Free;
   CustomControlList.Clear;
end;

(*
procedure TwwRecordViewPanel.FreeNonCustomControls(DestroyControls: boolean);
var i, j: integer;
   DeleteControl: boolean;
   customItem: TwwCustomControlItem;
begin
   for i:= ControlCount-1 downto 0 do begin
      DeleteControl:= True;
      if Controls[i].owner<>self then DeleteControl:= False;

      for j:= 0 to CustomControlList.count-1 do begin
         customItem:= TwwCustomControlItem(CustomControlList[j]);
         if Controls[i]=CustomItem.control then
         begin
            DeleteControl:= False;
            if (Controls[i].Owner is TWinControl) then
            begin
               Controls[i].visible:= CustomItem.Oldvisible;
               Controls[i].left:= CustomItem.left;
               Controls[i].top:= CustomItem.top;
               Controls[i].width:= CustomItem.width;
               Controls[i].height:= CustomItem.height;
               wwSetControlDataSource(TWinControl(Controls[i]), nil);
               wwSetControlDataField(TWinControl(Controls[i]), '');

               if HasButtonEffects(TWinControl(Controls[i])) then
               begin
                  TwwButtonEffects.Get(Controls[i]).Transparent:= customItem.ButtonTransparent;
                  TwwButtonEffects.Get(Controls[i]).Flat:= customItem.ButtonFlat;
               end;

               if (CustomItem.OldParent=Nil) or { 10/1/98 }
                  not (csDestroying in CustomItem.OldParent.ComponentState) then
                  Controls[i].parent:= CustomItem.OldParent //ValidParentForm(self)
            end;
            break;
         end
      end;
      if DeleteControl then begin
         if DestroyControls then Controls[i].Free
         else begin
            if Controls[i] is TWinControl then
            begin
               if not wwSetControlDataField(controls[i] as TWinControl, '') then continue;
            end
         end
      end
   end;

   for i:= 0 to CustomControlList.count-1 do TwwCustomControlItem(CustomControlList[i]).Free;
   CustomControlList.Clear;

end;
*)

Function TwwRecordViewPanel.UseCustomControls: boolean;
begin
  result:= (rvopUseCustomControls in Options)
{         and
      not (csDesigning in ComponentState)}
end;

procedure TwwRecordViewPanel.AddControlPosition(Control: TControl; Left, Top, Width, Height: integer);
var cp: TControlPosition;
begin
    cp:= TControlPosition.create;
    cp.Control:= Control;
    cp.Left:= Left;
    cp.Top:= Top;
    cp.Height:= Height;
    cp.Width:= Width;
    ControlPositions.Add(cp);
end;

Procedure TwwRecordViewPanel.DisplayVertical(Recreate: boolean);
const FixedEditWidthConst=0;
var
    LabelWidth, MaxLabelWidth, MaxEditWidth: integer;
    APos, i, j, numFields: integer;
    curFieldDisplayWidth: integer;
    curFieldDisplayLabel: wwSmallString;
    curFieldReadOnly: boolean;
    curField: TField;
    curLabel: Tlabel;
    customEdit: TWinControl;
    checkbox: TwwDBCheckBox;
    EditHeight: integer;
    FixedEditWidth: integer;
    accept: boolean;
    PrevTop: integer;
    checkboxOn, checkboxOff: wwSmallString;
    Bitmap: TBitmap;
    curEditControl: TControl;
    NextTabOrder: integer;
    tempWidth: integer;
    tempControlCount: integer;

    ControlPositionLeft, ControlPositionTop,
    ControlPositionWidth, ControlPositionHeight: integer;
    cp: TControlPosition;
    EditControl: TWinControl;
    ShowingVertScrollBar: boolean;
    OldWidth: integer;
    BackgroundImage: boolean;

    Function CreateEditControl(EditControl: TWinControl): boolean;
    var
       tempMask: string;
       tempAutoFill: boolean;
       tempUsePictureMask: boolean;
    begin
        result:= False;

        if EditControl is TwwDBCustomEdit then
        begin
            if wwGetPictureControl(self)=self then { Picture masks do not come from dataset }
            begin
               wwPictureByField(self, curField.FieldName, False,
                   tempMask, tempAutoFill, tempUsePictureMask);
               with TwwDBEdit(EditControl).Picture do
               begin
                  PictureMaskFromDataSet:= False;
                  PictureMask:= tempMask;
                  AutoFill:=tempAutoFill;
               end
            end
        end;

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

              if curFieldReadonly or curField.calculated then
              begin
                 TEdit(EditControl).color:= ReadOnlyColor;
                 EditControl.tabStop:= False;
              end;

              if EditControl is TwwDBEdit then
              begin
                 if curField is TStringField then  {7/29/97 - Limit length to field size }
                    if curField.editmask='' then // 9/9/02
                      TEdit(EditControl).maxlength:= curField.Size;
              end;

           end;

           if isSingleLineEditControl(EditControl) then
              TempWidth:= (curFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3
           else
              TempWidth:= FixedEditWidth; //Self.width - EditStartOffset - Margin.RightOffset;

           if EditControl is TwwDBDateTimePicker then
           begin
              TempWidth:=
                    TempWidth + TwwDBDateTimePicker(EditControl).Button.Width
           end;

           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;

⌨️ 快捷键说明

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