Re: Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
funnyusername
Hello all,
Well the noobie is very embarassed! :o The issues seems to have been a corrupt build environment, and a rebuild fixed it! :) ....
Well, I'm off to learn some more through trial and error. Can anyone suggest a good C# book on amazon, that has a decent amount of info on debugging?
.
What you are talking about in your last post seems all to me to be a broken delegate ( not connected to the form ) Otherwise your breakpoints are never ignored. As you have added the Tick delegate in the MainForm_Load delegate the next thing I would have done, if I would have had your situation is to set a breakpoint in the first line of the MainForm_Load delegate. If this also is ignored then you can be totally sure this event isn't fired. So as any form fires this event you can be sure it is not added to the MainForms Load event. Then I would look into the designer . This is a separate document since VS 2005 and its name is ( if the Forms name is MainForm) MainForm.designer.cs
If you look to your documents tree you will see that the Form has a '+' there. Expand the tree and you will see the document.
Open the code and you will find a section signed in a way like ' Automatic created code - dont touch' ( I dont know the correct English text, as my enviroment is german - so I can only retranslate the german text :D ) Open this text and you will find what you have created by drawing controls to the form with the designer.
Adding a delegate to an event always has the format
controlName.XYEvent += new xyEventHandler (controlName_xyEvent)
If your Form is named 'MainForm' the load Event is set like
Code:
this.Load += new System.EventHandler(this.MainMDI_Load);
Additional: Never be shy to ask simple questions. Even if someone sometimes sounds a bitt strict, this may happen, but believe me, its normally for your best.You will learn by those people to ask very exact questions and this is also very helpful to get the corrrect answers.
If you still have your old projectbuild anywhere you may find what has been wrong and this will also be a great lessn for you. Study the designer created code and you will understand a lot more about your own program.
BTW is there a reason to add the Tick event in the load event instead of in the designers code - InitializeComponent() directly.? ( I havn't studied your whole code yet ) :wave:
Re: Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
funnyusername
The MainForm properties Load event shows: <i>MainForm_Load</i>
In MainForm.Designer.cs I can't see that line, it doesn't seem to be there.
If you dont see it and it doesn't fire, IT IS NOT THERE, such simple. That was the built error ! :wave:
Re: [RESOLVED] Splash Form Timer.Tick - not Working
The OP mailed me the files, and I reviewed them....
The source files were fine. The problem was that the executable that was running was NOT built from the sources [exact reason unknown - as a rebuild fixed the problem].
The real first clue to this was when the OP sated that "BreakPoints were being ignored". Further investigation showed that they were NOT active because they were not matched up to the source (they showd as little reg "rings" reather than solid red "dots")
Re: [RESOLVED] Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
TheCPUWizard
The OP mailed me the files, and I reviewed them....
I see... strangeVS behavoiur. I remember only one time have had a similar behaviour in VS2005 when I had three projects conneced together ( 2x dlls and the main project)[/quote]I did some changes in the dlls code and pressed 'recreate projectmap' The project gives me a warning during debugging and told me that it cannot step into the dlls code because they are not up to date. ??? But I have pressed to recreate the pojectmap. Then I clicked to the dlls project file and recreated the dll itself and it was done. But IMHO if I have three projects added to gether and pressing 'recreate projectmap it should recompile the whole solution, but obviously it is not. ( there is no button in the menue which uses 'solution' in German VS.) So I think VS builing problems are very seldom.
Re: Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
JonnyPoet
(snip!)...Then I would look into the designer.....(snip!).....Study the designer created code and you will understand a lot more about your own program.
BTW is there a reason to add the Tick event in the load event instead of in the designers code - InitializeComponent() directly.? ( I havn't studied your whole code yet ) :wave:
Thanks, I'll look back over that and try to go deeper. :) When I 'double-click' my timer in the IDE its default event is the timer.tick and the code is automatically placed there.
Re: Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
funnyusername
...When I 'double-click' my timer in the IDE its default event is the timer.tick and the code is automatically placed there.
Yes thats correct, but in any questions of a problem of nor working delegates I'm always looking into the designers code if all is correct here. So the question now is:
Have you added the delegate twice ? One times using IDE and clicking there so its added to the form in the designer and a second time in the Form Load event as I can see this in your posts ?
Re: Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
JonnyPoet
Yes thats correct, but in any questions of a problem of nor working delegates I'm always looking into the designers code if all is correct here. So the question now is:
Have you added the delegate twice ? One times using IDE and clicking there so its added to the form in the designer and a second time in the Form Load event as I can see this in your posts ?
Yes [at line 111 in the designer....] , it is enabled, interval=1000, and the event wired up in the designer.
Then in the Form Load event, is is sped up (interval=100), enabled (redundant) and wired up (redundant)
Sloppy, Definately. But not problematic. Remember the identity of a delegate is the source and target. And you can not add duplicate events (ie cduplicating the add, will NOT cause the event to fire twice as often).
IT HAD NOTHING TO DO WITH THE PROBLEM
Re: Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
TheCPUWizard
IT HAD NOTHING TO DO WITH THE PROBLEM
This is correct. It has nothing to do with the built error.
Quote:
Originally Posted by
TheCPUWizard
....And you can not add duplicate events (ie cduplicating the add, will NOT cause the event to fire twice as often).
Try it, It fires twice as often. I just added a timer to a form and a Label and added the same delegate twice just as it was done. One time in the designer and one time in the form load event. Both are added with keyword new so they have the same pattern but are two delgate objects added. I did a counter for one step every second and show the results on a Label. It seems to step in steps of two. Because the event always is fired twice.
Code:
// Test project
public partial class Form1 : Form {
private int i = 0;
public Form1() {
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e) {
label1.Text = i.ToString();
i++;
}
private void Form1_Load(object sender, EventArgs e) {
timer1.Tick +=new EventHandler(timer1_Tick);
timer1.Enabled = true;
}
}
// and in InitializeComponents
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
....
So this was maybe the problem for it was vanished to quick.
;)
Re: [RESOLVED] Splash Form Timer.Tick - not Working
Your right, but I don't think that was causing my problem, because the rebuild fixed it without me changing the code. I don't know why (Obviously) but I'm sure you do! I just located the line in the Initialize components, ran the project and counted approx 3 seconds for my fade. :)
I commented out the line in Initialize Components and ran again and my fade was approx 6 seconds.
:?
My timer1 tick event is:
Code:
private void timer1_Tick(object sender, EventArgs e)
{
if (timerClock >= 20)
{
SplashForm.Opacity = SplashForm.Opacity - .04;
}
timerClock++;
if (timerClock == 60)
{
SplashForm.Close();
this.Opacity = 100;
timer1.Enabled = false;
}
}
And the Initialize components shows:
Code:
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// menuStrip1
I have now removed the timer settings in the Load event, and just left them in the Initialize Components.
I have deleted the tick += in the Initialize Components.
Thanks again. :)
Re: [RESOLVED] Splash Form Timer.Tick - not Working
Quote:
Originally Posted by
funnyusername
Your right, but I don't think that was causing my problem, because the rebuild fixed it without me changing the code.
As I told before CPUWizard is correct, Double setting the delegate has nothing to do with the built error, this only causes that the fade out is half the time
Quote:
I don't know why (Obviously) but I'm sure you do! I just located the line in the Initialize components, ran the project and counted approx 3 seconds for my fade. :)
Yep that was what I wanted to tell you. That quick fade out is caused because the delegate is added twice so it also is called twice at every tick.