|
Cool! Once I realized arrays aren't EVER passed by value
(pointed out by a fellow MVP) it was fairly straight forward.
Apparently I need to dust off my "C Programming for Idiots" book
You have a great day as well.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I need to override GetHashCode based on two Int32s.
Obviously, I can't get unique hash codes as it has to return one Int32.
I'm doing this at the moment, is there a better way to do it?
(m_Lower and m_Upper are both Int32)
public override int GetHashCode()
{
return (((Int64)m_Upper << 32) + m_Lower).GetHashCode();
}
I couldn't find any documentation on how Int64 implements it.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
The only strict requirement for the GetHashCode method is that it should always return the same hash code for a given value. So, this is a valid implementation of the method:
public override int GetHashCode() {
return 0;
}
However, that gives bad performance when you use the hash code for example in a dictionary. For good performance, the hash codes should be evenly distributed over the Int32 range of values.
This is how the implementation looks for the Int32 type:
public override int GetHashCode() {
return this;
}
This is how the implementation looks for the Int64 type:
public override int GetHashCode() {
return ((int)this) ^ ((int)(this >> 0x20));
}
As you see, it just throws away the top 12 bits. If you want to use all the bits in the hash code, you can just do an xor of the upper and lower value:
public override int GetHashCode() {
return m_Upper ^ m_Lower;
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Guffa wrote: throws away the top 12 bits
Actually, it's just splitting it into 2 ints and xoring them - 0x20 (Hex!)
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Yes, you are right. Why didn't I think of that, that is what I would expect it to do...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Which is the elemental code for searching in a datagridview column?. How to give the focus at the row with the value found?
|
|
|
|
|
Not sure what you're trying to do but you don't need to search into Columns, you can simply search in Rows:
DataGridView dgv = new DataGridView();
DataGridViewRow dgvr = new DataGridViewRow();
dgvr.Cells[0].Value = "Hello!";
dgv.Rows[dgv.Rows.IndexOf(dgvr)].Selected = true;
While (true) { Human.isLearnable = true; }
|
|
|
|
|
You can do that with sql procedures, after trigger it in a c# event
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
|
Hi guys,
Need some help please. I have a scan feature in my form and on form_load I am trying to fire the btnScan.performclick() event. It works but my form doesn't load until scanner times out or then I scan. I want the form to load and the picturebox to show no image while the scanner is waiting for an image.
I hope I am making sense.
Sameer
Sameer
|
|
|
|
|
Have a timer that gets started in the form load event, and then do the btnScan.PerformClick() in the timer's event handler.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
Thank you for your suggestion, it worked...
S
Sameer
|
|
|
|
|
I think you need Threading[^]
While (true) { Human.isLearnable = true; }
|
|
|
|
|
can you please give me an example
Thanks
Sameer
|
|
|
|
|
Sure[^]
While (true) { Human.isLearnable = true; }
|
|
|
|
|
For simplicity - use the BackgroundWorker component.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thank you Davey,
I decided to go with a timer that calls the performclick event. Thanks
S
Sameer
|
|
|
|
|
You don't put all the code for doing the scan in the btnScan.Click event handler. You put it in it's own method somewhere, then you can call that method from anywhere in your code, including the btnScan.Click event handler AND from in your Load event.
|
|
|
|
|
Thank you Dave for your response. I tried your suggestion and it didn't work, I believe the problem is that I have a while loop that waits for a response from the scanner in my btnscan_click event.
I instead added a timer and I am calling the btnScan.Performclick from there. That seems to be working, I am not sure if this is the best way to go with it but it works
Sameer
Sameer
|
|
|
|
|
hi,
I work in an application to show figures. I want diferent layers to each figue. I need draw figures independently one to another.
I´m using a transparent bitmap for each figure, and in OnPaint of a panel i draw all. But i got flicker when i move the objets.
What tecnics or class i could use to acomplish mi goals.
Thanks
Marcos.
|
|
|
|
|
Using DirectX would be a better approach. Have a look into 2D imaging in XNA.
Cheers,
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
Click here to view my blog
|
|
|
|
|
Thanks Mark, Im investigating directx now.
|
|
|
|
|
You need to make sure that no graphic manipulation is being done by any other method except the OnPaint method. The graphical and logical aspects of user controls must be independent for a smoot and flicker free control.
One of my articles has been able to help quite a few people with custom paint routines: Basics of Falling Blocks in VB 2005[^]
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
hi Thomas.
I read your article. I have problems with graphics. the quid of question is what tool i must to use to implement layered grapchics?. Then each figure must respond to mouse events, and have their own properties.
regards
Marcos
|
|
|
|