tmap to eliminate flicker and } begin { brush origin tics in painting / scrolling. } Width := Max(Width, Right - Left); Height := Max(Height, Bottom - Top); R := Rect(DX, DY, Right - Left - 1, Bottom - Top - 1); B := Rect(0, 0, Right - Left, Bottom - Top); end; with DrawBitmap.Canvas do begin Font := ACanvas.Font; Font.Color := ACanvas.Font.Color; Brush := ACanvas.Brush; Brush.Style := bsSolid; FillRect(B); SetBkMode(Handle, TRANSPARENT); DrawText(Handle, PChar(Text), Length(Text), R, AlignFlags[Alignment]); end; ACanvas.CopyRect(ARect, DrawBitmap.Canvas, B); finally DrawBitmap.Canvas.Unlock; end; end; end;
constructor TCustomVDBGrid.Create(AOwner: TComponent); var Bmp: TBitmap; begin inherited Create(AOwner); inherited DefaultDrawing := False; FAcquireFocus := True; 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); Bmp.LoadFromResourceName(HInstance, bmMultiDot); FIndicators.AddMasked(Bmp, clWhite); Bmp.LoadFromResourceName(HInstance, bmMultiArrow); FIndicators.AddMasked(Bmp, clWhite); finally Bmp.Free; end; FTitleOffset := 1; FIndicatorOffset := 1; FUpdateFields := True; FOptions := [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit]; DesignOptionsBoost := [goColSizing]; VirtualView := True; UsesBitmap; ScrollBars := ssHorizontal; inherited Options := [goFixedHorzLine, goFixedVertLine, goHorzLine, goVertLine, goColSizing, goColMoving, goTabs, goEditing]; FVertical := False; FOnlyOne := False; FTitlesWidth := 100; FColumns := CreateColumns; inherited RowCount := 2; inherited ColCount := 2; FDataLink := TGridDataLink.Create(Self); Color := clWindow; ParentColor := False; FTitleFont := TFont.Create; FTitleFont.OnChange := TitleFontChanged; FSaveCellExtents := False; FUserChange := True; FDefaultDrawing := True; FUpdatingEditor := False; FBookmarks := TBookmarkList.Create(Self); HideEditor; end;
destructor TCustomVDBGrid.Destroy; begin FColumns.Free; FColumns := nil; FDataLink.Free; FDataLink := nil; FIndicators.Free; FTitleFont.Free; FTitleFont := nil; FBookmarks.Free; FBookmarks := nil; inherited Destroy; ReleaseBitmap; end;
procedure TCustomVDBGrid.SetVertical(Value: Boolean); var i: integer; begin if Value <> FVertical then begin FVertical := Value; if Value then {change to vertical} begin inherited Options := inherited Options - [goColMoving]; inherited Options := inherited Options + [goRowMoving]; ScrollBars := ssVertical; for I := FIndicatorOffset to ColCount-1 do ColWidths[I] := DefaultColWidth; end else {change to horizontal} begin inherited Options := inherited Options - [goRowMoving]; inherited Options := inherited Options + [goColMoving]; ScrollBars := ssHorizontal; end; LayoutChanged; UpdateScrollBar; InvalidateEditor; ValidateRect(Handle, nil); Invalidate; end; end;
procedure TCustomVDBGrid.SetOnlyOne(Value: Boolean); begin if Value <> FOnlyOne then begin FOnlyOne := Value; LayoutChanged; UpdateScrollBar; InvalidateEditor; ValidateRect(Handle, nil); Invalidate; end; end;
procedure TCustomVDBGrid.SetTitlesWidth(Value: integer); begin if Value <> FTitlesWidth then begin FTitlesWidth := Value; if FVertical and (dgTitles in Options) then ColWidths[0] := FTitlesWidth; end; end;
function TCustomVDBGrid.AcquireFocus: Boolean; begin Result := True; if FAcquireFocus and CanFocus and not (csDesigning in ComponentState) then begin SetFocus; Result := Focused or (InplaceEditor <> nil) and InplaceEditor.Focused; end; end;
function TCustomVDBGrid.RawToDataColumn(ACol: Integer): Integer; begin Result := ACol - FIndicatorOffset; end;
function TCustomVDBGrid.DataToRawColumn(ACol: Integer): Integer; begin Result := ACol + FIndicatorOffset; end;
function TCustomVDBGrid.AcquireLayoutLock: Boolean; begin Result := (FUpdateLock = 0) and (FLayoutLock = 0); if Result then BeginLayout; end;
procedure TCustomVDBGrid.BeginLayout; begin BeginUpdate; if FLayoutLock = 0 then Columns.BeginUpdate; Inc(FLayoutLock); end;
procedure TCustomVDBGrid.BeginUpdate; begin Inc(FUpdateLock); end;
procedure TCustomVDBGrid.CancelLayout; begin if FLayoutLock > 0 then begin if FLayoutLock = 1 then Columns.EndUpdate; Dec(FLayoutLock); EndUpdate; end; end;
function TCustomVDBGrid.CanEditAcceptKey(Key: Char): Boolean; begin with Columns[SelectedIndex] do Result := FDatalink.Active and Assigned(Field) and Field.IsValidChar(Key); end;
function TCustomVDBGrid.CanEditModify: Boolean; begin Result := False; if not ReadOnly and FDatalink.Active and not FDatalink.Readonly then with Columns[SelectedIndex] do if (not ReadOnly) and Assigned(Field) and Field.CanModify and (not Field.IsBlob or Assigned(Field.OnSetText)) then begin FDatalink.Edit; Result := FDatalink.Editing; if Result then FDatalink.Modified; end; end;
function TCustomVDBGrid.CanEditShow: Boolean; begin Result := (LayoutLock = 0) and inherited CanEditShow; end;
procedure TCustomVDBGrid.CellClick(Column: TColumn); begin if Assigned(FOnCellClick) then FOnCellClick(Column); end;
procedure TCustomVDBGrid.ColEnter; begin UpdateIme; if Assigned(FOnColEnter) then FOnColEnter(Self); end;
procedure TCustomVDBGrid.ColExit; begin if Assigned(FOnColExit) then FOnColExit(Self); end;
procedure TCustomVDBGrid.ColumnMoved(FromIndex, ToIndex: Longint); begin FromIndex := RawToDataColumn(FromIndex); ToIndex := RawToDataColumn(ToIndex); Columns[FromIndex].Index := ToIndex; if Assigned(FOnColumnMoved) then FOnColumnMoved(Self, FromIndex, ToIndex); end;
procedure TCustomVDBGrid.RowMoved(FromIndex, ToIndex: Longint); begin FromIndex := RawToDataColumn(FromIndex); ToIndex := RawToDataColumn(ToIndex); Columns[FromIndex].Index := ToIndex; if Assigned(FOnColumnMoved) then FOnColumnMoved(Self, FromIndex, ToIndex); end;
procedure TCustomVDBGrid.ColWid
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] 下一页 [聊天工具]让你的MSN Messenger好友看到你在干嘛__天极Yesky [聊天工具]让你的Foxmail不再撒谎 [聊天工具]IncrediMail让你的E-mail也作秀 [常用软件]让你的Blog拥有Google日历 [常用软件][网络]Stuff Plug 让你的MSN聊天与众不同 [Delphi程序]让你的DBGridEh的Column自动适应宽度
|