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

📄 wwrcdvw.pas

📁 InfoPower_Studio 2007 v5.0.1.3 banben
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  begin
   Result:= False;
   PropInfo:= Typinfo.GetPropInfo(Control.ClassInfo,'WantTabs');
   if PropInfo<>Nil then
      result:= Boolean(GetOrdProp(Control, PropInfo))
  end;

begin
  inherited KeyDown(Key, Shift);

  if ssAlt in Shift then exit;

  Dlg:= DlgComponent as TwwRecordViewDialog;

  if  ((ssCtrl in Shift) and (key=vk_return)) and (rvoModalForm in Dlg.Options) and
      (not (rvoEnterToTab in Dlg.Options)) then
  begin
     ModalResult:= mrOK;
  end;

  if ActiveControl=Nil then exit; { 1/31/99  - All fields reaonly so no active control }

  if Key=27 then begin
     TwwCheatCastKeyDown(ActiveControl).KeyDown(Key, Shift);
     if (Key=27) then begin
        Key:= 0;
        if (ActiveControl is TWinControl) and Dlg.IsControlModified(ActiveControl) then exit
        else begin
          ModalResult:= mrCancel;
          Dlg.CloseAction := rvcCancel;
        end
     end
  end
  else if (not GetWantReturns(ActiveControl) and (key=vk_return) and (rvoEnterToTab in Dlg.Options))
      or (not GetWantTabs(ActiveControl) and (key=vk_tab)) then
  begin
     if ssShift in Shift then
        PostMessage(Handle, WM_NEXTDLGCTL, 1, 0)
     else
        PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
     key:= 0;
  end;

end;

procedure TwwRecordViewDialog.DoSetControlEffects(form: TwwRecordViewForm; curfield: TField;
   control: TControl; Frame: TwwEditFrame; ButtonEffects: TwwButtonEffects);
begin
   if Assigned(FOnSetControlEffects) then
      FOnSetControlEffects(form, curfield, control, Frame, ButtonEffects);
end;

procedure TwwRecordViewDialog.DoOnAfterCreateControl(
    form: TwwRecordViewForm; curField: TField; Control: TControl);
var ButtonEffects: TwwButtonEffects;
    Frame: TwwEditFrame;
//    OldHeight: integer;

 procedure UpdatePositions;
 begin
   if (style=rvshorizontal) 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 (rvoLabelsBeneathControl 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;
 end;

begin
   ButtonEffects:= TwwButtonEffects.Get(Control);
   Frame:= TwwEditFrame.Get(Control);
   if not (control is TLabel) then FLabelList.add(curLabel);

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

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

//     OldHeight:= Control.Height;
     if Assigned(FOnAfterCreateControl) then
        FOnAfterCreateControl(form, curfield, control);
     UpdatePositions;
   finally
   end

end;

procedure TwwRecordViewDialog.DoOnBeforeCreateControl(
    form: TwwRecordViewForm; curField: TField; var accept: boolean);
begin
   if Assigned(FOnBeforeCreateControl) then
      FOnBeforeCreateControl(form, curfield, accept);
end;

Procedure TwwRecordViewDialog.DoInitDialog(form: TwwRecordViewForm);
begin
   if Assigned(FOnInitDialog) then OnInitDialog(Form);
end;

Procedure TwwRecordViewDialog.DoCancelWarning(var CanClose: boolean);
begin
   if Assigned(FOnCancelWarning) then FOnCancelWarning(RecordViewForm, CanClose);
end;

Procedure TwwRecordViewDialog.DoCloseDialog(form: TwwRecordViewForm);
begin
   if Assigned(FOnCloseDialog) then OnCloseDialog(Form);
end;


Procedure TwwRecordViewDialog.AddCustomControl(CustomEdit: TWinControl);
var customItem: TwwCustomControlItem;
    buttonEffects: TwwButtonEffects;
begin
   customItem:= TwwCustomControlItem.create;
   with customItem do begin
      Control:= CustomEdit;
      Left:= CustomEdit.Left;
      Width:= CustomEdit.Width;
      Top:= CustomEdit.Top;
      Height:= CustomEdit.Height;
      ButtonEffects:= TwwButtonEffects.get(customEdit);
      if ButtonEffects<>nil then begin
         ButtonFlat:= buttoneffects.Flat;
         ButtonTransparent:= buttoneffects.Transparent;
      end;
      OldParent:= CustomEdit.Parent;
      OldVisible:= customEdit.visible;
   end;
   CustomControlList.add(customItem);
end;

function TwwRecordViewDialog.IsCheckBox(curField: TField; var checkboxOn, checkboxOff: string): boolean;
var fldName: string;
    i: integer;
    parts : TStrings;
    controlType: TStrings;
begin
   result:= False;
   fldName:= curField.fieldName;
   parts:= TStringList.create;

   controlType:= nil; { 6/22/99 - ADO datasets store in component, not dataset }
   if wwGetControlInfoInDataSet(self) then
      controlType:= wwGetControlType(curfield.dataset);
   if controlType=nil then
      controlType:= wwGetControlType(self);
      
   for i:= 0 to ControlType.count-1 do begin
      strBreakapart(controlType[i], ';', parts);
      if parts.count<4 then continue;
      if parts[0]<>fldName then continue;
      if parts[1]='CheckBox' then begin
	 CheckBoxOn:= parts[2];
	 CheckBoxOff:= parts[3];
	 result:= True;
	 break;
      end
   end;

   parts.free;
end;

function TwwRecordViewDialog.HasFrame(Control: TWinControl): boolean;
var frame: TwwEditFrame;
begin
    frame:= TwwEditFrame.Get(Control);
    result:= (frame<>nil) and frame.enabled;
end;

function TwwRecordViewDialog.HasButtonEffects(Control: TWinControl): boolean;
begin
    result:= TwwButtonEffects.Get(Control)<>nil;
end;

procedure TwwRecordViewDialog.InitPictureMask(EditControl: TWinControl; curField: TField);
var tempMask: string;
    tempAutoFill, tempUsePictureMask: boolean;
begin
   if (EditControl is TwwDBCustomEdit) then
   begin
      wwPictureByField(wwGetPictureControl(self), curField.FieldName, True,
         tempMask, tempAutoFill, tempUsePictureMask);
      with TwwDBCustomEdit(EditControl).Picture do
      begin
         PictureMaskFromDataSet:= False;
         PictureMask:= tempMask;
         AutoFill:=tempAutoFill;
         AllowInvalidExit:= False;
      end;
   end
end;


Procedure TwwRecordViewDialog.DisplayVertical;
var
    LabelWidth, MaxLabelWidth, MaxEditWidth: integer;
    APos, i, numFields: integer;
    curFieldDisplayWidth: integer;
    curFieldDisplayLabel: wwSmallString;
    curFieldReadOnly: boolean;
    curField: TField;
    curLabel: Tlabel;
    customEdit: TWinControl;
    checkbox: TwwDBCheckBox;
    NavigatorWidth: integer;
    ButtonPanelHeight: integer;
    EditHeight: integer;
    FixedEditWidth: integer;
    accept: boolean;
    PrevTop: integer;
    ARect: TRect;
    checkboxOn, checkboxOff: wwSmallString;
    editControl: TWinControl;
    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;

           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;

           { 5/19/99 - Memo fields should not be maximized if rvoMaximizeMemoWidth is false }
           TempWidth:= (curFieldDisplayWidth+1) * RecordViewForm.Canvas.TextWidth('0') + 3;
           if not isSingleLineEditControl(EditControl) then
           begin
              if (Patch[0]) or (rvoMaximizeMemoWidth in Options) then
                 TempWidth:= RecordViewForm.width - EditStartOffset - (Margin.RightOffset + FixedEditWidthConst);
           end;

{           if isSingleLineEditControl(EditControl) then
           begin
              TempWidth:= (curFieldDisplayWidth+1) * RecordViewForm.Canvas.TextWidth('0') + 3;
           end
           else begin
              TempWidth:= RecordViewForm.width - EditStartOffset - (Margin.RightOffset + FixedEditWidthConst);
           end;
}

           if EditControl is TwwDBDateTimePicker then
           begin
              TempWidth:=
                    TempWidth + TwwDBDateTimePicker(EditControl).Button.Width
           end
           else if (EditControl is TCustomMemo) and (rvoEnterToTab in Options) then
                  TMemo(EditControl).WantReturns := False
           else if (EditControl is TwwDBEditMemo) and (rvoEnterToTab in Options) then
                  TwwDBEditMemo(EditControl).WantReturns := False;

           if rvoShortenEditBox in Options then begin
              if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
           end;
           if rvoConsistentEditWidth in Options then begin
              if TempWidth<FixedEditWidth then TempWidth:= FixedEditWidth;
           end;

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

           if IsSingleLineEditControl(EditControl) then
              ControlPositionHeight:= EditControl.Height
           else
              ControlPositionHeight:=
                 RecordViewForm.Canvas.TextHeight('0') * LinesPerMemoControl + 8; {2 lines of Memo}
           if CurFieldReadOnly then enabled:=False;
           InitPictureMask(EditControl, curfield);

       end;

       EditControl.Left:= ControlPositionLeft;
       EditControl.Top:= ControlPositionTop;
       EditControl.Height:= ControlPositionHeight;

       FControlList.add(EditControl);

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

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

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

       EditControl.Width:= TempWidth;

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

       result:= True;
    end;

begin
   PrevTop:= Margin.TopOffset;
   with RecordViewForm do begin
      if not (rvoHideNavigator in Options) then NavigatorWidth:= Navigator.width
      else NavigatorWidth:= 0;

      if (rvokShowOKCancel in OKCancelOptions) then
      begin
        ButtonPanelHeight:= ButtonPanel.Height;
      end
      else

⌨️ 快捷键说明

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