Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

Windows Media Audio compressor

, 8 Apr 2004
Managed C++ Windows Media Audio (WMA) compressor.
//
//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
//  PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER 
//  REMAINS UNCHANGED.
//
//  Email:  yetiicb@hotmail.com
//
//  Copyright (C) 2002-2003 Idael Cardoso. 
//

using System;
using System.Windows.Forms;
using System.Globalization;

namespace Yeti.Controls
{
	/// <summary>
	/// Define a TextBox that allow only integer numbers.
	/// </summary>
	public class NumericTextBox : TextBox
	{
		public NumericTextBox()
      :base()
		{
		}

    protected override void OnKeyPress(KeyPressEventArgs e)
    {
      base.OnKeyPress(e);
      if ( (!e.Handled) && ( "1234567890\b".IndexOf(e.KeyChar) < 0) )
      {
        Yeti.Sys.Win32.MessageBeep(Yeti.Sys.BeepType.SimpleBeep);
        e.Handled = true;
      }
    }

	  public event EventHandler FormatError;
    public event EventHandler FormatValid;

    protected virtual void OnFormatError(EventArgs e)
    {
      if (FormatError != null)
      {
        FormatError(this, e);
      }
    }

    protected virtual void OnFormatValid(EventArgs e)
    {
      if (FormatValid != null)
      {
        FormatValid(this, e);
      }
    }

    protected override void OnTextChanged(EventArgs e)
    {
      try
      {
        int.Parse(this.Text, NumberStyles.Integer);
        OnFormatValid(e);
      }
      catch
      {
        OnFormatError(e);
      }
      base.OnTextChanged (e);
    }

    public int Value
    {
      get
      {
        return int.Parse(this.Text, NumberStyles.Integer);
      }
      set
      {
        this.Text = value.ToString();
      }
    }
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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

Share

About the Author

Idael Cardoso
Web Developer
France France
No Biography provided

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 9 Apr 2004
Article Copyright 2004 by Idael Cardoso
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid