The class MainGUI in a windows Form. Have only paste the needed parts.
public class MainGUI : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
Maingui maingui;
MediaDriver mediadriver;
.....
// HERE ARE ALL LABELS; BUTTONS and so on which are in the form
///
than I have somewhere a button event
private void file_button_Click(object sender, System.EventArgs e)
{
if (mediadriver == null)
mediadriver = new MediaDriver(label1, trackBar1, maingui);
maingui.mediadriver.open_media();
}
}
class MediaDriver
{
....
Form maingui;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.Timer timer1;
....
public MediaDriver(Label label1 , TrackBar trackBar1 , Form maingui)
{
....
this.timer1 = new
System.Windows.Forms.Timer(this.maingui.components );
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
....
}
....
//Here comes the other Methods
.....
}
It would work when I declare "MainGUI maingui" instead of "Form maingui" in
Class MediaDriver and change
Constructor to public MediaDriver(Label label1 , TrackBar trackBar1 ,
MainGUI maingui)
But the problem is that Class MediaDriver will be a DLL and someone could
use this DLL from a class
XYZ and than there would be no definition for MainGUI
"Will Pittenger" <wi************@verizon.net> schrieb im Newsbeitrag
news:e2**************@TK2MSFTNGP12.phx.gbl...
I believe that class needs a window. It is based on the standard Win32
timers. Try using System.Timers.Timer instead. I may be more familiar
with C++ than C#, but I do not see a window in the code you listed.
----------
Will Pittenger
E-Mail: mailto:wi************@verizon.net
All mail filtered by Qurb (www.qurb.com)
"Bilo" <ju********@yahoo.com> wrote in message
news:Oi****************@TK2MSFTNGP09.phx.gbl... I have a Windows Forms Class MainGUI
I have declared
MainGUI maingui;
public System.ComponentModel.Container components = new Container();
in the Class
I call another class MediaDriver with the Constructor
class MediaDriver
{
....
Form maingui;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.Timer timer1;
....
public MediaDriver(Label label1 , TrackBar trackBar1 , Form maingui)
{
....
this.timer1 = new
System.Windows.Forms.Timer(this.maingui.components );
this.timer1.Enabled = true;
this.timer1.Tick += new
System.EventHandler(this.timer1_Tick); ....
}
But i get an error
'System.Windows.Forms.Form' does not contain a definition for
'components'
How can I solve this? How can I add a Timer for the MainGUI form in the
Class MediaDriver?