Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

How to override function from Form object?

i have a 15 forms, all i want to do is on the event endresize of the form's object, to do 1 line of code, thats it calling a function to play a sound, now how to override that event/function. i dont want to do, for each form add event code. what if i had 100 forms... :/ tnx in advance.
If I understand correctly, you could just create a new control that inherents Form and override OnResizeEnd
PHP Code

<?php 
public partial class SoundForm : Form
    
{
      public 
SoundForm()
      {
      
InitializeComponent();
      }

      protected 
override void OnResizeEnd(EventArgs e)
      {
      
//Play your sound here
      
SystemSounds.Beep.Play();
      
base.OnResizeEnd(e);
      }
    } 

Then to use it you would change your forms to be SoundFrom like
PHP Code

<?php 
public partial class MainForm : SoundForm
    
{
      public 
MainForm ()
      {
      
InitializeComponent();
      }
    } 

This way you wouldnt' have to create an OnResizeEnd event for every new form you create you just make it SoundForm.
(Sep 5, 2015 01:14 PM)newmecha Wrote:  If I understand correctly, you could just create a new control that inherents Form and override OnResizeEnd
PHP Code

<?php 
public partial class SoundForm : Form
    
{
      public 
SoundForm()
      {
      
InitializeComponent();
      }

      protected 
override void OnResizeEnd(EventArgs e)
      {
      
//Play your sound here
      
SystemSounds.Beep.Play();
      
base.OnResizeEnd(e);
      }
    } 

Then to use it you would change your forms to be SoundFrom like
PHP Code

<?php 
public partial class MainForm : SoundForm
    
{
      public 
MainForm ()
      {
      
InitializeComponent();
      }
    } 

This way you wouldnt' have to create an OnResizeEnd event for every new form you create you just make it SoundForm.

exactly what i needed, thank you so much.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by FhackMar 2, 2022 03:52 AM 4 307 Mar 2, 2022 03:52 AM
Last Post: Fhack
[C] by slipperypeteMar 13, 2020 08:48 PM 0 83 Mar 13, 2020 08:48 PM
Last Post: slipperypete
[C] by 6577657534735Jun 20, 2019 09:48 PM 5 176 Jun 20, 2019 09:48 PM
Last Post: doxerhacker