ARTICLE

Power pack drawing primitives for visual basic 2005

Posted by Scott Lysle Articles | Windows Controls April 18, 2008
This kit contains a collection of drawing primitive controls in the form of an oval, rectangle and a line shape.
Download Files:
 
Reader Level:

Introduction

Microsoft has released version 2.0 of the Visual Basic 2005 Power Packs; the kit may be downloaded from here (http://msdn2.microsoft.com/en-us/vbasic/bb735936.aspx). Among other things, the kit contains a collection of drawing primitive controls in the form of an oval shape, a rectangle shape, and a line shape.

Figure 1: Using the Drawing Primitives from the Visual Basic 2005 Power Pack 2.0

Installed Controls

Upon installation of the tools; those items will appear in the toolbox under the heading of Visual Basic Power Packs v2.0. After the installation, you should see the Print Form, Line Shape, Oval Shape, and Rectangle Shape controls in the toolbox section. This article only addresses the drawing primitives.

Features.

Adding to a Form

In order to use a control, just drag the control from the toolbox and drop it onto the form as you would any other toolbox control; alternatively the controls may be added in code and added to the control collection.

Figure 2:  Power Packs Section of the Toolbox

Resize and Reposition

Once the drawing controls have been added to the page, the user may click on a control which in turn results in the display of the controls resizing handles. With the resizing handles present, the user may resize the oval or rectangle, or resize and reposition the beginning and end points of the line.

Figure 3:  Manipulating a Control at Design Time

Control Properties

Each controls properties are exposed in the IDE property grid upon selection of the control. The user may set fill colors and styles, border thicknesses, gradient effects, and other control related properties from this interface. Such properties may also be manipulated in code at run time.

Figure 3:  Setting Control Properties in the Property Grid

Control Events

The controls are configured to respond to a number of common events, by writing event handlers for these events is it possible to create responsive instances of the controls. In the example provided, the three oval controls are configured to show a roll-over effect when the mouse passes into and out of the control, and to respond to a click event.
The following code is used to alter the fill gradient color property of an oval control whenever the mouse enters the controls boundaries.

Private Sub OvalShape1_MouseEnter(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles OvalShape1.MouseEnter

OvalShape1.FillGradientColor = Color.CornflowerBlue

End Sub

 

And this code is used to restore the fill gradient color to its previous state once the mouse leaves the controls boundaries.

Private Sub OvalShape1_MouseLeave(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles OvalShape1.MouseLeave

OvalShape1.FillGradientColor = Color.FromArgb(255, 255, 192)

End Sub

Here, a click event handler is added for the same control and is used to manage the visible property on three line symbol controls also added to this page.

Private Sub OvalShape1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OvalShape1.Click

LineShape1.Visible = True

LineShape2.Visible = False

LineShape3.Visible = False

End Sub

Summary

Overall, the drawing primitives are a useful set of controls that may be used to enhance the appearance of an application GUI. The Microsoft site (http://msdn2.microsoft.com/en-us/vbasic/bb735936.aspx) is soliciting opinions and suggestions for additional controls and enhancements to the existing controls. Some additions that come to mind might be the inclusion of a transparent background label and a drop shadow enhancement to the existing controls (and the mentioned label control).

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Team Foundation Server Hosting
Become a Sponsor