zoukankan      html  css  js  c++  java
  • 给cxGrid 鼠标所在行加个大框框

    声明:本类来自cxGrid中的一个demo

    View Code
    unit RecStyle;

    interface

    uses
    Controls, Classes, Messages, Types;

    type
    TMycxDraw = class(TWinControl)
    private
    FAPoint: Tpoint;
    procedure SetAPoint(const Value: Tpoint);
    protected
    procedure AdjustFrameRgn;
    procedure Resize; override;
    public
    constructor Create(AOwner: TComponent); override;
    published
    property APoint: Tpoint read FAPoint write SetAPoint;
    end;

    implementation

    uses
    Windows, Graphics;

    procedure TMycxDraw.AdjustFrameRgn;
    const
    AElipsWidth = 4;
    var
    ARgn1, ARgn2: HRGN;
    ARect: TRect;
    begin
    if Parent <> nil then
    begin
    ARect := Rect(0, 0, Width, Height);
    ARgn1 := CreateRoundRectRgn(ARect.Left, ARect.Top, ARect.Right,
    ARect.Bottom, AElipsWidth, AElipsWidth);
    InflateRect(ARect, -2, -2);
    ARgn2 := CreateRoundRectRgn(ARect.Left, ARect.Top, ARect.Right,
    ARect.Bottom, AElipsWidth, AElipsWidth);
    CombineRgn(ARgn1, ARgn2, ARgn1, RGN_XOR);
    SetWindowRgn(Handle, ARgn1, True);
    DeleteObject(ARgn1);
    DeleteObject(ARgn2);
    end;
    end;

    constructor TMycxDraw.Create(AOwner: TComponent);
    begin
    inherited Create(AOwner);
    Color := clRed;
    end;

    procedure TMycxDraw.Resize;
    begin
    AdjustFrameRgn;
    inherited;
    end;

    procedure TMycxDraw.SetAPoint(const Value: Tpoint);
    begin
    FAPoint := Value;
    end;

    end.

    实例化:

    AFrameControl := TMycxDraw.Create(Self);
    AFrameControl.Parent := Self;
    AFrameControl.Visible := False;

    cxGrid中设置 :

    procedure TMainForm.cxMyDBCardMouseMove(Sender: TObject; Shift: TShiftState;
    X, Y: Integer);
    Var
    AHitTest: TcxCustomGridHitTest;
    ATrackItem: TcxCustomGridTableItem;
    ATrackRec: TcxCustomGridRecord;
    begin
    AHitTest := (Sender as Tcxgridsite).GridView.ViewInfo.GetHitTest(X, Y);
    if AHitTest is TcxGridRecordCellHitTest then
    begin
    ATrackItem := TcxGridRecordCellHitTest(AHitTest).Item;
    ATrackRec := TcxGridRecordCellHitTest(AHitTest).GridRecord;
    //设置位置
    AFrameControl.Left := ATrackRec.ViewInfo.RealBounds.Left + cxSplitter1.Left
    + cxSplitter1.Width + 3;
    AFrameControl.Top := ATrackRec.ViewInfo.RealBounds.Top + cxPageControl1.Top
    + cxHeader6.Height + Panel1.Height + 4;
    AFrameControl.Width := ATrackRec.ViewInfo.Width;
    AFrameControl.Height := ATrackRec.ViewInfo.Height;
    AFrameControl.Visible := True;
    end;
    end;

    效果:





  • 相关阅读:
    对我影响最大的老师
    秋季学习总结
    介绍自己
    搭建新环境的准备工作
    我的技术博客开通啦!!
    java数组及数组的插入,删除,冒泡算法
    包(package)以及面向对象三个基本特征(继承)的介绍
    常用的Arrays类和二维数组以及二分法的介绍
    构造方法、封装、关键字(this、static)和代码块的介绍
    类和对象的介绍
  • 原文地址:https://www.cnblogs.com/xspace/p/2248672.html
Copyright © 2011-2022 走看看