Hello.

Let me write one more interesting question today. I do copying of tcxGrid. On a standard grid, I did a replacement for Boolean fields like this:

procedure TFormClient.DrawGridCheckBox(Canvas: TCanvas; Rect: TRect; Checked: boolean); var DrawFlags: Integer; begin Canvas.TextRect(Rect, Rect.Left + 1, Rect.Top + 1, ' '); DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONPUSH or DFCS_ADJUSTRECT); DrawFlags := DFCS_BUTTONCHECK or DFCS_ADJUSTRECT;// DFCS_BUTTONCHECK if Checked then DrawFlags := DrawFlags or DFCS_CHECKED; DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DrawFlags); end; 

Given that TcxCanvas is of a different nature than TCanvas, I rewrite it this way:

 procedure TFormClient.DrawGridCheckBox(Canvas: TcxCanvas; Rect: TRect; Checked: boolean); var DrawFlags: Integer; StrCanvas : TCanvas; MyRect: TRect; begin StrCanvas.TextRect(Rect, Rect.Left + 1, Rect.Top + 1, ' '); Canvas.CopyRect(MyRect, StrCanvas, Rect); DrawFrameControl(Canvas.Handle, MyRect, DFC_BUTTON, DFCS_BUTTONPUSH or DFCS_ADJUSTRECT); DrawFlags := DFCS_BUTTONCHECK or DFCS_ADJUSTRECT;// DFCS_BUTTONCHECK if Checked then DrawFlags := DrawFlags or DFCS_CHECKED; DrawFrameControl(Canvas.Handle, MyRect, DFC_BUTTON, DrawFlags); end; 

However, this does not work, throws out a memory error. According to the assembler, I don’t want to look for a problem. The point is that I cannot find something similar to TextRect in tcxcanvas, since it was with his help that I redrawn ugly Boolean digits 1 and 0 and made quite a decent bird if the value is true in the grid. There is no such detailed documentation, for some reason I can’t see the modules either, so I’m guessing about what's in this TextExtend (). I would like to find something like TextRect. Who can give good advice? Is there a master on these issues)?

PS Let me remind everyone who forgot, TRect has the following structure:

  PRect = ^TRect; TRect = record case Integer of 0: (Left, Top, Right, Bottom: Longint); 1: (TopLeft, BottomRight: TPoint); end; 

    1 answer 1

    You declared StrCanvas as TCanvas , and who will create the object for you? In the first line of the method, you refer to StrCanvas.TextRect . Nothing that StrCanvas in this place = nil ?

     procedure TFormClient.DrawGridCheckBox(Canvas: TcxCanvas; Rect: TRect; Checked: boolean); var StrCanvas : TCanvas; begin StrCanvas.TextRect(Rect, Rect.Left + 1, Rect.Top + 1, ' '); 

    Want to use ready canvas, take canvas forms:

     Canvas.TextRect(Rect, Rect.Left + 1, Rect.Top + 1, ' '); 

    Just keep in mind that the text size will be considered for the font that is installed on the form.

    • Yes, I forgot to create an object), however, this does not solve the problem from where to get data into a standard canvas. That's why I left it nil for now, it’s useful for the forum). I would like to know more about the features of TcxCanvas. Canvas forms used in this case is not an option. Solved the problem in another way. Actually, the problem arose in drawing the grid field due to the fact that the boolean fields were not displayed in the tcxGrid component, which works in the postgres bundle. In the ODBC connection settings, there was a setting to associate a boolean type with a char, hence all these dances by the fire) - IntegralAL
    • Thanks for any help, problem solved. Good luck with all the forum users here) - IntegralAL