Recent

Author Topic: Class TRadioGroup not found error.  (Read 1724 times)

timw4mail

  • Newbie
  • Posts: 3
Class TRadioGroup not found error.
« on: October 07, 2021, 08:58:47 pm »
I've been following along with the "Learn to program using Lazarus" book. I'm working on the Polymorphic drawing example, and it seems to compile fine. But when the program is run, I get an EClassNotFound exception, saying that the TRadioGroup class is not found.

As far as I can see, I am including the correct Unit, but the exception trace seems to go deep into the LCL. I've tried the same code on mac OS, mac OS X PPC, and Windows 10.

Is there something simple I'm missing? I've attached the relevant code.
« Last Edit: October 07, 2021, 09:27:19 pm by timw4mail »

timw4mail

  • Newbie
  • Posts: 3
Re: Class TRadioGroup not found error.
« Reply #1 on: October 07, 2021, 09:26:20 pm »
Since I can't attach the .lfm file, here it is:

Code: Pascal  [Select][+][-]
  1. object Form1: TForm1
  2.   Left = 627
  3.   Height = 240
  4.   Top = 322
  5.   Width = 320
  6.   Caption = 'Polymorphic drawing example'
  7.   ClientHeight = 240
  8.   ClientWidth = 320
  9.   OnCreate = FormCreate
  10.   LCLVersion = '2.0.12.0'
  11.   object rgShape: TRadioGroup
  12.     Left = 41
  13.     Height = 68
  14.     Top = 141
  15.     Width = 239
  16.     AutoFill = True
  17.     Caption = 'Type of FDrawing'
  18.     ChildSizing.LeftRightSpacing = 6
  19.     ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
  20.     ChildSizing.EnlargeVertical = crsHomogenousChildResize
  21.     ChildSizing.ShrinkHorizontal = crsScaleChilds
  22.     ChildSizing.ShrinkVertical = crsScaleChilds
  23.     ChildSizing.Layout = cclLeftToRightThenTopToBottom
  24.     ChildSizing.ControlsPerLine = 1
  25.     ClientHeight = 49
  26.     ClientWidth = 229
  27.     ItemIndex = 0
  28.     Items.Strings = (
  29.       'TSquare'
  30.       'TCircle'
  31.     )
  32.     OnClick = rgShapeClick
  33.     TabOrder = 0
  34.   end
  35. end
  36.  

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Class TRadioGroup not found error.
« Reply #2 on: October 07, 2021, 10:09:54 pm »
The attached project is how it was meant to be.

timw4mail

  • Newbie
  • Posts: 3
Re: Class TRadioGroup not found error.
« Reply #3 on: October 07, 2021, 11:20:40 pm »
The attached project is how it was meant to be.

Thanks. After examining the example, I was able to get it working with the following changes: https://git.timshomepage.net/tutorials/lazarus-tutorials/commit/a8c63d1f5afca18bfa5e1149b6bb6c1ce15c5245

Of these changes, what was likely the cause of my problem? Too many referenced units, or the location of the TRadioGroup reference?

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Class TRadioGroup not found error.
« Reply #4 on: October 07, 2021, 11:39:19 pm »
Too many (redundant) units referenced is not a problem. Just unnecessary words in your sources.
The compiler knows what units are required, and ignores any you have included that are not required (and gives you hint(s) that they are not needed).

 

TinyPortal © 2005-2018