logo
vbRad Home
Source Code
Book Reviews
Forum
Links
About Us
Contribute

Compare Databases with SQL Effects Clarity
 
 Adding great features to form's system menu via inheritance

Posted on
4/1/2004
Author:
Robert Gelb
Email:
Not Shown
Applies To OS:
Windows
Product:
.NET Framework



Download the project, including the source (126 kb)

Sometimes a certain piece of code is so general that you want to bottle it and sell it to everyone. In this case we have a piece of code that I normally apply to all the forms that I create in VS.NET. I figure that every form can use a built-in ability to do the following:

  • Change the priority of the application
  • Change the transparency (known as opacity) of the form
  • Minimize the form to the tray
  • Take a screenshot of the form and place the file on the desktop
  • Set the form to always be on top

So how do you apply this code to your forms? That's the cool part and this is what makes inheritance so powerful. Here is a short step by step tutorial (it assumes you have downloaded the project).

  1. In your project, add FormSysMenuValueAdd.dll to your references. You'll find it in Library/bin folder
  2. Now put your form into View Code mode and scroll to the very top. There you will see code like this:
     
    		Public Class Form1
    		    Inherits System.Windows.Forms.Form		
    	
    Change it to the following:
     
    		Public Class Form1
    		    Inherits FormSysMenuValueAdd.MasterForm		
    	
Yep, that's it. When you run your now, it will have all the extra features sitting in the system menu.
Note: I can't take credit for the screenshot code, I downloaded it somewhere, I don't know where.

Download the project, including the source (126 kb)



Add Your Comment  

Name: Email Address: all fields optional
Notify me via email when someone responds to this message (valid email required).

Enter the word:
 



Comments
#1. By Rhys Norbert. Posted on 3/23/2006 5:42:27 PM
This is an amazing piece!

#2. By hax. Posted on 6/10/2006 6:29:33 AM
great post