Hello Friends,

I need help to disable the parent window form as soon as the user will open the child form....

for eg...consider daniweb...when we click on member login the background form gets grayed out....

Disabling the form is not the option cause it will just disable all the controls of the form....but I need a grayed out screen between the current child form and the parent form....

note - the parent form is not the MDI form...it is just a normal window form

and when the child form is open and if the user clicks on the main form without closing the child form then the screen should show some movement...

I tried disabling the form...changing the background of the form to opaque....but could not get through it....

Ok...I got the answer....

use form2.ShowDialog()

this will not allow the user to move to the parent form unless the child form is closed...

can anyone tell me how to add the grayed out screen???

Hi,

I'm not sure what you mean with: how to add the grayed out screen.

So I think it is the Parent form property -> IsMdiContainer and set it to True.

You could try setting the Opacity property of the main form to something like 0.5 just before you you display the modal form, then set it back to 1.0 on return.

Me.Opacity = 0.5
form1.ShowDialog()
Me.Opacity = 1.0

If you have your heart set on gray, then maybe this?

   Dim bc As Color = Me.BackColor
   Me.BackColor = Color.LightGray
   Form2.ShowDialog()
   Me.BackColor = bc

Or if you just want to dull the current backcolor up a bit

   Dim bc As Color = Me.BackColor
   Dim DullFactor As Single = 0.25 'Roange from 0 to 1.  Closer to zero = duller
   Me.BackColor = Color.FromArgb(255, CInt(Me.BackColor.R * DullFactor), CInt(Me.BackColor.G * DullFactor), CInt(Me.BackColor.B * DullFactor))
   Form2.ShowDialog()
   Me.BackColor = bc

Got the answer....

'Form3.vb

Public Class Form3
     Private Sub Form3_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
          StartPosition = FormStartPosition.CenterScreen
     End Sub

     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
          Me.Close()
     End Sub
End Class

'Form2.vb

Public Class Form2
     Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
          WindowState = FormWindowState.Maximized
          FormBorderStyle = Windows.Forms.FormBorderStyle.None
     End Sub
End Class

'Form1.vb

Public Class Form3
     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
          Form2.BackColor = Color.DarkGray
          Form2.TransparencyKey = BackColor
          Form2.Opacity = 0.7
          Form2.Show()
          Form3.ShowDialog()
          Form2.Close()
     End Sub

     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
          Me.WindowState = FormWindowState.Maximized
     End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.