Results 1 to 10 of 10

Thread: Modal Form Problem

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374

    Modal Form Problem

    I have noticed with .NET that when I display a modal form, if a place user input validation code in a click procedure

    eg. MsgBox("Please enter a valid number.")
    Text1.Focus()
    Exit Sub

    that after exiting sub the form is minimised. Has anyone else encoutered this frustrating behaviour? I can't see any obvious reason why this is happening. The form's default window state is set to normal.

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    It appears that this behaviour is dependent of your selection of the Startup Position property. Th effect you describe only happens if you set it to Windows Default.

    What puzzles me is:

    1. When the form is minimised as you describe, what is the untitled empty form left in view?

    2. The behaviour you describe is negated if you add a button to the form and use that to activate the validation event.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374
    I tried running the program from the exe (ie.not from the .NET IDE) and discovered that the form only minimises when there is a maximised window of another application in the background. However, if there is no maximised window, although the form does not minimise, the focus is not set to the text box.

    I tried all of the startup position options and the validate event without success.

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    I did not try it with other applications running, so that accounts for the difference in the results observed.


    Could we see your actual code please?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374
    VB Code:
    1. Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
    2.  
    3. If IsNumeric(Text1.Text) = False Then
    4. MsgBox("Please enter a valid number.")
    5. Text1.Focus()
    6. Exit Sub
    7. else
    8. 'etc etc
    9. End If
    10.        
    11.     End Sub

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    Thanks.

    Yes, that ties up with my experience that when you use a button event, the form (assuming there is no other application running) behaves properly.

    If you carried out the validation in the Text_Changed event of the text box, the form would minimise regardless of other applications.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374
    When there are no applications running, it still does not behave as I would expect. The form is not minimised but the text box does not take the focus as it should with Text1.Focus()

    You have to click in the text box to give it the focus.

    Is this a .NET bug? VB6 certainly doesn't behave this way.

  8. #8
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    On rechecking the behaviour, the form is NOT minimised. It is mostly hiding behind a new blank, untitled form!!!!

    However, if you then click the form it stays in view whenever you nextcarry out the validation.

    Wierd!!
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374
    I solved the problem by setting the FormBorderStyle property to Sizable.

    The problem occurs when this property is set to FixedToolWindow.

  10. #10
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    "I solved the problem by setting the FormBorderStyle property to Sizable.

    The problem occurs when this property is set to FixedToolWindow."

    That does not work for me. Were you getting the "Ghost" form as I posted?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

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