Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Thread Tools Display Modes
Old 05-05-2018, 03:29 PM
oxygen oxygen is offline
Junior Member
Join Date: May 2018
Posts: 9
Question Runtime error Resource TClass not found

Hi. I am a newbie in delphi I am trying to build my own class.

Main file with a form is Uc_heb1.pas. The class I am trying to use here is Testy.pas.

unit Testy;


  WinTypes, WinProcs, Messages, ExtCtrls, Dialogs,
  StdCtrls, Controls, Classes, // Graphics, Gauges, 
  Forms, Menus, SysUtils,
//  Uc_obr2,vyslheb, jmeno, book, Buttons,
//  uspech,testfnt, Napoveda,antiwin,otviram,
  functions, konstanty,

  TTesty = class(TForm)
    i: integer;
    Nic: TMenuItem;
    N1: TMenuItem;
    Testy: TMenuItem;
    okruhy1: TMenuItem;

    langMenuItems : array of TMenuItem;
    SubMenuItems : Array of TMenuItem;
    SubMenuItemsLoaded : Array [0..maxTestItems-1] of boolean;
    TestyDirs, SubDirs : TStringList; // for folders search
    dir : string;

    allBigger, skipFontTest, fontSizeSmall, fontSizeNormal, fontSizeLarge,
    difficultyEasy, difficultyNormal, difficultyHarder, difficultyHard,
    testyDirFound : Boolean;
    TestyDir : string;

    fileMenu: array [0..maxRecentFiles-1] of string;

    lanCount: integer; // počet jazyků načtených ze souboru .ini
    JazykyIndexy : TStrings;
    Jazyky : Array [0..maxTestItems-1] of string; // Language names ... associated with JazykyFolders
    JazykyFolders : Array [0..maxTestItems-1] of string; // Folder names associated with Jazyky menu items
    JazykySelected : Array [0..maxTestItems-1] of string; // Jazyky sub-folder folder specification

    procedure readINI;
    procedure writeINI;
    procedure JazykyInitiate;
    procedure DynMenu;
    procedure upravmenu;

var TestyOrganizer: TTesty;



procedure TTesty.upravmenu;
Then the Uc_heb1.pas:
unit Uc_heb1;


  WinTypes, WinProcs, Messages, ExtCtrls, Dialogs,
  StdCtrls, Controls, Graphics, Gauges, Classes,
  Forms, Menus, SysUtils,
  Uc_obr2,vyslheb, jmeno, book, Buttons,
  uspech,testfnt, Napoveda,antiwin,otviram,
  functions, konstanty, Testy,

  TForm1 = class(TForm)
procedure TForm1.FormCreate(Sender: TObject);
var i,j: integer;
    FilesTmpI : integer;
    list: TStringList;

TestyOrganizer := TTesty.Create(Form1);
TestyOrganizer.readINI; // step 1.
TestyOrganizer.JazykyInitiate;        // step 2.
TestyOrganizer.DynMenu;        // step 3.
The error happens here:
TestyOrganizer := TTesty.Create(Form1);

with a message
UC_HEB.exe raised exception ... Resource TTesty not found

I can run the program, but this message appears always when I start it.
Reply With Quote
Old 05-07-2018, 09:39 AM
Norrit Norrit is offline
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335

My guess is that you've written a form descendant just from code, so without the dfm. If you want a form descendant just add a new form through menu to your app. Then all that is needed for the base of the form is auto-generated.
If it's not a form (what I suspect) you should descent it from something different, TComponent/TObject for example (or none should be ok aswell).

What I meen is replace
TTesty = class(TForm)
TTesty = class(TComponent)

Since I don't see any reason why this should be a form in the beginning. It looks like a placeholder for TMenuItems, which I guess should be added to your form. So I guess you need to add a property of type TMainMenu to your TTesty class. Introduce your own constructor in which you set the private variable of that property

But start simple, just a basic framework with the easiest implementation possible and extend from there. Here you already tried complete implementation including variables and methods.
And just a pointer, instead of variables use properties!
And just personal favor, get rid of the array, T(Object)List is easier and much more readable. Array is something out of the Pascal time period, heavily used at schools but in real life kind of obsolete (true, there are some cases in which it's debatable).
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT. The time now is 02:31 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.