Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

PngSkin - Per Pixel Forms Skin

0.00/5 (No votes)
1 Nov 2007 1  
PngSkin – ActiveX Control used to apply eye catching skins to Windows Forms with minimal code
Screenshot - Screen.gif

Introduction

PngSkin is an ActiveX control written in Vb6 that can be used to apply per pixel alpha transparent PNG skin to any application (VB6 and .NET). You can ask your designer (Corel Draw) to create eye catching designs for your application. The control can be used for win2000 and upper operation systems. The non client area of any window can be designed in professional drawing software.

The best part of this control is that to use it in your application you need not code or configure it heavily. For VB6 Windows application, you need not write even a single line of code. For .NET Windows forms, you need to write just 2 lines of codes.

The Activex Control uses updatelayeredwindow (ULW) and setlayeredwindowattributes (SLWA) APIs to create a semi-transparent form capable of "hosting" controls. The word "hosting" is not correct. This example shows one way of creating a host form for controls and overlaying it on the semitransparent background.

Using the Code

For VB 6 Windows Forms

Add the component to your project and drag & drop to your form. Set form border to None and add some background colour.

Set the property ImageOuterPath = "your Png File Path" and run the project.

For .NET Windows Forms

Repeat the above procedure and add the following code to your Winform:

Private Sub PictureBox1_Click(ByVal sender As System.Object, _
	ByVal e As System.EventArgs) Handles PictureBox1.Click
    AxSkin1.UnloadSkin()
    Me.Close()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, _
	ByVal e As System.EventArgs) Handles MyBase.Load
    Me.BackgroundImage = Nothing
    With AxSkin1
       .ActivateSkin(Me.Handle.ToInt32)
    End With
End Sub

Points of Interest

To map the controls in design time, the control will set the background of form to PNG automatically in VB 6, however you need to set the forms background image to your PNG file.

Thanks

Many many thanks to LaVolpe for sharing the PNG support in VB 6 [http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=68527&lngWId=1].

History

  • 2nd November, 2007: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here