Board index » cppbuilder » Opening New Form in MDIApp

Opening New Form in MDIApp


2005-03-03 11:12:35 AM
cppbuilder19
When I do this I get a violation error.
if (ExtractFileExt(OpenDialog->FileName).LowerCase() == ".xms" )
{
MSXCBEForm = new TMSXCBEForm(this);
}
For some reason MSXCBForm = Null, What do I need to do to create this new
form.
Additionally, what I really want to once I've created the new form is to
open it with information from the OpenDialog as shown below. But again I am
not understanding what is going because it doesn't work.
if (ExtractFileExt(OpenDialog->FileName).LowerCase() == ".xms" )
{
MSXCBEForm = new TMSXCBEForm(this);
MSXCBEForm->OpenMSXFile(fIn, ansiFileName);
}
I would appreciate any guidance or suggestions on how to open a new form and
execute one of its functions with some parameters.
Thanks,
Kiwi
 
 

Re:Opening New Form in MDIApp

On Wed, 2 Mar 2005 22:12:35 -0500, Kiwi wrote:
Quote
For some reason MSXCBForm = Null, What do I need to do to create this new
form.
Do yourself a favor and do this in multiple steps.
Are you getting an access violation, or is MSXCBEForm (whatever that
is) not getting set?
Why are you having this as the owner (not saying you shouldn't just
asking what the rationale is)? Should it be NULL instead?
--
Good luck,
liz
 

Re:Opening New Form in MDIApp

Quote
>For some reason MSXCBForm = Null, What do I need to do to create this new
>form.
Do yourself a favor and do this in multiple steps.
Sorry, I don't understand what you mean, with respect to:
if (ExtractFileExt(OpenDialog->FileName).LowerCase() == ".xms" )
{
MSXCBEForm = new TMSXCBEForm(this); // This is attempting to open
a new form; something that worked for another form.
}
The form gets opened and when I follow it with Debug and look at one of the
first lines in the form constructor e.g.
MSXCBEForm->Height = 650;
MSXCBEForm is equal to NULL and I get an access violation error associated
with vcl60.bpl when that instruction is executed.
Thanks,
Kiwi
 

{smallsort}

Re:Opening New Form in MDIApp

"Kiwi" < XXXX@XXXXX.COM >wrote in message
Quote
When I do this I get a violation error.
Where exactly? Please narrowy it down further.
Quote
For some reason MSXCBForm = Null
Where is it NULL exactly? Again, please be more specific.
Quote
What do I need to do to create this new form.
You are already doing it.
Quote
if (ExtractFileExt(OpenDialog->FileName).LowerCase() == ".xms" )
{
MSXCBEForm = new TMSXCBEForm(this);
MSXCBEForm->OpenMSXFile(fIn, ansiFileName);
}
There is absolutely nothing wrong with that code. The only thing that can
possible go wrong would have to inside of the TMSXCBEForm class itself. You
did not show any of that code.
Gambit
 

Re:Opening New Form in MDIApp

On Thu, 3 Mar 2005 00:52:51 -0500, Kiwi wrote:
Quote
MSXCBEForm->Height = 650;
That shouldn't be in the constructor.
The constructor should merely refer to the member of the object
--
Good luck,
liz
 

Re:Opening New Form in MDIApp

Liz Albin wrote:
Quote
>MSXCBEForm->Height = 650;

That shouldn't be in the constructor.

The constructor should merely refer to the member of the object
Liz means that you could do with
Height = 650;
there.
Hans.
 

Re:Opening New Form in MDIApp

"Kiwi" < XXXX@XXXXX.COM >wrote in message
Quote
one of the first lines in the form constructor e.g.

MSXCBEForm->Height = 650;

MSXCBEForm is equal to NULL
As it should be. The global MSXCBEForm variable is not being assigned until
AFTER the constructor exits. You should not be using the MSXCBEForm
variable from inside of the TMSXCBEForm class's methods anyway. Use the
implicit 'this' pointer instead:
this->Height = 650;
Or simply:
Height = 650;
Gambit
 

Re:Opening New Form in MDIApp

Quote
As it should be. The global MSXCBEForm variable is not being assigned
until
AFTER the constructor exits. You should not be using the MSXCBEForm
variable from inside of the TMSXCBEForm class's methods anyway. Use the
implicit 'this' pointer instead:
Thankyou, this was my problem, cleaning up my form made all the difference.