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

📄 wwdatainspector.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    FInUpdateData := False;
  end;
end;

constructor TwwDataInspectorDataLink.Create(AObjectView: TwwDataInspector);
begin
  inherited Create;
  FObjectView:= AObjectView;
  VisualControl:= true;
end;

procedure TwwDataInspectorDataLink.EditingChanged;
begin
  FObjectView.EditingChanged;
end;

procedure TwwDataInspectorDataLink.RecordChanged(Field: TField);
begin
  if (Field = nil) or not FInUpdateData then
  begin
    FObjectView.RecordChanged(Field);
    FModified := False;
  end;

  if (Field<>Nil) and (Dataset.State in [dsEdit, dsInsert]) then
  begin
     FObjectView.FieldChanged(Field);
     FObjectView.TextIsSame:= True;
  end
end;

procedure TwwDataInspectorDataLink.LayoutChanged;
begin
  { 11/15/99 - Fixes problem for active cell updating in detail query }
  FObjectView.InvalidateEditor;
  FObjectView.invalidate;
//  FRecordViewPanel.LinkActive(Active);
end;

procedure TwwDataInspectorDataLink.ActiveChanged;
begin
   FObjectView.LinkActive(Active);
end;

procedure TwwDataInspectorDataLink.DataSetScrolled(Distance: Integer);
begin
  FObjectView.Scroll(Distance);
end;

{ TDrawGrid }

Function TwwDataInspector.MouseToItem(X, Y: Integer): TwwInspectorItem;
var ACol, ARow: integer;
begin
   MouseToCell(X, Y, ACol, ARow);
   result:= GetItemByRow(ARow);
end;

procedure TwwDataInspector.MouseToCell(X, Y: Integer; var ACol, ARow: Longint);
var
  Coord: TGridCoord;
begin
  Coord := MouseCoord(X, Y);
  ACol := Coord.X;
  ARow := Coord.Y;
end;


Function GetCenterPoint(ARect: TRect): TPoint;
var r: TRect;
begin
   r:= ARect;
   result.y:= r.Top + (wwRectHeight(r)) div 2;
   result.x:= r.Left + (wwRectWidth(r)) div 2;
end;

procedure TwwInspectorIndicatorRow.Invalidate;
var r: TRect;
begin
   if Enabled then
   begin
      r:= Inspector.CellRect(0, 0);
      r.right:= Inspector.ClientWidth;
      InvalidateRect(Inspector.Handle, @r, True);
   end
end;

procedure TwwInspectorIndicatorRow.SetColor(Value: TColor);
begin
   if FColor<>Value then
   begin
      FColor:= Value;
      Inspector.PaintOptions.Row1Color:= Value;
      Inspector.PaintOptions.InitBlendBitmapsFlag:=True;
      Invalidate;
   end
end;

procedure TwwInspectorIndicatorRow.SetTextAlignment(Value: TAlignment);
begin
   if FTextAlignment<>Value then
   begin
      FTextAlignment:= Value;
      if Enabled then Inspector.invalidateCell(0,0);
   end
end;

procedure TwwInspectorIndicatorRow.SetEnabled(Value: Boolean);
begin
   if FEnabled<>Value then
   begin
      FEnabled:= Value;
      Inspector.ApplySettings;
   end
end;

procedure TwwInspectorIndicatorRow.SetHeight(Value: integer);
begin
   if FHeight<>Value then
   begin
      FHeight:= Value;
      if (Inspector.RowCount>0) and Enabled then
         Inspector.RowHeights[0]:= Value;
   end
end;

procedure TwwInspectorIndicatorRow.SetCaption(Value: string);
begin
   if FCaption<>Value then
   begin
      FCaption:= Value;
      if Enabled then Inspector.invalidateCell(0,0);
   end
end;

constructor TwwInspectorIndicatorRow.Create(Owner: TComponent);
begin
  Inspector:= Owner as TwwDataInspector;
  FColor:= clBtnFace;
end;

constructor TwwDataInspector.Create(AOwner: TComponent);
const
  bmArrow = 'WWINSPECTORARROW';
  bmEdit = 'WWINSPECTOREDIT';
  bmInsert = 'WWINSPECTORINSERT';
var
  Bmp: TBitmap;
begin
  inherited Create(AOwner);
  NewMouseRow:= -1;
//  FAlternatingRowColor:=$00B1B1B1;
//  FActiveColumnColor:= clNOne;
  FPaintBitmap:= TBitmap.create;
  FPaintCanvas:= FPaintBitmap.Canvas;
  ControlStyle:= ControlStyle + [csReplicatable];

  Bmp := TBitmap.Create;
  try
    Bmp.LoadFromResourceName(HInstance, bmArrow);
    FIndicators := TImageList.CreateSize(Bmp.Width, Bmp.Height);
    FIndicators.AddMasked(Bmp, clWhite);
    Bmp.LoadFromResourceName(HInstance, bmEdit);
    FIndicators.AddMasked(Bmp, clWhite);
    Bmp.LoadFromResourceName(HInstance, bmInsert);
    FIndicators.AddMasked(Bmp, clWhite);
  finally
    Bmp.Free;
  end;


  SetFocusTabStyle := itsPreserveActiveItem;
  Color:= clBtnFace;
  ScrollBars:= ssVertical;
  FLineStyleData:= ovDark3DLine;
  FlineStyleCaption:= ovDark3DLine;
  FSaveCellExtents:= false;

  FDottedLineColor:= clBtnShadow;
  FDataLink:= TwwDataInspectorDataLink.create(self);
  FItems:= TwwInspectorCollection.Create(self);
//  FSelected:= TStringList.create;
//  FControlType:= TStringList.create;
  FixedCols:= 0;
  FCaptionIndent:= 12;
  ColCount:= 2;
  RowCount:= 1;
  FixedRows:=0;
  FCaptionWidth:= 100;

  inherited Options := [goColSizing,
     goTabs, goEditing, goAlwaysShowEditor];
  Options:= [ovColumnResize, ovRowResize, ovHighlightActiveRow,
             ovCenterCaptionVert, ovEnterToTab];
  DefaultDrawing := False;

  FCaptionFont := TFont.Create;
  FCaptionFont.OnChange := CaptionFontChanged;
  FInactiveFocusColor:= clNone;
  FButtonOptions:= TwwInspectorButtonOptions.create(self);
  FDataColumns:= 1;
  FTreeLineColor:= clWhite;

  FIndicatorRow:= TwwInspectorIndicatorRow.create(self);
  FPaintOptions:= TwwGridPaintOptions.create(self, FPaintBitmap);
  FPaintOptions.Row1Color:= IndicatorRow.Color;
  FPaintOptions.Column1Color:= CaptionColor;

  FixedDataRows:= 0;
end;

var KeyHook : HHOOK;

type TCheatCast = class(TwwDataInspector)
end;

function wwHookKeyProc(nCode: Integer; wParam: Integer; lParam: Integer): LResult; stdcall;
type
  TSelection = record
    StartPos, EndPos: Integer;
  end;
var ac: TWinControl;
    Inspector: TwwDataInspector;

    Function IsChildOfInspector(var Inspector: TwwDataInspector): boolean;
    var tc: TWinControl;
    begin
       tc:= screen.activecontrol;
       if not (tc is TwwDataInspector) then
       begin
          repeat
             tc:= tc.parent;
          until (tc=nil) or (tc is TwwDataInspector);
       end;
       result:=  (tc is TwwDataInspector);
       if result then Inspector:= TwwDataInspector(tc)
       else Inspector:=nil;
    end;

  function Selection: TSelection;
  begin
    SendMessage(ac.Handle, EM_GETSEL, Longint(@Result.StartPos), Longint(@Result.EndPos));
  end;


  Function AllSelected: boolean;
  begin
     with ac do
      with Selection do
        result:= (StartPos=0) and (EndPos=GetTextLen);
  end;

  function RightSide: Boolean;
  begin
    with ac do
      with Selection do
        Result := ((StartPos = 0) or (EndPos = StartPos)) and
          (EndPos = GetTextLen);
  end;

  function LeftSide: Boolean;
  begin
    with ac do
      with Selection do
        Result := (StartPos = 0) and
        ((EndPos = 0) or (EndPos = GetTextLen) {or (isMasked and (EndPos=1))});
    if ac is TwwDBCustomEdit then with TwwDBCustomEdit(ac) do
       if isMasked and (Selection.EndPos=1) then result:= True;
  end;

  function IsInExpandedGrid: boolean;
  begin
     result:= false;
     if (Inspector.parent is TwwDBGrid) then
        with TDrawGrid(Inspector.parent) do begin
           if Inspector.Height+2 < RowHeights[Row] then
              result:= True;
        end
  end;

  function TrueFocusIsGrid: boolean;
  begin
     result:= IsChild(Inspector.Handle, GetFocus) or (GetFocus=Inspector.Handle);
  end;


begin
    ac:= screen.activecontrol;
    if ac is TwwDataInspector then  // inplaceeditor doesn't update ac
    begin
       if (TwwDataInspector(ac).inplaceeditor<>nil) and
          (TwwDataInspector(ac).inplaceeditor.handle = GetFocus) then
       begin
          ac:= TwwDataInspector(ac).inplaceeditor;
       end
    end;

    result := CallNextHookEx(KeyHook, nCode, wParam, lParam);
    if result=1 then exit;  // if someone else has processed the key then skip below code
    if ac=nil then exit;
//    if ImmGetOpenStatus(ImmGetContext(ac.handle))=True then exit; // 7/10/03 - Allow IME editor to handle keystrokes

    if ((wparam = 13) or (wparam = 9)) and
       not (GetKeyState(vk_control)<0) and
       not (GetKeyState(vk_menu)<0) and
       (GetFocus=ac.handle) then
    begin
       if (lparam and $80000000)=0 then begin
         if IsChildOfInspector(Inspector) then
         begin
           if (ovEnterToTab in Inspector.Options) or (wparam=vk_tab) then
           begin
             //5/7/2002-PYW-Handles problem with main menu and return key.
             PostMessage(Inspector.handle, WM_KEYDOWN, wparam, 0);
             result:=1;
           end
         end
       end
       else result:=1
    end
    else if (wparam = vk_f2) and
       not (GetKeyState(vk_control)<0) and
       not (GetKeyState(vk_menu)<0) then
    begin
       if IsChildOfInspector(Inspector) then
       begin
         if (lparam and $80000000)=0 then
           Inspector.FCustomControlKeyMode:= not Inspector.FCustomControlKeyMode;
       end
    end
    // Need obj property to see if we should pass vk_down, vk_up, vk_next, and vk_prior to inspector
    // Always pass vk_left, vk_right
    else if (wparam in [vk_right, vk_left, vk_down, vk_up, vk_next, vk_prior]) and
        ((lparam and $80000000)=0) and
        (GetKeyState(vk_control)<0) then
    begin
        if IsChildOfInspector(Inspector) and (ac<>Inspector)  then
        begin
           PostMessage(Inspector.handle, WM_KEYDOWN, wparam, 0);
           result:=1;
        end
    end
    else if (wparam in [vk_left, vk_right, vk_down, vk_up, vk_next, vk_prior]) and
       not (GetKeyState(vk_control)<0) and
       not (GetKeyState(vk_menu)<0) then
    begin
       if wwHaveVisibleChild(ac) then exit;

⌨️ 快捷键说明

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