|
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);
|
|
|
|
|
Sumanta Rout wrote: 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 *
You need to box the integer:
myCmd->Parameters->Item[1]->Value= __box(i);
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
We have a large MFC program that uses ODBC to connect to SQL Server, Oracle and My SQL databases. To make the connection we have a database management layer that uses the SQLConnect function in sql.h from the ODBC API.
I am starting to compile some of the DLLS using /CLR so that I can program in C++/CLI and use some of the .NET classes like OdbcDataAdapter so that I can use the DataGrid.
Is there any way that I can use my existing SQLHANDLE or should I create a second connection to the database by creating a .NET OdbcConnection?
-Tim
|
|
|
|
|
Hi,
I would like to know if there's a way to determine if a DLL is a managed class library or not, *without* loading it.
I don't want to use code like the one below to load the assembly, I just want to check it's type.
bool IsManagedDLL(String ^ fn)
{
try {Assembly::LoadFile(fn);}
catch(...) {return false;}
return true;
} Is there any way to do it?
|
|
|
|
|
http://geekswithblogs.net/rupreet/archive/2005/11/02/58873.aspx
|
|
|
|
|
Thanks alot, i'ts just what i was looking for
|
|
|
|
|
You are welcome
|
|
|
|
|
Hi,
I have taken a Dialog based Application. Upon some button Click I have some functionality to be done like creating a directory with Security attributes of a given user. Once I build this I got an Executable File which I Invoke from another Dialog based Application in Managed C++.
I invoked this executable (or process) by giving permmisions for an user say MyUser.
Process::Start(exepath,path ,username,strSecurePwd,domain);
So whatever is done in the executable file is being done by the MyUser.
Now, what I want is I have to Place all my functions in an
Executable File (or Seperate process) which should not have GUI.
Once I Invoke this Process all the functions in that should execute.
So, what sort of application I need to take for this to happen?
Any Suggestions or an approach to proceed would be helpful.
Thanks In Advance.
Today is a gift, that's why it is called the present.
|
|
|
|
|
Make a program that starts minimized and doesn't show in taskbar
|
|
|
|
|
//
int x=0, y=1, z=2;
printf("%d\n", --x&&--y||--z);
printf("%d, %d, %d\n", x, y, z);
//produces an output of
// 1
// -1, 0, 1
//then
int x=0, y=1, z=2;
printf("%d\n", -- |--y&&--z); //<--------- here!!!
printf("%d, %d, %d\n", x, y, z);
//produces an output of
// 1
// -1, 1, 2
//whats the difference?
//arielpirante@yahoo.com
|
|
|
|
|
This is a forum for "managed" C++ questions. Your posts do not appear to be about managed C++ issues. You should use the "Visual C++ / MFC" forum. It is the closest thing to a plain C++ forum that we have.
It appears you are a student in a CIS course. Make sure your read the material provided as many times as it may take to understand it. This is the essence of the problem you face.
|
|
|
|
|
how would i know if a series of binary number is negative?????
|
|
|
|
|
cOOLcOmbo wrote: how would i know if a series of binary number is negative?????
When is a number not a binary number?
|
|
|
|
|
and how do you define negative on those "binary number"s?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
//this code (c++)
int x=0, y=1, z=2;
printf("%d\n", --x&&--y||--z);
printf("%d, %d, %d\n", x, y, z);
//produces an output of
// 1
// -1, 0, 1
//which is logicaly correct
//then i changed it into
int x=0, y=1, z=2;
printf("%d\n", -- |--y&&--z); //<--------- here!!!
printf("%d, %d, %d\n", x, y, z);
//produces an output of
// 1
// -1, 1, 2
//WHY????????????
|
|
|
|
|
Since you have the OR (||) once a true ccondition is found the rest is not evaluated. So when --x is calculated to be -1 it is no zero and a true condition so the right side of the or does not need to be done.
|
|
|
|