Solved

Name of form and panel the same?

Posted on 2002-03-12
5
148 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
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
I create my forms runtime and when I free them I set them to nil.

Groete
Gerhardus
0
 
LVL 7

Expert Comment

by:Motaz
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now