spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column117


JScript .NET, Part XI: Creating Windows Forms

Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


Redefining the OnMouseUp Event Handler

In this page, we demonstrate how to override an event handler. We define a new class, ClickPanel, which extends the class System.Windows.Forms.Panel. We redefine the function OnMouseUp() by:

  • Including the definition of OnMouseUp() from the super class, System.Windows.Forms.Panel
  • Adding a message box that displays the coordinates of the event.

We specify that the new function is overriding the super class and is protected against further overriding by other classes that may inherit it:

override protected function OnMouseUp (e : MouseEventArgs) {
  super.OnMouseUp(e);
  MessageBox.Show("Mouse Up at: "+e.X+", "+ e.Y);
} 

The class ClickPanel is defined as follows:

class ClickPanel extends System.Windows.Forms.Panel {
  override protected function OnMouseUp (e : MouseEventArgs) {
    super.OnMouseUp(e);
    MessageBox.Show("Mouse Up at: "+e.X+", "+ e.Y);
  } 
} 

We want to change the top panel to behave as the ClickPanel class, instead of the generic Panel class. We first change its definition:

private var topPanel: ClickPanel;

And then we need to change its construction statement:

topPanel= new ClickPanel;

The rest of the code is as shown in Page 5. You pop up this window by calling the Application.Run() method. The package name is MouseUpPkg and the class name is MouseUpCls. The running statement is:

Application.Run(new MouseUpPkg.MouseUpCls());

Whenever you click inside the top panel, a message box will pop up with the event coordinates, like this:


Next: How to create form menus

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: August 26, 2002
Revised: August 26, 2002

URL: http://www.webreference.com/js/column117/6.html

/HTML>