|
Anyone had any experience adding GPS support to a managed C++ application?
I will be checking out the articles in the next couple of days but I would also like to here some experiences of what is possible and the extent of any difficulties. e.g. are GPS aware laptops becomming more common or does your typical laptop still need a connection to a GPS device or smart phone?
Ger
|
|
|
|
|
Ger Hayden wrote: are GPS aware laptops becomming more common
Even if it were true I would doubt there would be any way to validate it.
And without some qualification (probably severe) to restrict to a targeted market I would seriously doubt it.
|
|
|
|
|
Hi, I've been banging my head against the wall for a few days with this one, so if anyone has a solution, you would be my hero. What I'm looking for is a way that when a Form is FIRST created and shown, it is already in the minimized state. I'm already aware of putting an icon in the tray, but that doesn't work the way I need it to, it must start already minimized in the taskbar. I also cannot have it show up for a quick second and then minimize, which is the only thing I can seem to get it too do. I don't want to go into all the specifics as why my program needs to do this, just trust me, it does. Any help would be greatly appreciated! Thanks!
|
|
|
|
|
Set WindowState = Minimized in your form's properties.
I must get a clever new signature for 2011.
|
|
|
|
|
I cannot get the syntax for the cyclic list class I am working on.
In the following class you see that I have a property named CycItem .
This works, but I would like to have it be the default indexer so I can just use Item or [] .
Any help would be great.
#pragma once
using namespace System;
using namespace System::Collections::Generic;
using namespace System::Reflection;
namespace MG_Geo {
generic <typename T>
public ref class CycList: public List<T>
{
public:
CycList()
{
}
property T CycItem [int]
{
T get(int index) {
if (this->Count==0)
{
throw gcnew IndexOutOfRangeException("IndexOutOfRange Count = 0");
}
while (index < 0)
{
index = (this->Count + index);
}
if (index >= this->Count)
{
index = (index % this->Count);
}
return this[index];
}
void set(int index, T value) {
if (this->Count==0)
{
throw gcnew IndexOutOfRangeException("IndexOutOfRange Count = 0");
}
while (index < 0)
{
index = (this->Count + index);
}
if (index >= this->Count)
{
index = (index % this->Count);
}
this[index] = *value;
}
}
};
}
modified on Friday, January 7, 2011 6:22 AM
|
|
|
|
|
Base class List(T) already has a default indexed property. You need to define your own on your class and mark it as new .
property T default [int]
{
virtual T get(int index) new
{
}
virtual void set(int index, T value) new
{
}
}
Best wishes,
Navaneeth
|
|
|
|
|
|
posting the same question multiple times is against the site's rules, and will keep people from answering at all.
Did you read the forum guidelines?
|
|
|
|
|
Need to pass private member of a Class as a argument to function of another class and get modified there and Class A will again user the modifed value of x there after..
int .Net Managed C++
class A
{
private :
int ^x;
...
B ^ ojbB;
ojbB->TheFunctionneedsPrivateObjectof_A( int &x)
}
class B
{
public TheFunctionneedsPrivateObjectof_A(int ^x)
{
Modify x here
}
}
|
|
|
|
|
You could declare a property p_x in class A. Class B would then use p_x to get the value of x,then it can operate on the value at will, and finally use p_x place the result back into x for class A to carry on with.
Ger
|
|
|
|
|
If x is already a reference to an object (why int ^ ?) then all you should need is:
ojbB->TheFunctionneedsPrivateObjectof_A(x);
which will pass x as a reference to the object, thus allowing the called function to access its member variables.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hmm. That would cause an unnecessary strong dependency. And the member was private.
|
|
|
|
|
He/she asked how to do it, not whether it was a good thing.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hm, it depends on what are you are trying to accomplish. I assume you are dealing with CLR types in your example. In this case you are missing the ref keyword. If A and B are meant to be native C++ classes the code as you have posted it is wrong and would never compile since you cannot hold a handle to a managed type in an instance of a native class without resorting to gcroot . That said, technically, you can of course pass a handle or tracking reference to a CLR object like this:
public ref class A {
YourComplexObject^ mHandleToYourComplexObject;
B^ mHandleToB;
public void PassYourComplexObject() {
mHandleToB->TakeComplexObject(mHandleToYourComplexObject);
}
};
public ref class B {
public void TakeComplexObject(YourComplexObject^ pHandleToYourComplexObject) {
}
};
EDIT: Corrected PassYourComplexObject
modified on Friday, January 7, 2011 6:13 AM
|
|
|
|
|
with the example below you should be set
Also works for other ref classes not only for primitves as int.
ref class A
{
private :
int x;
...
void foo()
{
B ^ ojbB;
x = 1;
ojbB->Increment(x);
}
}
ref class B
{
public:
void Increment(int %x)
{
x++;
}
}
Hope, I could help...
|
|
|
|
|
How to get the delagate value via property
property MyCallback^ CallBack1
{
MyCallback^ get {return m_pCallBack; }
}
Private MyCallback^ m_pCallBack;
Thanks
|
|
|
|
|
Here's one way:
using namespace System;
public delegate bool MyCallbackDelegate(void);
public ref class Test
{
private:
MyCallbackDelegate^ m_pCallBack;
bool doIt(void)
{
Console::WriteLine("Do It Called");
return true;
}
public:
Test()
{
m_pCallBack = gcnew MyCallbackDelegate( this, &Test::doIt );
}
property MyCallbackDelegate^ CallBack1
{
MyCallbackDelegate^ get() { return m_pCallBack; }
}
};
int main(array<System::String ^> ^args)
{
Test^ t = gcnew Test();
MyCallbackDelegate^ d = t->CallBack1;
d();
return 0;
}
John
|
|
|
|
|
Getting warring
warning C4677: 'Invoke': signature of non-private member contains assembly private type.. at
public delegate bool MyCallBac..
But I need the property to be public..
|
|
|
|
|
I don't see any warnings with the code I posted so you have something different. I'd need to see more code to help diagnose the problem.
The property and delegate are public in my example.
John
|
|
|
|
|
XmlSerializer^ serializer = gcnew XmlSerializer(typeid);
stream = gcnew FileStream(filePath, FileMode::Open, FileAccess::Read, FileShare::ReadWrite);
try
{
Object^ temp = serializer->Deserialize(stream);
A first chance exception of type 'System.Runtime.InteropServices.SEHException' occurred in tcs077j2
Additional information: External component has thrown an exception.
Please advice.. Thanks
|
|
|
|
|
As a suggestion you should create a test app that does a very simple deserialization.
Then run with Purify.
If it still crashes then it would suggest that there is a bug in Purify.
If it doesn't then add attributes one at a time into the test object, testing each one, to bring it up to match the object that causes the crash in your app.
If you replicate the full object without a crash then if it was me I would suspect some bug elsewhere in your code, specifically unmanaged code. Bugs in unmanaged code can cause failures long after the actual code ran.
|
|
|
|
|
Usering a Test App I was able to deserialize complete XML file. But Can you please suggest the tips to find the issue.
When I run without purify every thing is fine
But when I rung with purify the issue comes. May be purify is sensiable enough to catch the issue, but I want to find the exact location of the issue. Please advice
thanks in advance
|
|
|
|
|
ptr_Electron wrote: Usering a Test App I was able to deserialize complete XML file.
Presumably you mean with Purify running.
If so then as I suggested I would then suspect and first look to any unmanaged code in the application. If you do not have unmanaged code (nor 3rd party libraries that use it) then obviously that is not a problem.
If you don't know if you have any then I can't help you with that. And if you have it but don't know how to find the problem then the only sure way is via inspection. However streneous testing can help.
|
|
|
|
|
Yes, correct.. running the test application with purify with the same xml file is very well running fine.
But when I run my application with purify with the same xml file then it crashes at Deserialize method.
So the Unmanaged code before calling the Deserialize method should have some issue. I have that unmanaged code
So I believe this should be mostly some kind of memory overwrite issue ?
Do you think windgb or App verifier should give some clue.
Thanks for your time
|
|
|
|
|
ptr_Electron wrote: So I believe this should be mostly some kind of memory overwrite issue ?
It is a 'pointer' problem. There are many ways in which a pointer can be misused.
An overwrite is one way. An underwrite is another. A miscast is another. Misusing sizes is another. Etc.
There are C++ (straight C++ apps, not managed) tools which exist to determine in problems C++ code. It requires that one excercise the code very well.
Inspection is probably still the only sure option - at least as sure as it can be.
|
|
|
|