R
RxRick
vb.NET CF newbie question.. long-time VB6 & eVB user, hence the
problem
What is the best way to show/close forms in a multiple form project?
ShowDialog works sometimes when Show doesn't, at other times Show
works when ShowDialog doesn't. I tried a half-dozen different
combinations, at this point, I am thoroughly confused.
My program starts with Sub Main, it reads a registry value, if program
is registered, [main] is loaded, if not, then [splash] is loaded
first, then [main]. From [main] user may go directly to [frm_2] or to
[frm_1] first, then to [frm_2]. The program then flows sequentially
to [frm_3] then [frm_4] (and back). Maybe better explained by a cheesy
diagram (that doesn't look good using proportional fonts):
Sub Main-->( OR )
| |
| [splash]
V |
( OR )---->[main]--->( OR )
| |
( OR ) |
| |
V V
[frm_1]----->[frm_2]---->[frm_3]---->[frm_4]
The user can then backtrack through the forms to [main]. These are
complex forms with multiple displays of data, multiple inputs and
multiple options, there is no way to compress everything down to 1 or
2 forms. And I despised the eVB way of putting frames on top of frames
on top of forms.
Sub Main code:
If boolReg Then
Application.Run(frmSplash)
Else
Application.Run(frmMain)
End If
frmSplash code to load frmMain:
' Declare new frmMain
Dim newForm As New frmMain
' Show doesn't work - have to use ShowDialog !?
newForm.ShowDialog()
newForm.Dispose()
' This doesn't actually close the form !?
' Splash form still stays in memory
Me.Close()
frmMain code to load frm_2:
Dim newForm As New frm_2
newForm.Owner = Me
newForm.ShowDialog()
newForm.Dispose()
It gets uglier when loading [frm_1] from [main], then [frm_2] from
[frm_1]
frmMain code to load frm_1
Dim newForm As New frm_1
newForm.Owner = Me
' Have to use Show, because it's not a dialog !?
newForm.Show()
frm_1 code to load frm_2
Dim newForm As New frmModel
' Setting owner here erases the global variables!?
' But without setting owner, it adds yet another open form to
the "stack"
newForm.Show()
Me.Close()
So, it's an ugly conglomerated mess that makes no sense but (somehow)
works most of the time. Problem is, it leaves forms open with no
owner, so when switching to and from other applications, unowned
screens will go blank.
I've read 3 books, and still don't get it. Some of the solutions in
these books are not supported in the compact version of .NET, and the
CF book examples are too simple.
If somebody could give me an example, or point me to a code sample
posted elsewhere, or a good book or tutorial that explains forms in
the real CF world, I would be forever grateful. (Sorry for the wordy
post)
problem
What is the best way to show/close forms in a multiple form project?
ShowDialog works sometimes when Show doesn't, at other times Show
works when ShowDialog doesn't. I tried a half-dozen different
combinations, at this point, I am thoroughly confused.
My program starts with Sub Main, it reads a registry value, if program
is registered, [main] is loaded, if not, then [splash] is loaded
first, then [main]. From [main] user may go directly to [frm_2] or to
[frm_1] first, then to [frm_2]. The program then flows sequentially
to [frm_3] then [frm_4] (and back). Maybe better explained by a cheesy
diagram (that doesn't look good using proportional fonts):
Sub Main-->( OR )
| |
| [splash]
V |
( OR )---->[main]--->( OR )
| |
( OR ) |
| |
V V
[frm_1]----->[frm_2]---->[frm_3]---->[frm_4]
The user can then backtrack through the forms to [main]. These are
complex forms with multiple displays of data, multiple inputs and
multiple options, there is no way to compress everything down to 1 or
2 forms. And I despised the eVB way of putting frames on top of frames
on top of forms.
Sub Main code:
If boolReg Then
Application.Run(frmSplash)
Else
Application.Run(frmMain)
End If
frmSplash code to load frmMain:
' Declare new frmMain
Dim newForm As New frmMain
' Show doesn't work - have to use ShowDialog !?
newForm.ShowDialog()
newForm.Dispose()
' This doesn't actually close the form !?
' Splash form still stays in memory
Me.Close()
frmMain code to load frm_2:
Dim newForm As New frm_2
newForm.Owner = Me
newForm.ShowDialog()
newForm.Dispose()
It gets uglier when loading [frm_1] from [main], then [frm_2] from
[frm_1]
frmMain code to load frm_1
Dim newForm As New frm_1
newForm.Owner = Me
' Have to use Show, because it's not a dialog !?
newForm.Show()
frm_1 code to load frm_2
Dim newForm As New frmModel
' Setting owner here erases the global variables!?
' But without setting owner, it adds yet another open form to
the "stack"
newForm.Show()
Me.Close()
So, it's an ugly conglomerated mess that makes no sense but (somehow)
works most of the time. Problem is, it leaves forms open with no
owner, so when switching to and from other applications, unowned
screens will go blank.
I've read 3 books, and still don't get it. Some of the solutions in
these books are not supported in the compact version of .NET, and the
CF book examples are too simple.
If somebody could give me an example, or point me to a code sample
posted elsewhere, or a good book or tutorial that explains forms in
the real CF world, I would be forever grateful. (Sorry for the wordy
post)