Lazarus

Free Pascal => Beginners => Topic started by: oog on January 03, 2018, 03:16:23 pm

Title: Newbie Question - how to compile demo code from wiki?
Post by: oog on January 03, 2018, 03:16:23 pm
I have installed lazarus v1.8.0 on Windows 10, 64 Bit.
I successfully compiled the tutorial demo (Change Button Text "Click" to "Click again") so I think the compiler is working.
Now I want to proceed with the examples from the Wiki.
(3.4 Graphics -> Lazarus TCanvas -> Drawing a text limited on the width)

The examples do not compile.

Code: Pascal  [Select][+][-]
  1. // First calculate the text size then draw it
  2. TextBox := Rect(0, currentPos.Y, Width, High(Integer));
  3. DrawText(ACanvas.Handle, PChar(Text), Length(Text),
  4.   TextBox, DT_WORDBREAK or DT_INTERNAL or DT_CALCRECT);
  5.  
  6. DrawText(ACanvas.Handle, PChar(Text), Length(Text),
  7.   TextBox, DT_WORDBREAK or DT_INTERNAL);
  8.  


I get some error messages

Code: [Select]
Projekt kompilieren, Ziel: tutbmp01.exe: Exit code 1, Fehler: 13
tutbmp01u.pas(36,1) Error: Identifier not found "TextBox"
tutbmp01u.pas(36,20) Error: Identifier not found "currentPos"
tutbmp01u.pas(37,1) Error: Identifier not found "DrawText"
tutbmp01u.pas(37,10) Error: Identifier not found "ACanvas"
tutbmp01u.pas(38,3) Error: Identifier not found "TextBox"
tutbmp01u.pas(38,12) Error: Identifier not found "DT_WORDBREAK"
tutbmp01u.pas(38,28) Error: Identifier not found "DT_INTERNAL"
tutbmp01u.pas(38,43) Error: Identifier not found "DT_CALCRECT"
tutbmp01u.pas(40,1) Error: Identifier not found "DrawText"
tutbmp01u.pas(40,10) Error: Identifier not found "ACanvas"
tutbmp01u.pas(41,3) Error: Identifier not found "TextBox"
tutbmp01u.pas(41,12) Error: Identifier not found "DT_WORDBREAK"
tutbmp01u.pas(41,28) Error: Identifier not found "DT_INTERNAL"

What do I need to compile the examples?

Is there another tutorial that helps?
Title: Re: Newbie Question - how to compile demo code from wiki?
Post by: Blaazen on January 03, 2018, 03:32:56 pm
There is only a code snippet on the wiki, they probably assume some experience. You need to declare TextBox: TRect and add LCLType to uses and maybe more.
But there are examples that comes with Lazarus in directory lazarus/examples. Try them.
Title: Re: Newbie Question - how to compile demo code from wiki?
Post by: oog on January 03, 2018, 03:45:14 pm
Thank you for your quick reply. Now I've found the examples. I will try them.
Title: Re: Newbie Question - how to compile demo code from wiki?
Post by: wp on January 03, 2018, 03:46:26 pm
Yes. I agree that many wiki articles are written very carelessly. To be able to fix it you should post the link to the article.
Title: Re: Newbie Question - how to compile demo code from wiki?
Post by: Kays on January 08, 2018, 12:19:14 am
[…] To be able to fix it you should post the link to the article.
Huh? Just copy and past some adequately long quote to the wiki's search, and you'd know it's the Developing with Graphics (http://wiki.freepascal.org/Developing_with_Graphics) article before you can say Jack Robinson.
TinyPortal © 2005-2018