?
Solved

Name of form and panel the same?

Posted on 2002-03-12
5
Medium Priority
?
154 Views
Last Modified: 2010-04-05
Hi
Delphi allows you to put a panel on a form and change its name to Form1. This generates a lot of problems because now the compiler does not know whether I am refering to the panel or the form. Is this a bug? If not how do I specify which object I am accessing. I am using D5Ent.
Doing a Form1:=Nil causes a lot of strange problems.

Groete
Gerhardus
0
Comment
Question by:flooder
[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
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 200 total points
ID: 6855959
inside events you can use this:

Form1.Caption:= 'Hi'; // This will affect Panel caption

Self.Caption:= 'Hi'; // This will affect Form caption

Outside form:

Form1 means the form
Form1.Form1 means the panel

why did u need Form1:= nil??

Motaz
0
 

Expert Comment

by:gooder
ID: 6856004
Form1 is the instance of the form you create, when there is no object named 'form1' also;
If any, the way to access this form is to call 'Self' but not 'Form1' . And 'Form1' now is referenced to the object having this name.
                           so?
0
 
LVL 1

Author Comment

by:flooder
ID: 6856007
I create my forms runtime and when I free them I set them to nil.

Groete
Gerhardus
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6856025
how did you create forms at run-time?

if you assign an owner to your created forms, then you cann't free them manually, instead the owner will free them which this owner is freed, so that if the owner attempt to free already freed forms, access violation will occure.

Another solution is to set nill to the owner of your forms such as:

var
  Form: TForm;
begin
  Form:= TForm.Create(nil);
  Form.Show;
 ....
  Form.Free;
  Form:= nil;
end;

Motaz
0
 
LVL 1

Author Comment

by:flooder
ID: 6856061
if not assigned(myform) then
  myform:=tmyform.create(nil)
myform.show or myform.showmodal

events for myform
onclose
  Action:=cafree;
ondestroy
  myform:=nil;

This is in short how I do this

Groete
Gerhardus
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

771 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