Solved

Name of form and panel the same?

Posted on 2002-03-12
5
152 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Dbf export problem to a Visual Foxpro application 6 233
Delphi selector screen 2 92
Working with hours 3 74
tidtcpserver connection lost handle 2 110
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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