Recent

Author Topic: Grid, accent and drawText  (Read 2218 times)

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 132
Grid, accent and drawText
« on: August 27, 2016, 09:00:09 am »
Hi,

I want do draw in a cell of a TDBGrid some content so a write this code

Code: Pascal  [Select][+][-]
  1.    s:=field.asString;
  2.   r:=rect;
  3.   inflaterect(r,-1,-1);
  4.   r.right:=r.right-getsystemmetrics(SM_CXVSCROLL);
  5.   drawtext(canvas.handle,pchar(s),-1,r,DT_WORDBREAK or DT_NOPREFIX);  

well the issue is that if the content is something like "più" in the cell it is display pi and some strange char. The other strange think is that if a write
  drawtext(canvas.handle,'più',-1,r,DT_WORDBREAK or DT_NOPREFIX);

everything works fine.
I use a Sqlite database.

Many thanks



Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Grid, accent and drawText
« Reply #1 on: August 27, 2016, 05:16:25 pm »
I got older Lazarus 1.7 trunk (r.51976) and both ThemeServices.DrawText() methods expect string as a parameter. Maybe they expected PChar in the past, I'm not sure now. Anyway, try to replace "pchar(s)" with simply "s".
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 132
Re: Grid, accent and drawText
« Reply #2 on: August 29, 2016, 07:08:02 am »
I am using Lazarus 1.6 (official release). the drawtext procedure does not allow me to use directly s but only a pointer, the drawtext that I am using is in redef.inc.

Anyway, I finally solved changing the code as below

Code: Pascal  [Select][+][-]
  1.    s:=field.asWideString;
  2.   r:=rect;
  3.   inflaterect(r,-1,-1);
  4.   r.right:=r.right-getsystemmetrics(SM_CXVSCROLL);
  5.   drawtextw(canvas.handle,pwidechar(s),-1,r,DT_WORDBREAK or DT_NOPREFIX);  
  6.  

Thanks

 

TinyPortal © 2005-2018