Results 1 to 4 of 4

Thread: [RESOLVED] Transparent form masks visible controls on the lower form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    90

    Resolved [RESOLVED] Transparent form masks visible controls on the lower form

    Hi,
    I am designing a transparent form(portaflow_masked) to sit on top of a window(portaflow) so that certain parts of it are masked out.
    But I am unable to operate the controls on the original form through the transparent top form.

    The excerpts from the code:

    Code:
    Public Class Form1
    
        Shared newprocess As System.Diagnostics.Process = New System.Diagnostics.Process
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            newprocess.StartInfo.FileName = "C:\Program Files\PORTAFLOW-C ENG\PFC"
            newprocess.Start()
    
            Me.TopMost = True
            Me.Label1.Text = Me.Label1.Text & "M3/hr"
    
        End Sub
    Any ideas ??
    Thanks.
    Attached Images Attached Images   

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,110

    Re: Transparent form masks visible controls on the lower form

    Is portaflow_masked a 3rd party control, or just the name of a form you're creating?
    If you're creating it, how did you set it up for transparency.
    A quick test of just creating a form with transparency with a few pictureboxes on it (I placed one picturebox on the form, changed its backcolor to red and made five copies so I had six of them on a form.
    With the following code I could move the form around (by dragging on any of the pictureboxes) to put it over anything, and I could still operate things underneath the form by clicking between the pictureboxes so clicks were going through the transparent regions.
    Try it out to see if you have an issue.
    I have had occasions where the clicks would not go through the transparent portion of the form, but I'm not sure why. It might have been as a result of messing with opacity as well, or it might have been because I had a control filling the form that had a transparent color background, so wasn't visible, but still captured mouse inputs. That doesn't seem to be the case, because I just tried putting a picturebox with a transparent background on the form, and it didn't block the mouse, so I'm not sure what the case was. I also thought it might be related to using Aero mode vs a non-Aero mode in windows, but that also doesn't seem to be the case (I just switched from a non-Aero to an Aero mode and the code still works).

    Give it a try and see what your results are.
    Code:
    Public Class Form1
    
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        BackColor = Color.DimGray
        TransparencyKey = Color.DimGray
        FormBorderStyle = Windows.Forms.FormBorderStyle.None
        TopMost = True
      End Sub
    
      Private Sub PictureBox_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox6.MouseMove, PictureBox5.MouseMove, PictureBox4.MouseMove, PictureBox3.MouseMove, PictureBox2.MouseMove, PictureBox1.MouseMove
        Static lpos As Point
        If e.Button = Windows.Forms.MouseButtons.Left Then
          Me.Location += New Size(e.X - lpos.X, e.Y - lpos.Y)
        Else
          lpos = e.Location
        End If
      End Sub
    
      Private Sub PictureBox_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox6.MouseUp, PictureBox5.MouseUp, PictureBox4.MouseUp, PictureBox3.MouseUp, PictureBox2.MouseUp, PictureBox1.MouseUp
        If e.Button = Windows.Forms.MouseButtons.Right Then Me.Close()
      End Sub
    End Class
    The MouseMove and MouseUp code is just added for convenience so you can move the form around (drag with left button) and exit the program (click with right button).

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    90

    Re: Transparent form masks visible controls on the lower form

    Hi Passel ,
    Thanks for your reply.
    "portaflow_masked" a form with the same dimensions as that of the original portaflow software with the transparency key colour set to the form backcolour.This is rendering the form transparent.
    I shall try out your code which seems to be similar to what I had used in VB6.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    90

    Re: Transparent form masks visible controls on the lower form

    Hi Passel,
    Thanks for pointing out the windows "AERO" issue.
    I switched to the non-aero mode & it solved my problem.

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