Forms Creation Question

A

Aaron

I need to know whether or not every form for a project in all namespaces is
created when an application is launched or not. I'm using the singleton
method now for my forms and I'm not sure why, but sometimes the emulator is
crashing saying it's low on memory when I try opening and closing
forms...still haven't pinpointed exactly what situation it happens under,
but if I know that the forms are all created and reside in memory at
startup, this would help diagnose the potential problem. Once I get the
answer to this question, I'll probably have more until I get this forms
thing down in C#, but I need to know this first.

Thanks
 
T

Tim Wilson

Default instances of Forms do not exist. You must create an instance of a
Form before showing it.
 
A

Aaron

OK, while that makes sense, I still don't understand why each instance of a
form creates a separate task on a PPC. I have an Ipaq 5555 and using ITask
I show tons of instances of my app opened, only because a bunch of forms
were created when I launched them throughout the process of testing my app.
I was always use to eMbedded Visual Basic which created only one instance of
your app, regardless of how many forms were launched. I need to know if
there is a way to rectify this problem as my client will not be happy to see
this type of thing happening.

Another question is why when I call this code to close out my form:

frmPSA.GetInstance().Close();

it does nothing, essentially locking my app up, but not literally, and I
have even added the following code to my forms since they use the singleton
method:
protected override void OnClosed(EventArgs e)

{

base.OnClosed(e);

instance = null;

}

can anyone give me assistance on either of these matters?
 
P

Peter Foot [MVP]

Because the task manager on Pocket PC doesn't actually enumerate the
processes on the device, it merely creates a list of the captions of all the
visible top level forms. You can work around this by setting the caption to
nothing "" when in the background so only your current form will appear.

Peter
 
A

Aaron

For the most part this works; however, when switching between forms then,
I'm getting "Start" flashing back and forth between my app name in the start
menu area at the top of the screen. Here's an example of a call where this
happens...any suggestions?

private void btnInfo_Click(object sender, System.EventArgs e)

{

frmInfo.GetInstance().lblHeader.Text = "General Information";

frmInfo.GetInstance().txtInfo.Text = "Please select from the options
below.";

frmInfo.GetInstance().btnScreenTool.Visible = true;

this.Text = ""; // set form caption to nothing

frmInfo.GetInstance().Text = "My App"; // set form opening to application
name

frmInfo.GetInstance().Show();

}
 
A

Aaron

Nope, still the same. The only service pack I could find was the .NET
Framework Service Pack 2, so I installed it, rebooted my computer, rebuilt
the project in VS .NET, recreated the cab, then installed it on my PPC and
same result. Were you speaking of a different service pack, otherwise I'm
back to square one with the annoying flashing.
 
J

Jan Yeh_eMVP

My way is to set the unused forms as hidden by Form.Hide().
ex. Set Form2 as active form
Form2.Show()
Form1.Hide()
and switch back to Form1
Form1.Show()
Form2.Hide()

This can solve your first problem...
However, you better watch out when you switch between forms,
Form.Activated event will be triggered.

--

Best Regards,

Jan Yeh
MVP - Windows CE.NET, MCSD.NET, .NETcf consultant
http://blog.mvpcn.net/janyeh
 
D

Daniel Moth

Long shot but setting the following in the registry to 0 might help (it
certainly prevents animation of my forms when they come up, not sure about
your flashing form though): HKLM\System\GWE\Animate

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top