|
I'm not quite sure what you're asking. Are you trying to turn your uint into a DateTime?
Edit:
Boy, MSDN[^] is sure helpful:
Convert.ToDateTime Method (UInt32): Return Value
This conversion is not supported. No value is returned.
Jon Sagara
Look at him. He runs like a Welshman. Doesn't he run like a Welshman? Doesn't he? I think he runs like a Welshman.
Sagara.org | Blog | My Articles
-- modified at 21:02 Wednesday 22nd February, 2006
|
|
|
|
|
Yea, but the Uint32 that holds the time contains UTC formatted time from a C based program sent over ethernet. I pull it out of a packet, decode and now I need to be able to convert it to DateTime to be able to use it the C# app. Thanks
|
|
|
|
|
I believe the Uint32 value is the number of seconds since January 1, 1970 (most likely). Thus, to get the correct DateTime, you must initialize the your DateTime variable to January 1, 1970 and add the Uint32 seconds to it.
-- modified at 23:33 Wednesday 22nd February, 2006
|
|
|
|
|
Thanks for the tip George. Here's what I have encountered:
uint uval
DateTime dt = new DateTime( 1970, 1, 1 );<br />
dt.AddSeconds( uval );<br />
Console.WriteLine( "Date is {0}", dt.ToLocalTime( ) );<br />
Here is a real result to illustrate:
2/23/2006 11:49:15 AM: Raw POSIX Date-Time: 1140713262, Conversion: 12/31/1969 7:00:00 PM<br />
I printed out the 2K/POSIX value, followed by the conversion to local time. I was thinking the conversion should have yielded a date time along the lines of the message preamble 2/23/2006 11:49:15 AM give or take a few seconds in terms of synchronization w/ the server time. However it was off by just a few years!
I was curious to what was happening so I changed the dt.ToLocalTime() to dt.ToUniversalTime() and it yields 1/1/1970 5:00:00 AM. Since the DateTime is initialized to DateTime( 1970, 1, 1 ) this begs the question of just what is dt.AddSeconds( Convert.ToDouble( uval ) ) adding?
Interestingly if I print out dt without the ToLocalTime() conversion it yields 1/1/1970 12:00 AM. That means the seconds added should be 18000 to result in 1/1/1970 5:00:00 AM. This is why I am a little suspect of the 2K/POSIX value, it doesn’t make sense to me to added a 10 digit value and only yield a 5 hour delta since the 1970 epoch.
Now I have quadruple checked the packet decoding logic and I can tell you that all fields before and those after in a variable length packet are all correct and at the appropriate offset. Thus I have revisited the decoding and it appears to be OK in every respect less the date time situation.
At this juncture I am wondering if the 2K flavor of UTC requires any special consideration. Or is there something I am just plain missing? I am stumped.
Final FYI – according to the documentation from the Server vendor, the date-time is stored as followed:
TIME 4 Bytes A date/time, expressed as the number of seconds since Midnight January 1, 1970 Coordinated Universal Time (UTC).
So at least I know I am playing with the right deck,
Mike Luster
|
|
|
|
|
I have succeeded in getting my code to successfully do mouse clicks on a commercial program, running at a specific screen location, using this code:
SetForegroundWindow(targetWindowHandle);
input.type = INPUT_MOUSE;
input.mi.dx = 900;
input.mi.dy = 50;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dwFlags = 0;
input.mi.dwExtraInfo = 0;
SetCursorPos(input.mi.dx, input.mi.dy);
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE+MOUSEEVENTF_LEFTDOWN);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
The problem is, of course, if the window is moved, the clicks miss. I would love to be able to do the clicks relative to position 0,0 of the window pointed at by targetWindowHandle instead of relative to position 0,0 of the screen.
(I hope that statement makes sense to you guys.)
Any suggestions?
Thanks.
-- modified at 20:11 Wednesday 22nd February, 2006
|
|
|
|
|
for those interested ...
The solution was rather trivial after i found "GetWindowRect" in User32:
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
public static extern int GetWindowRect(int hwnd, ref RECT rc);
// Get the target window's screen coordinates
RECT rect = new RECT();
int hwnd = GetWindowRect((int)targetWindowHandle, ref rect);
Persistence pays ...
---
-- modified at 15:34 Thursday 23rd February, 2006
|
|
|
|
|
I need to make a calcualtor (must be able to add, subtract, divide, and multiply). Two text boxes allow you to enter numbers which in turn does the math and prints to a seperate
|
|
|
|
|
Homework question?
jessica gelina wrote: and prints to a seperate
Missing end of sentence, the adjective should be followed by a noun.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
|
jessica gelina wrote: the only reference we got was that it is similar to the C++ method
Which is what?
You've got to be more specific about what your problem is in order for us to help. For example, I commented that in your first post the sentence ended midstream. So we can only guess or assume what you want.
You have two text boxes.
I'm assuming you have a bunch of buttons. +, -, /, *
I'm assuming you have a textbox or label for the result.
What part isn't working? What have you tried already?
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
i have two text boxes, and four buttons. Each text box allows for numbers, the buttons are teh math function. They then print the answer onclick to a seperate label.
I have tries adding the strings which simply put the two numbers in the box next to one another. I have tries sending the text.tostring function to the label.......
|
|
|
|
|
You need to convert it to an int before you can add them. Use this method:
<br />
int x = Convert.ToInt32(
int y = Convert.ToInt32(
<br />
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|
|
int x;
int y;
private void btnAdd_Click(object sender, System.EventArgs e)
{
int x = Convert.ToInt32.txtFirstNum;
int y = Convert.ToInt32.txtSecondNum;
x + y;
}
It doesn't recoginze the ToInt32! Is this supposed to be my answer label name?
|
|
|
|
|
jessica gelina wrote: int x = Convert.ToInt32.txtFirstNum;
int y = Convert.ToInt32.txtSecondNum;
Can't you at least copy/paste correctly????
Regards,
Nish
|
|
|
|
|
|
In addition to my previous post.
jessica gelina wrote: x + y;
Needs to assign the result to something in order for you to use it. e.g.
int result = x + y; Then you can take the result and assign it to the Text property of your Label . (Remember to convert it to a string when you do that)
Does this help?
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
He is referring to the fact that you coded:
Convert.ToInt32.txtFirstNum; When the example clearly used brackets and specified you needed to pass in a string .
Convert.ToInt32(txtFirstNum.Text);
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Just need to make a few changes:
<br />
private void btnAdd_Click(object sender, System.EventArgs e)<br />
{<br />
int x = Convert.ToInt32(txtFirstNum.Text);<br />
int y = Convert.ToInt32(txtSecondNum.Text);<br />
x + y;<br />
}
That should fix it
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|
|
Sean89 wrote: int x;
int y;
What's this bit for ? ( outside the click event handler )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ohh lol oops.
private void btnAdd_Click(object sender, System.EventArgs e)<br />
{<br />
<br />
int x = Convert.ToInt32(txtFirstNum.Text);<br />
int y = Convert.ToInt32(txtSecondNum.Text);<br />
x + y;<br />
<br />
}
Sorry bout that.
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|
|
|
Sounds just like project 5 in the Basic Programming course at St Louis Community college.
Good luck.
|
|
|
|
|
Somebody has to start somewhere.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi all,
does anyone have any idea about using the microsoft speech api in a c# application. I've got the basics down but there's limited to no documentation available. MSDN only seem to documentation, examples, etc for C++. The problem is that some of the classes etc are either not available or different in some way that those available in c#.
I'm particularly interested in changing voices, pitch, rate, volume, etc.
Thanks
Rich
|
|
|
|
|
Does anyone know anything about Microsoft's plans for Source Safe? Have they just lost interest in providing version configuration management packages? Someonce mentioned 2007 to me?
I am currently using the old Visual Studio Source Safe. Does anybody know of any plugins or anyway to improve the differ?
Cheers
AJ
|
|
|
|