|
<br />
textBox->Text = gcnew String(szData);<br />
Yeah, This way I realy like. Can you introduce more about this. How can you find out this way?
Do you have any tips for this kind?
Sorry, my English very bad.
|
|
|
|
|
Well it's quite simple:
You can create String objects with passing char* to the String constructor.
'Text' is something like pointer. gcnew is something like new in c++ but a little bit smarter. So all we have to do is just create new String^ object with szData as value instead of "" ( String is initialized with "" string normally ).
|
|
|
|
|
Hi,
I am compiling old C++ code in visual studio 2005. I am Getting the error as fatal error LNK1104: cannot open file 'libc.lib' ASMUtils
libc.lib
I found this library is not avialable in VC8. I copied this library from VC7 but still I am getting many other errors.
Even I tried to ignore it by putting Linker-Input-Ignore Specific Libary, but I could not able to fix this bug
Need some urgent help.
Thanks in advance
|
|
|
|
|
This is my code below: It gets the computer name and then the associated IP along with it. If we have the IP address how can we get the computer name? Thanks
void AsyncServer::InitSocks()
{
String* server = "CATUXPSD01";
int port = 4901;
printf("in InitSocks");
String* request = String::Concat(S"Our test data asdf");
Byte bytesSent[] = Encoding::ASCII->GetBytes(request);
Byte bytesReceived[] = new Byte[256];
Socket* s = 0;
IPHostEntry* hostEntry = 0;
// Get host related information.
hostEntry = Dns::Resolve(server);
//hostEntry = new IPHostEntry();
// Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
// an exception that occurs when the host IP Address is not compatible with the address family
// (typical in the IPv6 case).
IEnumerator* myEnum = hostEntry->AddressList->GetEnumerator();
while (myEnum->MoveNext())
{
IPAddress* address = __try_cast<ipaddress*>(myEnum->Current);
IPEndPoint* endPoint = new IPEndPoint(address, port);
Socket* tmpS = new Socket(endPoint->AddressFamily, SocketType::Stream, ProtocolType::Tcp);
try {
tmpS->Connect(endPoint);
}
catch(Exception *e) {
// Handle exception here
}
if (tmpS->Connected)
{
s = tmpS;
break;
}
}
// Create a socket connection with the specified server and port.
if (s == 0) {
printf("Connection failed");
} else {
// Send request to the server.
s->Send(bytesSent, bytesSent->Length, static_cast<socketflags>(0));
}
}
|
|
|
|
|
staticplus wrote: If we have the IP address how can we get the computer name?
They hide that information in the documentation[^]
and again[^]
|
|
|
|
|
Inside <<inside c++="" object="" models="">>, it wrote
"It is stll a bad design choice to declare all functions virutal and to depend on the compiler to optimize away unnecessary virtual invocations."
I can't understand it very well.
|
|
|
|
|
This is the wrong forum, your queston has nothing to do with .NET. Try the Visual c++ forum.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. I probably wont be posting as much now that I have Stephen R.G. Fraser's book "Pro Visual C++/CLI and the .NET 2.0 Platform" which, I can tell, is going to be an invaluable resource. I wanted to use the ErrorProvider component to provide validation error messages, but when I use errorProvider->SetError(control_name, "This is an error"); I get the blinking error icon by the control but the error message is not displayed. Does anyone know why this is? The usage seems to be straight forward enough.
Thanks
Buck
|
|
|
|
|
Hi, try and move the cursor over the blinking ErrorProvider...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Duh. Thanks, it was right there in front of me but I glossed over it.
Buck
|
|
|
|
|
I am looking for some examples or advice of really good data parsers. I am using a windows application and pulling data in via RS-232 ports. The data is typically one byte at a time and is complete data. It will have a header, a command, data, checksum, etc. I am looking for some smart parsers. I have some parsers that work, but I would like to make them more full proof.
Does anyone have any advice of ways to make sure it stays smart or places to find examples of parsers? For example, I had a parser that pulled two bytes of data in at a time. It worked well except for if the system was turned on at an odd byte. If the header was supposed to be in the higher byte, but was now in the lower byte, I had an issue. This problem has been fixed, but I want to see what other people have come across. Thanks for the help.
|
|
|
|
|
epsilonorion wrote:
I am looking for some examples or advice of really good data parsers.
Google Lex Parser
Also many if not most parsing implementations use a finite state machine design.
Also this forum is for C++ managed development. See the first post in the forum. If you are not developing on the .NET platform then your question should go into the Visual C++ / MFC forum
|
|
|
|
|
Hi,
I am converting VC++6, MFC application to MC++. While compiling the code I am getting error as
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
The above error is due to the following lines of code
operator ++ (void);
operator -- (void );
operator + (int inAmount );
operator - (int inAmount );
operator += (int inAmount );
operator -= (int inAmount );
void operator = (QWORD theMicorseconds );
Now I have set the compiler option as /wd 4403 then 147 other errors are appered. Some are as follows
error C4867: 'TWindow::WMDestroy': function call missing argument list; use '&TWindow::WMDestroy' to create a pointer to member
error C4867: 'TWindow::WMPaint': function call missing argument list; use '&TWindow::WMPaint' to create a pointer to member
error C4867: 'TWindow::WMCommand': function call missing argument list; use '&TWindow::WMCommand' error C4867: 'TWindow::WMNotify': function call missing argument list; use '&TWindow::WMNotify' to create a pointer to member
error C4867: 'TWindow::WMSysChar': function call missing argument list; use '&TWindow::WMSysChar' to create a pointer to member
error C4867: 'TWindow::WMQueryNewPalette': function call missing argument list; use '&TWindow::WMQueryNewPalette' to create a pointer to member
error C4867: 'TWindow::WMPaletteChanged': function call missing argument list; use '&TWindow::WMPaletteChanged' to create a pointer to member
Please Help me out. Thanks in advance
|
|
|
|
|
Disabling warnings isn't going to do anything but hide your problems.
There's no TWindow class I know of in the Microsoft class libraries.
That looks like Borland OWL classes to me. You may have a tough time
compiling that on Visual C++.
You need to go through warnings and errors and fix the problem.
For example, "error C4430: missing type specifier" indicates that the compiler
doesn't recognize a type on tha line.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How do I communicate between two windows forms in the same application? I have a main form that uses "showDialog()" to create the second form in which i type some information. Upon clicking on the "Ok" button of the second form, i need to pass the information i typed to the main form.
I'm new to Managed C++ and a bit noob which C++, so, please, be patient...
I've tried to put a "System::Windows::Forms::Form^ form" as an argument in the constructor of the second form and then, when it was initialized in the main form, I used a "this" to pass the argument.. but it didn't work.
Code in the 2nd form:
SecondForm(System::Windows::Forms::Form^ form) {
}
Code in the 1st form:
SecondForm form2 = gcnew SecondForm(this)
form2->showDialog();
(i intended to pass information by using something like form->function(args)).
I've read something about using delegates, but the article was oriented for c#..
Can anyone help me, plz? Thanks
|
|
|
|
|
Hi,
when there is a clear master-slave relationship between two forms (e.g. one Form
showing a second as a modal dialog), then I would suggest the dialog is extended with
some public getter/setter methods so the calling form can initialize it (with the setters) and
interrogate its state (with the getters). No delegate functionality is required here.
[added]Properties are very good at getting/setting things[/added]
-- modified at 9:19 Wednesday 24th October, 2007
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: then I would suggest the dialog is extended with
some public getter/setter methods
Really? That's how Object Oriented Design works? Interesting[^].
|
|
|
|
|
Hi,
I am converting VC++6, MFC application to MC++. While compiling the code I am getting error as
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
The above error is due to the following lines of code
operator ++ (void);
operator -- (void );
operator + (int inAmount );
operator - (int inAmount );
operator += (int inAmount );
operator -= (int inAmount );
void operator = (QWORD theMicorseconds );
Please Help me out. Thanks in advance
|
|
|
|
|
I create an abstract class and a class derived from it. I know that an abstract class's object cannot be created until all its pure virtual functions are redefined within their derived class. However, How about the constructor and destructor functions? As they are special class functions, they can not be redefined within their derived class.
class Abstract_base {
public:
virtual ~Abstract_base()=0;
virtual void interface1() const = 0;
virtual const char* mumber() const
{
return _mumble;
};
protected:
char *_mumble;
};
class Concrete_derived : public Abstract_base {
public:
Concrete_derived()
{
};
virtual void interface1() const {};
};
int main
{
Concrete_derived trouble;
return 0;
}
The code above has link eror.(error LNK2019)
If I change "virtual ~Abstract_base()=0;" to "virtual ~Abstract_base()=0; {}", the link error disappeared. Why shall we add "virtual" to the destructor function?
Can you give me some explanation?
My thanks
|
|
|
|
|
I suggest asking in the right forum ( visual C++ is for non-.NET C++ )
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
I have thought that question for visual C++ might be something like MFC ,not pure C++ questions.
Thank you for your suggestion.
I will ask the same question in Visual C++ forum.
Tommorow is another day
|
|
|
|
|
Unhandled Exception: System.Net.Sockets.SocketException: No connection could be
made because the target machine actively refused it
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at AsyncServer.InitSocks()
i get this message after compilation of the code in the console window.
//This is my code which is probably causing the error:
void AsyncServer::InitSocks()
{
String* server = "CATUXPSD01";
int port = 4901;
printf("in InitSocks");
String* request = String::Concat(S"Our test data asdf");
Byte bytesSent[] = Encoding::ASCII->GetBytes(request);
Byte bytesReceived[] = new Byte[256];
Socket* s = 0;
IPHostEntry* hostEntry = 0;
// Get host related information.
hostEntry = Dns::Resolve(server);
// Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
// an exception that occurs when the host IP Address is not compatible with the address family
// (typical in the IPv6 case).
IEnumerator* myEnum = hostEntry->AddressList->GetEnumerator();
while (myEnum->MoveNext())
{
IPAddress* address = __try_cast(myEnum->Current);
IPEndPoint* endPoint = new IPEndPoint(address, port);
Socket* tmpS = new Socket(endPoint->AddressFamily, SocketType::Stream, ProtocolType::Tcp);
tmpS->Connect(endPoint);
if (tmpS->Connected)
{
s = tmpS;
break;
}
}
// Create a socket connection with the specified server and port.
if (s == 0) {
printf("Connection failed");
} else {
// Send request to the server.
s->Send(bytesSent, bytesSent->Length, static_cast(0));
}
}
So a socket is being created so I can send data. My problem is that when there is nothing listening on the port I don't want the program to generate the error, I want to trap the error and do something with it. Thanks
|
|
|
|
|
In the documentation for the Socket class, I see five types
of exceptions that can be thrown by Socket::Connect().
As always, it's up to you to handle the exception(s) if you don't
want your app to "crash".
You need to wrap code that can throw exceptions in try/catch[/finally] blocks.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi,
I am facing error in the following code. Thanks in Advance. Please suggest
The error occours at this point
: myCmd->Parameters->Item[1]->Value=i; //int i=106
error C2664: 'Microsoft::Data::Odbc::OdbcParameter::set_Value' : cannot convert parameter 1
from 'int' to 'System::Object __gc *
Code:
OdbcConnection *myCon = new OdbcConnection("Driver={Sql Server};server=SUMANTAR;trusted_connection=yes;database=PacketQueue;");
try
{
int i=106;
myCon->Open();
OdbcCommand *myCmd = new OdbcCommand("{?=call MultiParamSP(?,?)}",myCon);
myCmd->Parameters->Add("RetVal",OdbcType::Int);
myCmd->Parameters->Item[0]->Direction=ParameterDirection::ReturnValue;
myCmd->Parameters->Add("QueueID",OdbcType::Int);
myCmd->Parameters->Item[1]->Value=i;
myCmd->Parameters->Add("IDCRC",OdbcType::Int);
myCmd->Parameters->Item[2]->Direction=ParameterDirection::Output;
OdbcDataReader *myReader = myCmd->ExecuteReader();
while (myReader->Read())
{
Console::WriteLine();
for(Int32 i=0;iFieldCount;i++)
{
Console::WriteLine("{0}:{1}",(myReader->GetName(i))->ToString(),(myReader->GetValue(i))->ToString());
}
}
myReader->Close();
Console::WriteLine();
Console::WriteLine("OutputParamVal={0};ReturnVal={1}",myCmd->Parameters->Item[2]->Value,myCmd->Parameters->Item[0]->Value);
|
|
|
|