• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1376
  • Last Modified:

Adding a semi transparent background to a frameless popup vb.net

Is it possible to load an image with opacity<1 behind a popup window?

I've been asked to remove the frame from the popup because i cant control alerts when the X button is pressed. However, if i choose not to show the frame, the popup will blend with the previous window.

What I have in mind is: when the button to load the popup is pressed, to also load an image that appears infront of the original widnow but behind the popup, and to give an interesting affect, the imagen should have an opacity<1 (kind of trasnparent.
The image being just a plain white square.

I've been suggested to play around with the gradient alpha but I don't know how yet, so the question is basicly how to load an image behind the popup with some transparency and fixed position?


Any code suggestions will be greatly appreaciated
popup.JPG
0
infogws
Asked:
infogws
  • 2
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Use code like this to disable the 'X' in the top right:
Public Class Form1

    Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
        Get
            Const CS_NoClose As Integer = &H200
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ClassStyle = cp.ClassStyle Or CS_NoClose
            Return cp
        End Get
    End Property

End Class

Open in new window

0
 
Tom BeckCommented:
It sounds like you are trying to create a screen effect over the original web page while the pop up is visible. You can do this with css and a div or in the case of ASP.NET, a Panel like this:

<asp:Panel ID="screen" runat="server" CssClass="screen" Visible="false"></asp:Panel>

The css whould look like this:

.screen
{
      position:fixed;
      z-index: 600;
      width:100%;
      height:100%;
      top:0px;
      left:0px;
    background-color: #333;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
    filter: alpha(opacity=80);
    opacity: 0.8;
}

Adjust the z-index to get the screen in between the web page and pop up.

VS will complain about the opacity css, but it all needs to be there to make it cross browser compatible.
0
 
infogwsAuthor Commented:
Idle_mind: Im going to try you suggestion right away. Is the effect I'm mentioning possible?

Btw, I'm using Visual Studio 2008, coding with visual basic.net. Its a desktop application.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
The effect is possible...
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim overlay As New Form
        overlay.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        overlay.ShowInTaskbar = False
        overlay.BackColor = Color.White
        overlay.StartPosition = FormStartPosition.Manual
        overlay.Location = Me.Location
        overlay.Size = Me.Size
        overlay.Opacity = 0.5
        overlay.Show(Me)

        Dim f2 As New Form2
        f2.ShowDialog()

        overlay.Close()
    End Sub

End Class

Open in new window

0
 
infogwsAuthor Commented:
That kind of solved the problem, thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now