Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-05-2018, 03:29 PM
oxygen oxygen is offline
Junior Member
 
Join Date: May 2018
Posts: 1
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.

Code:
unit Testy;

interface

uses
  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,
  FileCtrl;

type
  TTesty = class(TForm)
  private
    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
  public
    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;
  end;

var TestyOrganizer: TTesty;

implementation

uses
  Uc_heb1;


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

interface

uses
  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,
  FileCtrl;

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

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
  #2  
Old 05-07-2018, 09:39 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,280
Default

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)
with
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
Reply

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 11:02 PM.


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