Results 1 to 10 of 10

Thread: [Resolved]Rectangles

Threaded View

  1. #3
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Rectangles

    Hi Vipkid,
    You can use an ordinary form to show a partly transparent rectangle in front of the web browser. You need to set various properties of the form to make it work well. If the user can move/resize the form, code the forms Move and Resize events to keep them aligned; otherwise set the bounds in a similar way in the Load event. The following code goes on the form (Form1) which hosts the web browser (WebBrowser1):

    vb.net Code:
    1. Private WithEvents frm As New Form With _
    2.     {.FormBorderStyle = Windows.Forms.FormBorderStyle.None, .Owner = Me, _
    3.      .StartPosition = FormStartPosition.Manual, .Visible = False, _
    4.      .ShowInTaskbar = False, .BackColor = Color.Gray, .Opacity = 0.6}
    5.  
    6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    7.         If frm.Visible Then
    8.             frm.Hide()
    9.         Else
    10.             frm.Show(Me)
    11.         End If
    12.     End Sub
    13.  
    14.     Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move, Me.Resize
    15.         frm.Bounds = RectangleToScreen(WebBrowser1.Bounds)
    16.     End Sub
    You only need the WithEvents keyword if you want to do something with frm's events, for example the Click event.


    @jmcilhinney. John, I never see anyone else recommending forms for solving this kind of transparency problem. Is there some good reason for not doing so?

    BB
    Last edited by boops boops; Jun 29th, 2010 at 06:00 AM.

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