Link to home
Start Free TrialLog in
Avatar of phalgune
phalgune

asked on

Shaped forms and bitmaps

I am working on a project that should support skinning of the application. My main form can be a irregularly shaped form.

The form has to be shaped according to the background bitmap or the main window bitmap.

Since I am talking about several possibles shapes that the form can take it isn't viable to use GraphicsPath in the Paint event to create all the arcs for me.

I want a simple way to shape the form based on the bitmap.

I tried to shape it by setting the TransparencyKey to the background color of the bitmap but it doesn't work.

Thanks in advance.

Regards
Phalgun
ASKER CERTIFIED SOLUTION
Avatar of testn
testn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've been able to do this w/out using form.region by settng both the transparency key AND the form background color to match the background of the image.

I've only used .gif images in these cases but I don't see why it wouldn't work with a bitmap.
Avatar of testn
testn

the different is when you click at the blank area. It should behave differently.
'add picture to the form and make it transparent - the form will be picture shape

Option Explicit On
Option Strict On

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Visible = False
        PictureBox1.Top = 0
        PictureBox1.Left = 0
        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
        PictureBox1.Image = (Image.FromFile("genie.bmp"))

        Me.BackColor = Color.Magenta
        Me.FormBorderStyle = FormBorderStyle.None
        Me.TransparencyKey = Color.Magenta
        Me.Visible = True
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Me.Close()
    End Sub
End Class
testn - Thanks for the clarification.  I've used it only for splashscreens so onClick wasn't relevant.  Appreciate the info - Frodoman
Avatar of phalgune

ASKER

Well I got the solution. I used region to do that.
Avatar of Bob Learned
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: testn {http:#10111880}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
Force accepted.

D'Mzz!
RoverM
EE Page Editor - .NET

(it has been more than 7 days since my last comment, seems to have missed this one in the clean up)