Mega Search
23.2 Million


Sign Up

Make a donation  
Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32

Hi,

I am trying to create a new form as below.

The problem is when it gets to frmMain.Create(Application); the 
following error occurs:

"Access violation at address 0046D929 in module 'Client.exe'. Read of 
address 00000000."

What am I doing wrong? And is there a more elegant way of doing it? I 
need the new form to be independent so that it exists even after the 
original form is destroyed.

Thanks,



unit Login;

interface

uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
   Dialogs, StdCtrls,Forms, Main;

type
   TfrmLogin = class(TForm)
     Label1: TLabel;
     Label2: TLabel;
     txtComputer: TEdit;
     txtPassword: TEdit;
     Button1: TButton;
     Button2: TButton;
     procedure Button1Click(Sender: TObject);
     procedure Button2Click(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;

var
   frmLogin: TfrmLogin;
   frmMain: Tfrmmain;

implementation

{$R *.dfm}

procedure TfrmLogin.Button1Click(Sender: TObject);
begin
  frmMain.Create(Application);
  frmMain.Visible := true;
  frmMain.Caption := 'Connected to: ' + txtComputer.Text;
  Destroy;
end;

procedure TfrmLogin.Button2Click(Sender: TObject);
begin
   Application.Terminate;
end;

end.

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 26-Dec-2007, at 11:47 PM EST
From: Mark Smith
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
Mark Smith wrote:

> > You don't have to. Don't believe everything others tell you. Delphi
> > will generate standalone exes by default.
> 
> I know thats my point, the OP was suggesting I switch to C#...

Which will NOT generate standalone apps (at least, not without help),
and runs on .NET. 

-- 
Rudy Velthuis [TeamB]        http://www.teamb.com

"A low voter turnout is an indication of fewer people going to 
 the polls." -- George W. Bush

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 10-Jan-2008, at 7:59 PM EST
From: Rudy Velthuis [TeamB]
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
Rudy Velthuis [TeamB] wrote:
> Mark Smith wrote:
> 
>> That's too bad. The thing that has attracted me to Delphi is the fact
>> it generates stand alone exe files.
>>
>> I don't want to have to distribute huge .net runtimes with my
>> application or expect my customers to have to hunt it down and
>> install themselves :(
> 
> You don't have to. Don't believe everything others tell you. Delphi
> will generate standalone exes by default.
> 

I know thats my point, the OP was suggesting I switch to C#...

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 10-Jan-2008, at 6:41 PM EST
From: Mark Smith
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
"Ian Boyd"  wrote in message
news:4784f29c$1@newsgroups.borland.com...

>
> a terrible component addon mechanism,

I never found it terrible....

>lack of official support,

The support is actually great considering some of the "team" members have
been doing this since the early 90's


> few references or examples on the internet, sparse documentation

I find tons of Articles and documents on the web.
What is great, is that stuff written for D2 still works (sometimes with a
minor tweak).
And if it is something new, i do go to the MDSN for API info, and thats easy
to translate.



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 10-Jan-2008, at 11:36 AM EST
From: Todd Frankson
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
Mark Smith wrote:

> That's too bad. The thing that has attracted me to Delphi is the fact
> it generates stand alone exe files.
> 
> I don't want to have to distribute huge .net runtimes with my
> application or expect my customers to have to hunt it down and
> install themselves :(

You don't have to. Don't believe everything others tell you. Delphi
will generate standalone exes by default.

-- 
Rudy Velthuis [TeamB]        http://www.teamb.com

"Vote early and vote often." -- Al Capone (1899-1947)

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 10-Jan-2008, at 12:26 PM EST
From: Rudy Velthuis [TeamB]
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
>> We have a large collection of hacks and workarounds that we've discovered 
>> over the years. Get out. Get out now. Get Visual C# Express Edition.
....
> That's too bad. The thing that has attracted me to Delphi is the fact it 
> generates stand alone exe files.

Don't worry.  He is exaggerating.  He's a bitter newsgroup poster :)

Look, Delphi has bugs, and it has quirks.  It's like any other system, you 
just need to know it.  In general though it is great.  Having used VC# 
Express, there's no way I'd choose it over Delphi (it's not exactly bugfree 
either, of course, no is it without its own perhaps more annoying quirks), 
and I think the original poster probably wouldn't either... because here he 
is on a Delphi newsgroup, so surely he must also be using it!

My only suggestion if you're using Delphi and using newgroups is, stay away 
from .non-technical - it has a reputation for threads whinging and 
complaining and sounding like the poster above, basically, and frankly it 
all just gets a bit much after a while.  The rest of the groups are more 
focused with people who are more normal and helpful.

Good luck!

Cheers,

David


Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 10-Jan-2008, at 12:04 PM EST
From: David M
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
Ian Boyd wrote:
> 
> The cons of it are the huge amount of quirks and bugs, a terrible component 
> addon mechanism, lack of official support, very small peer support system, 
> few references or examples on the internet, sparse documentation, and 
> (today) a poor IDE. 
> 

As a newcomer I have used both the free editions of Delphi 7 and 2006 
and I prefer the new IDE. (Probably because I am used to the Visual 
Studio IDE)

The old one seemed to lack any dropdown lists to show members of 
classes, not much formatting etc. Unless I was missing a way to enable this?

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 9-Jan-2008, at 10:19 PM EST
From: Mark Smith
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
Ian Boyd wrote:

> a terrible component addon mechanism

Not anymore:

  http://rvelthuis.de/programs/compinstall.html

-- 
Rudy Velthuis [TeamB]        http://www.teamb.com

"Glory is fleeting, but obscurity is forever."
-- Napoleon Bonaparte (1769-1821)

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 9-Jan-2008, at 6:30 PM EST
From: Rudy Velthuis [TeamB]
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
> That's too bad. The thing that has attracted me to Delphi is the fact it 
> generates stand alone exe files.

> I don't want to have to distribute huge .net runtimes with my application 
> or expect my customers to have to hunt it down and install themselves :(

Yes. Delphi has a blazing fast compiler, single .exe deployment, compiles to 
native code, (used to have) a great IDE, a small dedicated peer support 
system, and the source code for the code library is open source.


The cons of it are the huge amount of quirks and bugs, a terrible component 
addon mechanism, lack of official support, very small peer support system, 
few references or examples on the internet, sparse documentation, and 
(today) a poor IDE. 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 9-Jan-2008, at 11:12 AM EST
From: Ian Boyd
 
Re: Creating a new instance of a form  
News Group: borland.public.delphi.nativeapi.win32
> Welcome to Delphi. i've been using it for 10 years now. Delphi is full 
> of these bugs, problems, slowdowns, incompatibilities, quirks, oddities. 
> We have a large collection of hacks and workarounds that we've 
> discovered over the years. Get out. Get out now. Get Visual C# Express 
> Edition.

Thanks for the hack.

That's too bad. The thing that has attracted me to Delphi is the fact it 
generates stand alone exe files.

I don't want to have to distribute huge .net runtimes with my 
application or expect my customers to have to hunt it down and install 
themselves :(

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 6-Jan-2008, at 5:36 PM EST
From: Mark Smith