Results 1 to 12 of 12

Thread: Form.Show method

  1. #1

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168

    Unhappy 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:
    1. Module modMain
    2.     Sub Main()
    3.         Dim clsf As New Form1()
    4.         clsf.Show()
    5.     End Sub
    6. 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.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    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:
    1. Module modMain
    2.     Sub Main()
    3.         Dim clsf As New Form1()
    4.         clsf.Show()
    5.     End Sub
    6. 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.

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Hinder ****ed up, lol

    Anyway, just do an Application.Start(Form1)

  4. #4
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    Originally posted by kasracer
    Hinder ****ed up, lol

    Anyway, just do an Application.Start(Form1)






    You can't use the Application Namespace in a module

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Originally posted by Hinder






    You can't use the Application Namespace in a module
    Why?

  6. #6
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    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

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  8. #8
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Hinder






    You can't use the Application Namespace in a module
    Yeah that is wrong, lol. I've used it on the past, like 3 programs I've made.

  9. #9
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    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*


  10. #10

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168
    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 .

  11. #11
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  12. #12

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168

    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
  •  



Click Here to Expand Forum to Full Width