Displaying different forms as startsup Object- vb 2005

M

Maverick

Hi Everyone,
I am facing an issue, hope if any of you guys could help me out.
My application have form 1,2 and 3, In some cases my application
starts up with form 1 and there are certaining cases where I have to
skip form 1 (and its functionality) and display from 2 as start up
object.

To overcome come this,I unchecked the "Enables application framework"
checkbox and start my project from sub Main in Module.
Now I am facing another issue in this approach is that before calling
to any form if I display any message to user by MessageBox.Show
("text") method application appears on taskbar with vs project default
icon (Icon that appears if we dont mention any icon for our project in
Project properties). Similarly on ALT+Tab combination default icon
appear in place of my application icon.

Can you help me how to overcome this and what would be the best
approach in my case to alter the form display sequence.

Regards,
Haroon.
 
A

Aaron

Maverick said:
Hi Everyone,
I am facing an issue, hope if any of you guys could help me out.
My application have form 1,2 and 3, In some cases my application
starts up with form 1 and there are certaining cases where I have to
skip form 1 (and its functionality) and display from 2 as start up
object.

To overcome come this,I unchecked the "Enables application framework"
checkbox and start my project from sub Main in Module.

This tells me that you are using VB as your language. Also you did not need
to do this.
If you wanted to change the startup form at runtime you can do this with the
application framework enabled.
It would be done through the StartUpEvent.
Now I am facing another issue in this approach is that before calling
to any form if I display any message to user by MessageBox.Show
("text") method application appears on taskbar with vs project default
icon (Icon that appears if we dont mention any icon for our project in
Project properties). Similarly on ALT+Tab combination default icon
appear in place of my application icon.

AFAIK you cannot use MessageBox and still have an application icon show up
in the title bar.
What you would need to do is create your own form to show in this case.

Dim MyMessageBoxForm as new frmMessage()
MyMessageBoxForm.ShowDialog()

Can you help me how to overcome this and what would be the best
approach in my case to alter the form display sequence.


<STAThread()> _
Public Shared Sub Main()

Dim FormToChoose As Integer = 1

Dim frmTemp As Windows.Forms.Form = Nothing
Dim MyMessageBoxForm as new frmMessage()



Select Case MyMessageBoxForm.ShowDialog()

Case 0
frmTemp = New Form1()

Case 1
frmTemp = New Form2()

Case 2
frmTemp = New Form3()

Case 3
frmTemp = New Form4()

End Select


Application.Run(frmTemp)

End Sub
 
A

Aaron

I'd like to say sorry if my first reply was confusing, I was a little short
on time yesterday when I posted. I took some more time this morning and
finished what I would have done.

Here is the Sub Main class

Friend Class AppManager

<STAThread()> _
Public Shared Sub Main()

Dim MyMessageBoxForm As New MyMessage()


Dim frmTemp As Windows.Forms.Form = Nothing

Select Case MyMessageBoxForm.ShowDialog()

Case DialogResult.Abort
frmTemp = New Form1()

Case DialogResult.Cancel
frmTemp = New Form2()

Case DialogResult.Ignore
frmTemp = New Form3()

Case DialogResult.No
frmTemp = New Form4()

End Select


Application.Run(frmTemp)

End Sub
End Class

And since my reason was only to test I made another form to act as the
messagebox called MyMessage. This
form had 4 buttons on it. Clicking a button determines which form will be
the Main form. I just used the first 4 of the
DialogResult enums as flags to the main form to determine which one had been
choosen.

Public Class MyMessage

Private Sub ButtonClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _
Button1.Click, Button2.Click, Button3.Click, Button4.Click

Select Case Convert.ToInt32(DirectCast(sender,
Button).Name.Substring(6))
Case 1 'button1
'Form1 as startup form
Me.DialogResult = Windows.Forms.DialogResult.Abort

Case 2 'button2
'Form2 as startup form
Me.DialogResult = Windows.Forms.DialogResult.Cancel

Case 3 'button3
'Form3 as startup form
Me.DialogResult = Windows.Forms.DialogResult.Ignore

Case 4 'button4
'Form4 as startup form
Me.DialogResult = Windows.Forms.DialogResult.No

End Select

Me.Close()


End Sub

End Class
 

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