We are looking for some qualified individuals to work on a new Visual Basic site. The first task is developing a high-quality resource guide for Visual Basic developers. This resource guide will be a well-organized list of web sites that have very good resources about Visual Basic (from beginners stuff through advanced with topics like MTS and ASP). It will gradually expand to include other resources such as free source code and online shopping of development tools. If you are interested in working on a web site dedicated to Visual Basic jump to http://www.allvbstuff.com and fill out the form online. Thanks!
This issue demonstrates how to create a non-rectangle shaped form.
This class modifies the shape of a form by using several API calls to redraw the form. It will allow you to add some special effects to your applications. The basic steps to use this class are to set the FormObject (usually just the Me object) and then set the Shape property to the shape you want the form to appear as.
This class works best with forms that have the BorderStyle property set to 0.
Public Enum eFormShapes
An enumerator with all the supported form shapes. Currently this class only supports one, eShapeElliptic.
Public FormObject As Form
This should be set to the form that you want to change the shape of. It must be set before any other methods or properties are used.
Public Property Let Shape(eShape As eFormShapes)
Setting this property will automatically change the shape of the form based on the parameter passed in eShape.
Public Sub CenterForm()
This is a bonus routine to center a form. Since we are changing the shape of a form, we thought a centering routine would be useful.
Public Sub Move(Button As Integer)
This routine is used to allow a captionless (which is the type of form that is required for this routine) to be able to be moved by clicking on the form and dragging the mouse. You will need to call this routine in the Form_MouseDown routine.
This source code will show how change the shape of a form into an ellipse. This code assumes you have created a new form and changed the BorderStyle property to 0.
Option Explicit Dim moFormShaper As New cFormShaper Private Sub cmdQuit_Click() Unload Me End Sub Private Sub Form_Load() Set moFormShaper.FormObject = Me ' sets the form object to shape moFormShaper.Shape = eShapeElliptic ' selects the shape to change the form into. moFormShaper.CenterForm ' centers the form. End Sub ' Allows movement of the form Private Sub Form_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single) moFormShaper.Move Button End Sub
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0094.html