|
From my form I change(add or delete) data in datagridView source; How can do to see immediatly thoses modifications
|
|
|
|
|
Have you tried the Refresh method?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi all,
I know how to use the dynamic_cast in Borland, but how would I do something like this in CLI VC++:
for (int k = 0 ; k < Form1->ComponentCount ; k++)
{
if(Form1->Components[k]->ClassNameIs("TImage"))
{
dynamic_cast <TImage*>(Form1->Components[k])->Picture->LoadFromFile("T1.bmp");
}
}
Many Thanks
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
If TImage is a managed object:
dynamic_cast<TImage^>(Form1->Components[k])->Picture->LoadFromFile("T1.bmp");
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks for the help George I'll try it...
Reagrds,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi,
I need to get a flag, and protocole type in tram TCP, for that i would use WinPcap4.0 but unfortunatly it doesn't work ' i have installed Wpcap.exe ', in first i try to obtain a device list:
<br />
pcap_if_t *alldevs;<br />
pcap_if_t *d;<br />
int i=0;<br />
<br />
for(d= alldevs; d != NULL; d= d->next)<br />
{<br />
printf("%d. %s", ++i, d->name);<br />
if (d->description)<br />
printf(" (%s)\n", d->description);<br />
else<br />
printf(" (No description available)\n");<br />
}<br />
<br />
if (i == 0)<br />
{<br />
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");<br />
return;<br />
}
Please help me de resolve this great broblem,
Thank you verry mutch
|
|
|
|
|
i have a project of developing a linux chat server and i need help for it fast.contact me at arjunjag@yahoo.com so that i can send you all the details as soon as possible.
thanks
Arjun
|
|
|
|
|
You do realise that this isn't the way that these forums work don't you? People will get to you when they can.
Plus, this site is more for Visual Studio and .NET, not Linux.
Finally, don't put your email address in a request. It's not very nice, and it is a very good way to get spammed. You do realise that these forums are googled don't you?
|
|
|
|
|
Hi All
I am using the srand function generate random numbers.Here is the problem.
for example:
#include<iostream>
#include <time.h>
int main()
{
int i = 0,j = 0;
srand((int)time(0));
for(i=0; i<10; i++)
{
j=1+(int)(10.0*rand()/(RAND_MAX+1.0));
std::cout << j << '\t';
}
std::cout << std::endl;
return 0;
}
result:
5 8 8 8 10 2 10 8 9 9
2 9 7 4 10 3 2 10 8 7
The problem is that the two lines of the results are the same when the compiler run over in one second.
How the function works?
how the computer make the rand numbers?
Does the function can generate really Random Numbers ?
Please help me out if you find some solution for the above problem.
Thanks in advancs !
Where did the good times go?
Don't try it, just do it!
*Archibald*rever dragon!
|
|
|
|
|
Random numbers are very rarely random. They are defined using standard algorithms, and will return the same values based on the same seed value. Hence, they are known as pseudo-random numbers.
If you need the sequences to differ, then you need to use a different seed value.
|
|
|
|
|
thx a lot
now i see!
Where did the good times go?
Don't try it, just do it!
*Archibald*rever dragon!
|
|
|
|
|
Can someone clarify the differences between interior pointers and handles for me?
As I understand it, interior pointers do what handles can plus they allow for pointer semantics (arithmetic and comparison). Interior pointers also can point to unmanaged objects and native pointers are implicitly converted to interior pointers (but not vice versa). Both seem to be able to point to interior members of managed objects (such as an array of managed objects, or a managed class with a member variable of another managed type). Neither support double indirection (ie handle to a handle). So is there anything a handle can do that an interior pointer can't? In which case I assume handles are used purely for convenience as they're far easier to read/write/work with if you don't need the extra capabilities of an interior pointer. So basically use interior pointers over handles only when you need pointer semantics or some sort of interop capability?
|
|
|
|
|
|
Right, that's just making use of the pointer semantics of interior pointers.
My main point of confusion right now is that my initial understanding was that handles could only point to whole CLI objects (ie not interior data members no matter their type). In which case that would be an important place where interior pointers would need to be used. However, I can make a ref class Foo with a data member of a ref class Bar and a data member of a managed value class V (each of those classes as int data members) and use a handle to point to the Bar member, the V member, or even the int members of those 2 objects. So while using a handle to the int might incur a boxing cost, its still quite possible. So the only thing I see handles unable to point which interior pointers can are native objects. This seems to say that interior pointers are only useful for when pointer semantics are required or you need them for interop which I thought for sure was not the only time you needed them.
That's a little confusing considering:
"CLI object references always refer to a whole object of CLI type on the CLI heap (e.g., it cannot refer to a directly held member inside a CLI reference type object, or to an object on the C++ heap)."
from page 27 of the C++/CLI Design Rationale. http://www.gotw.ca/publications/C++CLIRationale.pdf
|
|
|
|
|
Adding to led mikes comment, the tracking handle points to a managed object's header. It is a whole-object pointer. The interior pointer points to a manage object's data and you can use a pointer-typed interface to move from one data item to another. So, interior pointers only are used in special situations.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Ok, so for the most part an interior pointer and handle can point to the same types of things (i.e., a ref class, a ref class data member of another ref class, a value type data member of a ref class, etc). The difference is that when they are seemingly pointing at the same thing, the handle is pointing at the object's header information (and thus the whole object) while the interior pointer has the specific address of the object's data itself (which is what allows it to use pointer semantics). That makes sense I think. But you say interior pointers are only used in special situations. That seems to imply that replacing handles with interior pointers in some situations is not going to work (which I didn't think was the case). Is that right? And if so, could you give me a basic example of such a situation?
I'm still unclear on the implications of the quote from the Design Rationale doc. When it says handles can't point to interior data members of an object, that just means it can't point to the specific address of the data giving it pointer semantics? But it can still point to the whole object data member meaning they're perfectly useful for pointing to interior data members as long as you don't need pointer semantics and just want a tracking pointer. No?
|
|
|
|
|
using namespace System;
void MultiplyArray( array<int>^ data, int value )
{
// Interior pointers only refer to the managed object's state or data.
// They are initialized with an address of a managed object's data item.
// They do not produce verifiable code; so, you cannot compile this code
// with /clr:safe. They cannot be converted to or casted to a native pointer.
// However, interior pointers can be converted to pinned pointers.
interior_ptr<int> begin = &(data[0]);
interior_ptr<int> end = begin + data->Length;
while (begin < end )
{
*begin *= value;
++begin;
}
}
// Tracking references point to the whole managed object.
// Using a tracking reference here does not make much sense since using a
// tracking handle has the same affect in this case.
void PrintArray( array<int>^% vals )
{
for each (int val in vals)
{
Console::WriteLine(val);
}
}
int main(array<System::String ^> ^args)
{
// Tracking handles refer to the whole managed object.
// They can be initialized with gcnew.
array<int>^ values = { 1, 2, 3, 4, 5 };
MultiplyArray(values, 2);
PrintArray(values);
return 0;
}
|
|
|
|
|
Ok, thanks, that's a good example of where interior pointers can simplify things. But you could do similarly with just handles if you have an array of 'handle to typeX' even if its not quite as nice a solution.
(Sorry I'm not sure how to use the code tag and ignore HTML so the array type is shown.)
#include "stdafx.h"
using namespace System;
// Can multiply the array elements when the array type is handle to type
// rather than needing interior pointers.
// A little silly with int due to boxing costs but imagine with an array of
// ref class objects where you do perform some useful change to each element
void MulArray( array<int^>^ data, int value )
{
for each(int^% i in data)
{
*i *= value;
}
}
// Tracking references point to the whole managed object.
// Using a tracking reference here does not make much sense since using a
// tracking handle has the same affect in this case.
void PrintArray( array<int^>^ vals )
{
for each (int val in vals)
{
Console::WriteLine(val);
}
}
int main(array<System::String ^> ^args)
{
// Tracking handles refer to the whole managed object.
// They can be initialized with gcnew.
array<int^>^ values = { 1, 2, 3, 4, 5 };
MulArray(values, 2);
PrintArray(values);
return 0;
}
Now I understand why you'd want your version in some cases where you're being passed an array<int>^ that you didn't choose to create. In theory you could create a new array (of array<int^>^) to copy the array<int>^ to use with my version if you wanted to avoid interior pointers and make the code verifiable. I'm just trying to draw a solid line in my mind dividing the uses of handles and interior pointers. Like I said (and you just showed), they can be useful for pointer semantics. But you can still find a way to avoid them and use handles to point to interior members. So are the only time they're absolutely necessary are when you must have pointer semantics and in some interop scenarios (where native pointers can convert implicitly to interior pointers but not handles)? They can simplify some situations where you're pointing to interior members of a ref class but you can still get around doing so via handles (even if it may not be as elegant and performant as the interior pointer solution).
|
|
|
|
|
What is the correct syntax for setting up a DataSet array in managed C++
In C# I used the following
public static DataSetPI40[][] dsPI40 = new DataSetPI40[8][];
and I tried the following in C++ but had errors.
public:
static DataSetPI40[8][40]^ dsPI40 = gcnew DataSetPI40[8][40];
Can someone please help with this, thanks.
Michael
|
|
|
|
|
Arrays are different in C++/CLI:
array<DataSetPI40^, 2>^ dsPI40 = gcnew array<DataSetPI40^>(8, 40);
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I still get the following error.
Error 6 error C2767: managed array dimension mismatch :
expected 1 argument(s) - 2 provided
After I change this to the following and it worked.
after adding ", 2" to the otherside it worked
But when I add the second dimension as follows it compiles.
static DataSetPI40::PIVar40DataTable^ PIVar40 =
gcnew DataSet_PI40::PIVar40DataTable();
but, when I refer to the Dataset I get the following error.
dsPI40[1][5]->PIVar40[nRecNumID]->ColumnName
Error 8 error C3262: invalid array indexing: 1 dimension(s) specified for 2-dimensional 'cli::array<Type,dimension> ^'
Michael
|
|
|
|
|
I am sorry about not including the second "2":
<code>array<DataSetPI40^, 2>^ dsPI40 = gcnew array<DataSetPI40^, 2>(8, 40);
dsPI40[1, 5]->PIVar40[nRecNumID]->ColumnName</code>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks, but I understood that. However, when I add the variable for the table as above it compiles also.
When I try to load the table above with data it says there is only one dimension, therefore I must be stating the table variable incorrectly I assume, do you know what the problem is.
Michael
|
|
|
|
|
You didn't look at my above response carefully! You wrote:
dsPI40[1][5]->PIVar40[nRecNumID]->ColumnName
I responded with:
dsPI40[1, 5]->PIVar40[nRecNumID]->ColumnName
Your code above had "[1][5]" where the complier compiled only up to the "]" after the 1 and believe you only supplied one dimension.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Everything works great, thanks for the help.
Michael
|
|
|
|