LITTLEBLACKDOG.COM Forum Index LITTLEBLACKDOG.COM

 
LWD LWD   FAQ FAQ   Memberlist Memberlist   Usergroups Usergroups   Active Topics Active Topics   Register Register  
  Profile Profile   Log in to check your private messages Log in to check your private messages   Log in Log in  
  Who is Online Who is Online   Image Gallery Image Gallery   Chat Chat   Search Search  
  LWDGear       LBDGear  

View next topic
View previous topic
Post new topic     Reply to topic   LITTLEBLACKDOG.COM Forum Index » Code Warriors
Author Message
Nauntilus
Stray Dog


Joined: 08 Mar 2007
Posts: 1

Post Posted: Thu Mar 08, 2007 6:53 pm   Post subject: What does this mean?? Reply with quote Back to top  

This is a C# question.

For this line of code
Quote:
if (((&msg).Msg == 256 || (&msg).Msg == 260) && keyData == Keys.Escape)

I am getting these errors:

Quote:
Pointers and fixed size buffers may only be used in an unsafe context


Quote:
You can only take the address of an unfixed expression inside of a fixed statement initializer


Quote:
Operator '.' cannot be applied to operand of type 'System.Windows.Forms.Message*'


The underlined parts of the code that are incorrect are (&msg).Msg and (&msg).Msg.


The second place I am having problems with is

Quote:
TimerCallback timerCallback1 = new TimerCallback(this.TimerCode0);
timer0 = new System.Timers.Timer(timerCallback1, null, 0, 60000);
TimerCallback timerCallback2 = new TimerCallback(this.TimerCode1);
timer1 = new System.Timers.Timer(timerCallback2, null, 1000, 5000);
TimerCallback timerCallback3 = new TimerCallback(this.TimerCode2);
timer2 = new System.Timers.Timer(timerCallback3, null, 0, 500);
TimerCallback timerCallback4 = new TimerCallback(this.TimerCode3);
timer3 = new System.Timers.Timer(timerCallback4, null, 5000, 20);


The error is
Quote:
No overload for method 'Timer' takes '4' arguments

The part of the code that is underlined as incorrect is TimerCallback and everything in parenthesis after that.

And finally the last part I am having problems is.
Quote:
if ((int)strs1.Length > 1)
{
timer1.Change(0, Convert.ToInt32(strs1[1]));
}
label.Top = base.Height / 2 - label.Height / 2;
label.Left = base.Width / 2 - label.Width / 2;
}
else if (Code0[i].Substring(0, 6) == "")
{
stnpanel2.BringToFront();
string[] strs2 = Code0[i].Substring(6, Code0[i].Length - 13).Split(new char[] { Convert.ToChar("^") });
if ((int)strs2.Length > 1)
{
long l = Convert.ToInt32(strs2[1]);
timer1.Change(l, l);
}
else
{
timer1.Change(5000, 5000);
}
ie2.Navigate(strs2[0], ref arg1, ref arg2, ref arg3, ref arg4);
}

The first error has to do with the Change part of timer1.Change.

This is the error;
Quote:
'System.Windows.Form.Timer' does not contain a definition for 'Change'

The second error has to do with the ie2.Navigate(strs2[0], ref arg1, ref arg2, ref arg3, ref arg4); Part and the error is:

No overload for method 'Navigate' takes '5' arguments
Quote:


All help is really appreciated, I have been banging my head against this for 2 weeks.

~Nauntilus
View user's profile Send private message
CMTG
Leg Humper
Leg Humper


Joined: 23 Feb 2002
Posts: 4959
Location: On average, Cheltenham.

Post Posted: Fri Mar 09, 2007 2:04 am   Post subject: Reply with quote Back to top  

Firstly, welcome to the forum!

Stick around and get to know us.


Nauntilus wrote:
This is a C# question.

For this line of code
Quote:
if (((&msg).Msg == 256 || (&msg).Msg == 260) && keyData == Keys.Escape)

I am getting these errors:

Quote:
Pointers and fixed size buffers may only be used in an unsafe context


Quote:
You can only take the address of an unfixed expression inside of a fixed statement initializer


Quote:
Operator '.' cannot be applied to operand of type 'System.Windows.Forms.Message*'


The underlined parts of the code that are incorrect are (&msg).Msg and (&msg).Msg.


The first and second errors means you are trying to do something naughty. Taking the memory address of an object is usually a no-no in a managed environment. (The last error is probably just an artifact of using the wrong indirection operator on a pointer, but as it says, pointers aren't allowed in this context anyway.)

Try the following:

Code: Select all
if ((msg.Msg == 256 || msg.Msg == 260) && keyData == Keys.Escape)


Nauntilus wrote:
The second place I am having problems with is

Quote:
TimerCallback timerCallback1 = new TimerCallback(this.TimerCode0);
timer0 = new System.Timers.Timer(timerCallback1, null, 0, 60000);
TimerCallback timerCallback2 = new TimerCallback(this.TimerCode1);
timer1 = new System.Timers.Timer(timerCallback2, null, 1000, 5000);
TimerCallback timerCallback3 = new TimerCallback(this.TimerCode2);
timer2 = new System.Timers.Timer(timerCallback3, null, 0, 500);
TimerCallback timerCallback4 = new TimerCallback(this.TimerCode3);
timer3 = new System.Timers.Timer(timerCallback4, null, 5000, 20);


The error is
Quote:
No overload for method 'Timer' takes '4' arguments

The part of the code that is underlined as incorrect is TimerCallback and everything in parenthesis after that.


This one is self-explanatory, really. If you look up the documentation for the System.Timers.Timer object:

http://msdn2.microsoft.com/en-us/library/system.timers.timer.timer.aspx

You will see that it has only two constructors, none of which have four parameters.

You probably meant to use the System.Threading.Timer object, which has the constructor that you are trying to use:

http://msdn2.microsoft.com/en-us/library/system.threading.timer.timer.aspx

Nauntilus wrote:
And finally the last part I am having problems is.
Quote:
if ((int)strs1.Length > 1)
{
timer1.Change(0, Convert.ToInt32(strs1[1]));
}
label.Top = base.Height / 2 - label.Height / 2;
label.Left = base.Width / 2 - label.Width / 2;
}
else if (Code0[i].Substring(0, 6) == "")
{
stnpanel2.BringToFront();
string[] strs2 = Code0[i].Substring(6, Code0[i].Length - 13).Split(new char[] { Convert.ToChar("^") });
if ((int)strs2.Length > 1)
{
long l = Convert.ToInt32(strs2[1]);
timer1.Change(l, l);
}
else
{
timer1.Change(5000, 5000);
}
ie2.Navigate(strs2[0], ref arg1, ref arg2, ref arg3, ref arg4);
}

The first error has to do with the Change part of timer1.Change.

This is the error;
Quote:
'System.Windows.Form.Timer' does not contain a definition for 'Change'


The second error has to do with the ie2.Navigate(strs2[0], ref arg1, ref arg2, ref arg3, ref arg4); Part and the error is:

Quote:
No overload for method 'Navigate' takes '5' arguments


All help is really appreciated, I have been banging my head against this for 2 weeks.

~Nauntilus


The first error is pretty similar to the one we had before. You are trying to use a System.Windows.Forms.Timer object. Look up the documentation for it:

http://msdn2.microsoft.com/en-gb/library/system.windows.forms.timer_members.aspx

You will see it has no Change method. Once again, you probably meant to use a System.Threading.Timer object, which has the method that you are trying to use:

http://msdn2.microsoft.com/en-us/library/system.threading.timer_members.aspx

As for the second error, it's not obvious to me what type of object ie2 is, so I can't look that one up.

The long and the short of it is that all of these errors look like they can be solved by taking a closer look at the documentation. You should probably take some time to get to know the MSDN Library.

Finally, I neither use nor know C# in any great depth, so most of this is 'psychic debugging' on my part. I hope it helps.

_________________
Pie. I wish I could
constrain my hungry greed but...
Sadly, defeated.


Charlene's Law: There's no such thing as can't.
Charlene's Corollary: Unless it's followed by be arsed.

If only 20% of your staff is programmers, and you can save 50% on salary by outsourcing programmers to India, well, how much of a competitive advantage are you really going to get out of that 10% savings?
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic     Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours

Help us keep advertisements off this site. Donate today!