C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
c# timer Posted by floozy on 2 May 2003 at 1:55 AM
Still working on that multibutton thing, and getting there. Now
Id like to display a form only after a certain time has elapsed.
I have a button which has a built in hover event, it all works ok, how can I delay that hover event for say a couple of seconds.

If You need some of my code to give any hints, Ill be watching this site.

thanks
Report
Re: c# timer Posted by Brutes on 2 May 2003 at 2:19 AM
Hi

You can use the
window.setTimeout("showBanner()", speed);

Look at
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/settimeout.asp

also see the cleartimeout method.
Report
Re: c# timer Posted by floozy on 2 May 2003 at 4:37 AM
: Hi
:
: You can use the
: window.setTimeout("showBanner()", speed);
:
: Look at
: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/settimeout.asp
:
: also see the cleartimeout method.
:
Thanks for Your reply, I was wondering when Youd answer to one of my qusetions, You seem to be very active when it comes to answering questions.
I still have little experience in C# and programming in general, I started my training August last year, English is not my mothertongue.

That is probably why Your hint doesnt help me along. The application Im writing with Visual C# is not for html pages.

Greetings from Germany
Report
Re: c# timer Posted by Brutes on 5 May 2003 at 4:05 AM
Cool Man.

Sorry I assumed you were developing on the web with html.

Your Timer mouse over event is perfect.
Keep in that direction, You seem to be on the right track.

Fire the timer event on the mouse over and when the timer Timeout fires you reset the timer timeout so it doesn't keep on firing and do what ever it was you wanted to delay.

private void button1_buttonClicked()
{
Timer1.Timeout = 5000; // or something to make it start counting down
}

private void Timer1_timerTimeout()
{
Timer1.timeout = 0; // or something to stop it
// Now do whatever the timer was supposed to delay
}

Ps. I am just coding off the top of my head.
You should see how the logic is supposed to solve your problem.
Report
Re: c# timer Posted by lyubo on 2 May 2003 at 9:14 AM
This message was edited by lyubo at 2003-5-2 9:24:27

This message was edited by lyubo at 2003-5-2 9:15:36

: Still working on that multibutton thing, and getting there. Now
: Id like to display a form only after a certain time has elapsed.
: I have a button which has a built in hover event, it all works ok, how can I delay that hover event for say a couple of seconds.
:
: If You need some of my code to give any hints, Ill be watching this site.
:
: thanks
:
Q: How can I delay that hover event for say a couple of seconds
A: One way is to override the event handler :)
Q:If You need some of my code to give any hints, Ill be watching this site.
A: yes, i may get things clearer and give you better advise.

P.S: You learn C# since August 2002? Well that's a lotta time compared to me :). I learn C# for two months now, here is my first project's Beta version. I call it Cryptographer .NET Tester's Beta: http://lmilev.hit.bg/CSFX.exe
I got two web services on the way thought.
One for dictionary translation Bulgarian to English and vica versa. Built on that dict. ws i'm doing many interfaces like MobileWeb, other ASP.NET Web sites, Desktop interfaces, PocketPC interfaces, that all use the web to contact my web service and retrieve data from the dictionary.
And one for text transformation Bulgarian to Latin and vica versa.

Report
Re: c# timer Posted by floozy on 5 May 2003 at 1:36 AM
Thanks for Your answer,
No its not c# Im learning since August, first its been C++, a bit of html and SQL, a lot about network and plenty of other computer basics.
Ive never done any programming before, so You still reckon Im a bit slow? However, Ill get there.
Back to my question.

here is some of the code
public class ChocolateForm : System.Windows.Forms.Form
{.....................
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ImageList mImageList = null;
private int mCntColums = 0;
private PartialButton[,] mButtons = null;
private MButton mMultibtn = null;

//construction
public ChocolateForm(System.Windows.Forms.ImageList imageList, int cntColums, MButton father)
{
mImageList = imageList;
mCntColums = cntColums;
mMultibtn = father;
.....

mButtons = new PartialButton[ mCntColums, lines ];
int imageIndex = 0;
for ( int il = 0; il < lines; il++ )
{
for ( int ic = 0; ic < mCntColums; ic++ )
{
// button properties
mButtons[ic, il] = new PartialButton( imageIndex );
mButtons[ic, il].Size = new System.Drawing.Size( 22, 22 );
mButtons[ic, il].Location = new Point(ic * 23, il * 23);
mButtons[ic, il].ImageList = this.mImageList;
mButtons[ic, il].ImageIndex = imageIndex;
mButtons[ic, il].Click += new System.EventHandler( this.buttonClick );
//declare another eventHandler for click event to close chocolate and display clicked pic

mButtons[ic, il].Click += new System.EventHandler( this.chocoClick );
this.Controls.Add( mButtons[ic,il] );
imageIndex++;
}
}//end construction

...............
//
public class MButton : System.Windows.Forms.Button
{

private System.Windows.Forms.Timer myTicker;
private System.ComponentModel.IContainer components;
private int mColuns = 2;
private ChocolateForm mChocolateForm = null;
....................
//methode in MButton Class
private void onMyMouseHover(object sender, EventArgs ea)
{
if ( mChocolateForm == null )
{

mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);

//set location of chocolate, transform this.Location into screen point
//and set screen point of chocolate to that
Point ChocPos = this.Location; ChocPos.X = this.Size.Width;
ChocPos.Y = this.Size.Height - this.Size.Height; //strange but works

ChocPos = this.PointToScreen(ChocPos);
mChocolateForm.Location = ChocPos;
mChocolateForm.BringToFront();
// myTicker.Enabled = true; How to set the timer to display chocolate only after time elapsed
// myTicker.Stop();
mChocolateForm.ShowInTaskbar = true; //set to false when finished with button
mChocolateForm.Show();
}
}
Does that make things clearer?
greetings
Report
Re: c# timer Posted by floozy on 5 May 2003 at 2:48 AM
here is my solution to my problem.

start timer in mouse hover methode and create chocolate in timer tick methode, it seems to work

private void onMyMouseHover(object sender, EventArgs ea)
{
this.myTicker.Enabled = true;
this.myTicker.Interval = 1000; myTicker.Tick += new EventHandler(myTimerTicks);
}

private void myTimerTicks(object obj, EventArgs ea)
{
if ( mChocolateForm == null )
{
mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);

//set location of chocolate, transform this.Location into screen point
//and set screen point of chocolate to that
Point ChocPos = this.Location;
ChocPos.X = this.Size.Width;
ChocPos.Y = this.Size.Height - this.Size.Height; //strange but works

ChocPos = this.PointToScreen(ChocPos);
mChocolateForm.Location = ChocPos;
mChocolateForm.BringToFront();

Timer anotherT = (Timer)obj;
anotherT.Stop();
anotherT.Tick -= new EventHandler(myTimerTicks);

mChocolateForm.ShowInTaskbar = true; //set on false when finished with button
mChocolateForm.Show();
}
}
what do you say
Report
Re: c# timer Posted by lyubo on 5 May 2003 at 11:10 AM
: here is my solution to my problem.


: //set location of chocolate, transform this.Location into screen point
: //and set screen point of chocolate to that
: Point ChocPos = this.Location;
: ChocPos.X = this.Size.Width;
: ChocPos.Y = this.Size.Height - this.Size.Height; //strange but works
:
: ChocPos = this.PointToScreen(ChocPos);
: mChocolateForm.Location = ChocPos;
: mChocolateForm.BringToFront();
:
: Timer anotherT = (Timer)obj;
: anotherT.Stop();
: anotherT.Tick -= new EventHandler(myTimerTicks);
:
: mChocolateForm.ShowInTaskbar = true; //set on false when finished with button
: mChocolateForm.Show();
: }
: }
: what do you say
:
I bet your solution works, here is my way, see if you find it more attractive
private void onMyMouseHover(object sender, EventArgs ea)
{ // begin handler
// i luve threads ;p
Thread chocFormCreating = new Thread(new ThreadStart(this.ChocolateFormCreator));
chocFormCreating.Start();
} // end handler

private void CholocateFormCreator()
{ // begin Creator
// wait 1 second and then create the chocolf
Thread.Sleep(1000);
mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);
if ( mChocolateForm == null )
{ // begin if statement
mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);

//set location of chocolate, transform this.Location into screen point
//and set screen point of chocolate to that
Point ChocPos = this.Location;
ChocPos.X = this.Size.Width;
ChocPos.Y = this.Size.Height - this.Size.Height; //strange but works

ChocPos = this.PointToScreen(ChocPos);
mChocolateForm.Location = ChocPos;
mChocolateForm.BringToFront();

mChocolateForm.ShowInTaskbar = true; //set on false when finished with button
mChocolateForm.Show();

}// end if
}// end creator

Greetings from Bulgaria
Report
Re: c# timer Posted by floozy on 6 May 2003 at 12:38 AM
goodonya mate, looks good and I even understand it, howzat?
Im going to try it out. Only thing I find strange is, You creating a chocolate and then compare if null and create it again, well Ill see.
And Ill be posting more questions.
thanks

: private void CholocateFormCreator()
: { // begin Creator
: // wait 1 second and then create the chocolf
: Thread.Sleep(1000);
?????????????????
: mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
: mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);

: if ( mChocolateForm == null )
: { // begin if statement
: mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
: mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);
:
: //set location of chocolate, transform this.Location into screen point
: //and set screen point of chocolate to that
: Point ChocPos = this.Location;
: ChocPos.X = this.Size.Width;
: ChocPos.Y = this.Size.Height - this.Size.Height; //strange but works
:
: ChocPos = this.PointToScreen(ChocPos);
: mChocolateForm.Location = ChocPos;
: mChocolateForm.BringToFront();
:
: mChocolateForm.ShowInTaskbar = true; //set on false when finished with button
: mChocolateForm.Show();
:
: }// end if
: }// end creator
:
: Greetings from Bulgaria
:

Report
Re: c# timer Posted by lyubo on 7 May 2003 at 9:35 AM
: goodonya mate, looks good and I even understand it, howzat?
: Im going to try it out. Only thing I find strange is, You creating a chocolate and then compare if null and create it again, well Ill see.
: And Ill be posting more questions.
: thanks
:
: : private void CholocateFormCreator()
: : { // begin Creator
: : // wait 1 second and then create the chocolf
: : Thread.Sleep(1000);
: ?????????????????
: : mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
: : mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);
:
: : if ( mChocolateForm == null )
: : { // begin if statement
: : mChocolateForm = new ChocolateForm( ImageList, mColuns, this );
: : mChocolateForm.Closing += new System.ComponentModel.CancelEventHandler(this.chocoClosing);
: :
: : //set location of chocolate, transform this.Location into screen point
: : //and set screen point of chocolate to that
: : Point ChocPos = this.Location;
: : ChocPos.X = this.Size.Width;
: : ChocPos.Y = this.Size.Height - this.Size.Height; //strange but works
: :
: : ChocPos = this.PointToScreen(ChocPos);
: : mChocolateForm.Location = ChocPos;
: : mChocolateForm.BringToFront();
: :
: : mChocolateForm.ShowInTaskbar = true; //set on false when finished with button
: : mChocolateForm.Show();
: :
: : }// end if
: : }// end creator
: :
: : Greetings from Bulgaria
: :
:
:
I just copied and pasted your code with some modifications, i didn't notice the comparement you're talking about, i was just giving an example of the threading use and tryed to implement your code without really reading it thought
I bet you can fix the code, it's peace of cake, and give it a go. Good Luck!

Greetings from Bulgaria



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.