|
Thanks (again) for your fast reply. I HAVE ordered that book you sugested but it is yet to arrive. So, I'm still very ignorant. I read:
Foo^fooPtr = gcnew Foo()
as
poiter-to-thing-called-Foo named-fooPtr = new Foo()
and relating to a new instance of Foo() referenced by a pointer instead of a name. I don't want a new Foo(). I want a pointer to the Foo() that was instanced previously elsewhere. Have I completely misunderstood the syntax?
Regards
Ron
|
|
|
|
|
regnwald wrote: I don't want a new Foo(). I want a pointer to the Foo() that was instanced previously elsewhere.
Strange! So where are you keeping that pointer? If you could explain what you are trying to achieve, I think there will be better solution.
|
|
|
|
|
"Strange"? Oh dear, I must be way off.
Early in the project I instanced a type:
cdVersionInfo cdVI;
I first cleared it with:
memset(&cdVI,0,sizeof(cdVersionInfo));
After including "memory.h" this gave no errors.
memset() accepts &cdVI but VC++ 2005 does not. Yet I need a pointer to cdVI for a function RCStartSDK in a .dll. Using &cdVI in memset and my project compiles with no errors (I must check data in cdVI tonight) but using &cdVI in calling RCStartSDK gives a compiler error that using & is an anachronism.
The memset line comes from a VC++6 example of how to use the SDK. Imported and converted for VC+++2005 does not alter either code using of &cdVI and the exaple still works with both. But the same code in my project does not work. Even including the example's H file into my project does not help.
If I was at "AT HOME" I would say cdVIptr=VarPtr(cdVI). I have a (slightly) horrid feeling I need to change the first instance f cdVI to your suggestion. I still need to be able to clear the type and cdVIptr has to be global and I assume I set values:
cdVIptr^.SIZE = sizeof(cdVersionInfo);
or
cdVIptr*.SIZE = sizeof(cdVersionInfo);
depending on circumstances.
Am I struggling in the right direction or am I unable to see the jungle for the vines?
One day perhaps...
But its really hard going back to school at 72. I speak a litthe Italian, French and German, but the dialects always confuse.
Regards
Ron
|
|
|
|
|
hi guys,
I have a program that connect to mysql database in a remote location(speedhosting.co.cc). but when ever i execute the program it shows error.
connection state : driver closed undefined value data reader = undefined value
I am using VC++ .net to for this program and (using namespace MySql::Data::MySqlClient)
Kindly help me plz. Thank you.
Regards,
Thilek
|
|
|
|
|
How are you trying to connect I assume you are using the mysql data provider for .net if so what is you connections string sans the username and password
a programmer traped in a thugs body
|
|
|
|
|
Thanks for looking at my question,
I am wondering how I would use the ToUpper and ToLower functions on only part of a string in .net C++.
For example, I converted an inputted name to all caps for the purpose of comparing it. Now I need to display the name with only the first letter capitalized.
In short, I need to make "BRAD" to "Brad"
Note that the inputted name is not always the same, so however you can show me how to do this has to work with any inputted name.
Thanks for any help!!
|
|
|
|
|
TabascoSauce wrote: with only the first letter capitalized.
Sentence case? You can write code using SubString(), ToUpper() and ToLower(). Here it is.
String^ ConvertToSentenceCase(String^ input)
{
return (input->Length > 0) ? String::Concat(input->Substring(0,1)->ToUpper(),input->Substring(1)->ToLower())
: String::Empty;
} Other methid is to use TextInfo class and work with ToTitleCase method. Here it is
String^ ConvertToSentenceCase(String^ input)
{
using namespace System::Threading;
return Thread::CurrentThread->CurrentCulture->TextInfo->ToTitleCase(input);
} Hope that helps
|
|
|
|
|
Hey thanks for the help!
Sadly I am still having issues, after I tried to build it the build log gives me the error:
"1>.\TempConverter.cpp(37) : error C2440: 'return' : cannot convert from 'System::String ^' to 'int'
1> No user-defined-conversion operator available, or
1> There is no context in which this conversion is possible
Here's the block of code I have your second suggestion in (yes I am very, very new to programming, I'm trying to overachieve on an assignment in my online class):
if (name->CompareTo("ALPHA" || "BETA" || "GAMMA") != 0)
{
Console::WriteLine("Sorry, you have insufficient rights to access to this program");
Console::Write("Please enter 1 to end the program: ");
endProgram = Convert::ToInt16(Console::ReadLine());
}
else
{
if (name->CompareTo("ALPHA" || "BETA" || "GAMMA") == 0)
{
using namespace System::Threading;
return Thread::CurrentThread->CurrentCulture->TextInfo->ToTitleCase(name);
Console::WriteLine("Hello ", initial->ToUpper() , ". ", name);
Console::Write("Are you converting from celsius or fahrenheit?: ");
tempr = Convert::ToString(Console::ReadLine()->ToLower());
}
I'm trying to get it to write something like "Hello M. Beta"
Feel free to point anything else I've done wrong (to an expert this probably looks horrible).
Again thanks for your time and anymore help you can give me!
modified on Sunday, February 15, 2009 6:31 PM
|
|
|
|
|
Aah, you copied my code to a wrong place. Try this
String^ ConvertToSentenceCase(String^ input)
{
using namespace System::Threading;
return Thread::CurrentThread->CurrentCulture->TextInfo->ToTitleCase(input);
}
if (name->CompareTo("ALPHA" || "BETA" || "GAMMA") == 0)
{
using namespace System::Threading;
name = ConvertToSentenceCase(name);
Console::WriteLine("Hello ", initial->ToUpper() , ". ", name);
}
|
|
|
|
|
Ahhh, Ok I understand now.
Thanks for the help! After I busted through like 100 other errors I had in my program I finally got it to work.
You're a lifesaver, have a good day!
|
|
|
|
|
Hello All
I have two USB audio devices attached to the system. Using API's "SetupDiEnumDeviceInterfaces" and "SetupDiGetDeviceInterfaceDetail" I am able to figure out their unique device paths which is in this format
"\\?\hid#vid&pid&col02#7&1bca1430e&0&0001#{some id}"
"\\?\hid#vid&pid&col02#7&3db23aebe&0&0001#{some id}"
Also on using the API "waveInGetDevCaps" I am able to find out the unique strings the system is using to identify this device which are "USB Headset" and "USB Headset (2)", my question is how can i know from my application which "USB Headset" is linked to the which of the above mentioned path. Or is there a way to map the audio devices listed in “Sound and Audio Devices” settings with the actual hardware programmatically.
Any input is greatly appreciated.
OS (2000, XP, Vista), VS2005 ( VC++ IJW )
Thanks
gsm
|
|
|
|
|
I have a nested managed class and I would like to expose the properties of the nested class to C# and VB. How do I do this?
In the following C++ managed class, I can see all of the properties of FitnessUserProfile in VB. I can see the Activity class within the FitnessUserProfile object in VB but I can't see any FitnessUserProfile.Activity properties.
What am I doing wrong?
I am using Visual Studio 2005.
namespace GarXface<br />
{<br />
<br />
<br />
public ref class FitnessUserProfile : public ICloneable<br />
{<br />
<br />
public:<br />
<br />
property unsigned BirthDay<br />
{<br />
void set(unsigned day)<br />
{<br />
m_pProfile->SetBirthDay(day);<br />
}<br />
<br />
unsigned get()<br />
{<br />
return m_pProfile->GetBirthDay();<br />
}<br />
}<br />
<br />
<br />
ref class Activity : public ICloneable {<br />
internal:<br />
<br />
Activity(void);<br />
<br />
public:<br />
<br />
property float MaxHeartRate<br />
{<br />
void set(float heartRate)<br />
{<br />
<br />
}<br />
<br />
float get()<br />
{<br />
<br />
}<br />
<br />
} <br />
<br />
<br />
<br />
<br />
<br />
|
|
|
|
|
stempsoft wrote: ref class Activity
Make the nested class public. So it can be accessed by FitnessUserProfile::Activity . BTW, why are you exposing nested class?
|
|
|
|
|
Thanks but I have it working now. Not sure what I was doing wrong before.
And why wouldn't I expose a nested class? Activity is only useful within FitnessUserProfile.
Oh and you advice was wrong it generates an error:
Help file says the following:
When applied to a managed type, such as class or struct, the public and private keywords indicate whether the class will be exposed through assembly metadata. public or private cannot be applied to a nested class, which will inherit the assembly access of the enclosing class.
When used with /clr, the ref and value keywords indicate that a class is managed (see Classes and Structs (Managed)).
|
|
|
|
|
stempsoft wrote: Oh and you advice was wrong it generates an error:
Then you are doing it incorrectly. See the following code which will execute without any errors. It show how a method declared in nested class is accessed from outside.
public ref class Outer
{
public:
ref class Inner
{
public:
void SayHello()
{
Console::WriteLine("Hi from inner");
}
};
}; You use it like
Outer::Inner^ inner = gcnew Outer::Inner();
inner->SayHello(); Does that help?
|
|
|
|
|
i am developing a application which has got a admin module and a user module, admin module will be running on only one machine, but the user modules will be running on multiple systems. i have got some settings to be done in admin module and the same settings should be used by user module also, how to get the settings in the user module from the admin machine. whenever any settings are changed in admin module all the user modules should get the new settings.
Naveen
|
|
|
|
|
naveen_bij wrote: which is the best method to send data to clients, without a request from client
If the clients are not going to make a request then they have to listen or poll for the data. It's not the best method, it's the only method left after you eliminate requesting data. Essentially there is little difference between the two.
|
|
|
|
|
thanks for your response.
so i have to write a listener event in my application. Currently i don't know how to do it, but will try to do that and if any problems will get back for your help
Naveen
|
|
|
|
|
Hi,
I wouldn't try and push the data from server to client; just have one of these:
- have the client ask whether new admin data is available at the start of a new session;
- or have the server respond with a specific error code rather than real data whenever it feels the
client should get new admin data first.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
thank you sir,
i thought of using UDP multicasting, where all the clients join a group and server sends a datagram to that group. so i will send a error code to the group stating that new settings are available, when the user modules receive this message they have to complete and stop all the other processes and get the new settings, because the settings are used in other processes.
can u please guide me how to do it in a better way
Naveen
|
|
|
|
|
Hi,
there are some problems with multicast:
- the sender does not know how many listeners there are
- the sender does not expect a response
- the receivers have no way to respond, to inform things went well, or wrong...
- the receivers may have missed it (being off, or just not listening); if so, no one notices.
So if it is essential that your clients immediately switch over to the new settings, I don't think multicasts are an option. I suggest you close the existing connections (maybe by returning an error on all requests other than CONNECT) and tell the clients that try and
(re)connect that new settings are available.
An easy way to manage versions/settings/... is by adding one byte to every message sent by clients, I would call it the generation number. The server would then refuse all requests with a bad generation number except "give me valid settings", and return an error saying "bad generation"; the client would then close the connection, ask for the latest settings (which works outside a session, and no matter what the generation number is), then
start a new session. And of course every time the server has new settings it simply increments the generation number.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
why do you eliminate the requesting from client?
what about setting a listening thread on the client which gathering the update command from the admin module?
I am developing a application ,i use this way.
|
|
|
|
|
i am eliminating the request from client because the settings changed on the server should be updated immediately to all the clients.
can you please guide me how to write a listening thread, it would be very helpful and how to send the update command to all the clients.
in my application clients are independently running they they take only the settings from server and nothing else. we thought of doing this because server downloads the new settings from another host and then will distribute the settings locally on LAN.
Naveen
|
|
|
|
|
in client modual,I start a thread by createthread(),
in the thread fuction,i use blocked socket api,accept(). and make the thread always runing by while(1).
like below:
while(1)
{
....
accept(); //thread will be blocked here ,i think it's efficient,no more
// cpu time
....
}
in the admin modual, when you want to send changes,using the connect()and send().
do I make myself clear for you?
if not ,I sorry. because english is not my mother language.
if any question more ,we can discuss more.
|
|
|
|
|
thank you for your precious time
it means all my user modules should be connected to admin module and wait in an infinite loop.
what method shall i use to connect to the admin module.
i think my list of questions is growing. since i have recently started working on .net, i dont know much about .net
Naveen
|
|
|
|