|
-
Aug 25th, 2003, 03:14 PM
#1
Thread Starter
Addicted Member
Form.Show method
Hi all big players
Here is a problem of mine:
I create a Form ("Form1") in my project and write a "Sub Main" procedure in a Module ("modMain") as :
VB Code:
Module modMain
Sub Main()
Dim clsf As New Form1()
clsf.Show()
End Sub
End Module
I set the Startup object property to "Sub Main"
The problem is it shows the form only for half second, why not get focused ?
Thanks in Adv.
-
Aug 25th, 2003, 03:19 PM
#2
Hyperactive Member
Re: Form.Show method
Originally posted by parminder
Hi all big players
Here is a problem of mine:
I create a Form ("Form1") in my project and write a "Sub Main" procedure in a Module ("modMain") as :
VB Code:
Module modMain
Sub Main()
Dim clsf As New Form1()
clsf.Show()
End Sub
End Module
I set the Startup object property to "Sub Main"
Because once you start the .Show, it basically starts on its own thread, and the Main() function continues to the end, once it ends, all attached forms close as well.. you could do a ShowDialog to hold that form open..
The problem is it shows the form only for half second, why not get focused ?
Thanks in Adv.
-
Aug 25th, 2003, 03:34 PM
#3
Hinder ****ed up, lol
Anyway, just do an Application.Start(Form1)
-
Aug 25th, 2003, 03:39 PM
#4
Hyperactive Member
-
Aug 25th, 2003, 03:48 PM
#5
-
Aug 25th, 2003, 03:52 PM
#6
Hyperactive Member
Originally posted by Edneeis
Why?
Not quite sure why, I have tried in many attempts to use the application namespace in my console/module applications with no success.. I have to access the Assembly directly to get start up directories and things of that nature.. If I'm wrong and you can access it, do tell
-
Aug 25th, 2003, 04:00 PM
#7
Thats because you are in a console application not because it is a Module. Application's full namespace is System.Windows.Forms.Application so you need to referrence its assembly to use it. If you aren't making a windows application then you'll need to reference the dll manually.
You can also show the form modally instead of making it the main form. Just use ShowDialog instead of Show.
Last edited by Edneeis; Aug 25th, 2003 at 04:04 PM.
-
Aug 25th, 2003, 04:08 PM
#8
Yeah that is wrong, lol. I've used it on the past, like 3 programs I've made.
-
Aug 25th, 2003, 04:12 PM
#9
Hyperactive Member
Originally posted by kasracer
Yeah that is wrong, lol. I've used it on the past, like 3 programs I've made.
Yea ok I've been shot down
*walks away with head hung low*
-
Aug 26th, 2003, 01:16 PM
#10
Thread Starter
Addicted Member
Thanks to all who reply.
The orignal problem is solved.
And now here is another problem (as extenstion of the origonal problem).
In my application (going to develop). It is non MDI application and I want, the user to work only at one form at a time. For this I have to use Form1.ShowDialog method. Now question is : "Is this approach is correct ?"
Thanks for your support .
-
Aug 26th, 2003, 01:25 PM
#11
Yes or you can use Application.Run and then just hide that form instead of close it until you want the whole app to close, but i'd stick with ShowDialog.
-
Aug 28th, 2003, 05:52 AM
#12
Thread Starter
Addicted Member
Form.Show method (resolved)
Thanks again for your support
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|