Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating my own component in a application

Posted on 1997-07-16
2
Medium Priority
?
167 Views
Last Modified: 2010-04-06
Im creating my own component (non-visual) as a desant of TComponent.
In the application that uses the component I guess I have to call the Create-constructor of my component. I name the instance of my component 'MD1' in the application. So what I say is that I have to call MD1.Create(?).
I cant find out where to place the MD1.Create(?) and as use can see I dont know which parameter to send.
The form holding the component is called Form1 and I have tried to make an OnCreate-procedure for Form1 (called FormCreate).
In Form1.FormCreate I wrote a line like this:
...
MD1.Create(Self)
...
but when I run the application I get a run-time-error in the above line saing something like...
Acess-voilation....FFFFFFFF.... (you know it).
I figure that Self (From1) is not even Created itself by now (when FormCreate is called).

By the way. What I want to know is:
- Where should I put MD1.Create(?) and what parameter should I send with it.
- I would also like to know where Delphi Creates all the components of the form that is put on is visualy.

Thanx - Steff
0
Comment
Question by:steff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 400 total points
ID: 1338981
You should write something like this:
procedure Form1.FormCreate(Sender...
...
  MD1 := TMD{Classname}.Create(Self{or nil if you want});
  MD1.Property := Some_Property_value;
...

Delphi creates all components right before FormCreate(OnCreate).

/// John

0
 

Author Comment

by:steff
ID: 1338982
The answer was precis what I wanted. The comment on when Delphi creates its components should have been alitle more specific - like I what procedure excactly (but what the ....)

Thanx - Steff
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question