|
Hi,
I need to convert an hex datetime value 0x43599f4e to a .net datetime. I tried to convert the hex value to an int, but couldn't convert that to a datetime since System.Convert doesn't support conversion of long/int values to datetime. Any ideas?
Thanks
Paul
paul
|
|
|
|
|
PaulLou wrote: I need to convert an hex datetime value 0x43599f4e to a .net datetime.
How is this hex value a datetime ? Where did it come from ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is it ANSI C time? ie: The number of seconds since 1/1/1970 midnight, the Unix time epoch? If so, then do this...
int intTime = 0x43599f4e;
DateTime myTime = new DateTime(1970, 1, 1);
myTime = myTime.AddSeconds((double)intTime);
|
|
|
|
|
Hi Joshua,
Your solution works great. The values got converted correctly. Thanks a lot for your reply. Can you pl tell me to me why 1970 0101 is taken as the seed value, or the reason behind it. I somehow thought year 1900 would be the year from which the calculations takes place and it is not in .net.
Thanks
Paul
|
|
|
|
|
Hi Paul. I'm glad to hear that it's working for you.
PaulLou wrote: Can you pl tell me why 1970/01/01 is taken as the seed value, or the reason behind it.
The time value that you had was in ANSI C time. It's a 32 bit time_t type (just a signed int really) in the C language which is used by other standard ANSI C time functions. 1970/01/01 00:00:00 is what's called the UNIX epoch. Time is stored as seconds since the UNIX time epoch.
So, 0 would be 1970/01/01 00:00:00.
60 would be 1970/01/01 00:01:00.
Why did they choose 1970? I don't know. Probably because it sounded like a good idea at the time. Unfortunately, since it is a signed 32 bit integer, it'll overflow sometime in the year 2038. So some of our old C and C++ apps will go through the equivalent of a Y2K issue at that time.
Java time apparently starts at 1970 too, but it uses milliseconds instead of seconds.
I think MS Access' timestamp field starts at 1900.
Well, that's my 2 cents.
|
|
|
|
|
hi everyone,
i have gathered some image resources from devenv of Microsoft.net vs, and i saw some bitmaps of 16x256 size (a list of 16x16 but 16 images) for example.
I understood devenv uses these bitmaps as images in program but divides into 16x16 images first.
how can i divide this large images into small images (any type) programatically?
thanx.
|
|
|
|
|
The most obvious way would be to write code to load the image, then copy each section into a 16x16 bitmap and save it
Bitmap [] bitmaps = new Bitmap[16];
for(int i=0; i < 16; ++i)
{
bitmaps[i] = new Bitmap(16, 16, toolstrip.PixelFormat);
using (Graphics gr = Graphics.FromImage(bitmaps[i]))
{
gr.DrawImageUnscaled(toolstrip, i*16, 0, 16, 16);
}
}
That's not been run, so it could have errors, but you get the idea. bitmaps should contain an array of images for each icon. You can call Bitmap.Save to save them to disc.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Because you're not passing the item by reference, it's being copied every time you call the function.
If you check 'Ignore HTML tags in this message (good for code snippets)' below, we'll be able to see all of your code and comment further
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm array is created using the new keyword, that makes it a reference type doesn t it?
|
|
|
|
|
yes, that is true, but you still need to specify ref if you want to pass by reference.
Like I said, I'm guessing because you didn't post your code legibly. In .NET, reference types are reference counted. A new object is created when your old object is modified, unless it's passed by ref.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: yes, that is true, but you still need to specify ref if you want to pass by reference.
I think you misread the question. The OP asked about copies of the *array* being created when accessing the SomeArray property, he doesn't want to pass the result of obj.SomeArray[i] by reference or by value. Arrays are reference types, so they are *not* copied. In the OP's code, only the reference to the array is copied when he does obj.SomeArray.
Christian Graus wrote: In .NET, reference types are reference counted. A new object is created when your old object is modified, unless it's passed by ref
Huh? I thought reference counting is solely for the purpose of garbage collection. It definitely is *not* used to implement copy on write semantics.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote: I think you misread the question.
To be honest, I wrote it off as the code was illegible, and expected to be able to answer it better once the code was properly posted.
S. Senthil Kumar wrote: Huh? I thought reference counting is solely for the purpose of garbage collection. It definitely is *not* used to implement copy on write semantics.
Perhaps I need to read my .NET framework book again, because I was sure that is what it said happens.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Depends on how the SomeArray property has been implemented. If it's like
public int[] SomeArray
{
get { return someArray; }
}
then no, no copies of the array are created, because array is a reference type. So only the reference to the array is copied.
However, this means that the client can do something like
int []arr = obj.SomeArray;
arr[0] = arr[1] = 0;
and this will result in the original array also being updated.
In case the programmer didn't want that to happen, he/she will code the SomeArray property as
public int [] SomeArray()
{
return (int[] )((ICloneable)someArray).Clone();
}
in which case, everytime someone does obj.SomeArray[i] , a new copy of the array is created.
In fact it's not recommended to have properties that return arrays for precisely this reason. According to MSDN[^],
Use a method when:
...
* The member returns an array. Properties that return arrays can be very misleading.
Usually it is necessary to return a copy of the internal array so that the user cannot change internal state.
This, coupled with the fact that a user can easily assume it is an indexed property, leads to inefficient code.
In the following code example, each call to the Methods property creates a copy of the array.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i understand now, so only the reference is copied.
thanks
|
|
|
|
|
Hi, I've read several articles about drag&drop and know how to d&d text from one textbox to another.
But if I catch the MouseDown event, I can't select text or if I select text it becomes unselected if I try to drag it.
My target is to select and drag and drop text like in Visual Studio itself (Just from one textbox to another).
I tried several workarounds, but no one works as expected.
My environment is Visual Studio, graphics library is default Windows Forms.
I would appreciate helpfull hints, thank you.
Kalix
|
|
|
|
|
you want to check to see if there is selected text first (selected text length > 1). If there is, you are doing a drag/drop. If not, you are selecting text. This is how you make the distinction.
hope this helps
|
|
|
|
|
Thanks for your reply. I tried to check the SelectionLength and SelectedText propertys, but if I start to drag the text becomes unselected.
It would work, if the MouseDown event is fired before the unselection.
Does anybody have an idea?
|
|
|
|
|
Hi
I need to draw a Border around a Tabcontrol ( i mean around the entier Tabcontrol not around the TabPages). i am able to do draw a border by overriding the OnPaint method but the Tabs disappear. This is my code. I have the double buffering code in the constructor.
<br />
base.OnPaint(e);<br />
Rectangle borderRectangle = ((Control)this).ClientRectangle;<br />
int BorderWidth = 1;<br />
Color BorderColor = Color.Black;<br />
ControlPaint.DrawBorder(e.Graphics, borderRectangle, BorderColor, BorderWidth, ButtonBorderStyle.Solid, BorderColor, BorderWidth, ButtonBorderStyle.Solid, BorderColor, BorderWidth, ButtonBorderStyle.Solid, BorderColor, BorderWidth, ButtonBorderStyle.Solid);<br />
Can anyone help me out in this. My question is do i have to draw the tabs aswell or am i missing something.
Regards
Deepak
-- modified at 14:01 Monday 14th November, 2005
|
|
|
|
|
Dear Experts,
I want to copy open files (DLL or Database file) If I use File.Copy(srcFile,dstFile) method it returns an error "Can not access file "filename" it is being used by another process.". Please help me how can I copy such files??
Best regards,
Asaad
Osman
|
|
|
|
|
close the file and then copy it again.
|
|
|
|
|
Dear Sir,
Thank you for your prompt reply. I dont want to close file. Actually I want to copy SQL Server Database files or any DLL so I dont want to stop SQL Server Service or How can I close DLL.
Thanks
Osman
|
|
|
|
|
Hi
After Drawing UML Class Digram by using MS-Visio
How i Can Generate C# Source Code of this UML Class Digram...
thanks
|
|
|
|
|
Hi
Is there an equivalent to UML multiplicitys and Association Class in the Visual Studio Class Designer?
and how i can draw Association Class in the Visual Studio Class Designer?
thanks ....
|
|
|
|
|
Hi,
I've got a custom user control using inheritance that I'm working on that I would like to cancel the 'Click' event. Any help would be greatly appreciated.
|
|
|
|