|
that thread listens for messages so WM_DESTROY should terminate thread process...
|
|
|
|
|
|
Please don't spam the forum with posts like this. If you don't have a clue, you should just for once try to _not_ post a reply to a question. In this case, the parameters are perfectly legal, and has absolutly nothing to do with his problem. The only thing this kind of reply is doing is to make the question look answered, and it will not show up when clicking the 'unanswered questions' link above. Thus, instead of helping, these kind of posts actually reduces the chance of getting an answere to a question. If this was just a one-timer, I wouldn't be bothered, but you do this over and over again.
|
|
|
|
|
How would one declare a function pointer and initialize an array of those pointers to different constructors. I'm declaring an array of structures like the following
typedef struct tagExtractOps
{
CString strExtractName;
int nCtorCount;
CTOR* pConstructors[];
} ExtractOps;
const int NUMBER_OF_OPS = 3;
ExtractOps[NUMBER_OF_OPS] = {"OP_1",2,{ctorA,ctorB},"OP_2",3,{ctorA,ctorC,ctorD},"OP_3",1,{ctorE}};
for ( int i = 0; i < NUMBER_OF_OPS; i++ )
{
for ( int j = 0; j < ExtractOps[i].nCtorCount; j++ )
{
Parent* pExtract = (Parent*) new Extractops[i].pConstructors[j];
if ( pExtract )
{
.... do a bunch of operations on pExtract
delete pExtract;
}
}
} In this example, all of the classes inherit from class Parent and all the operation I call are either defined in the parent or are virtual functions.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
The only way I can think of doing it, is using an factory of some sort
[edit] Re-written into something that actually compiles! [/edit]
enum EClasses
{
EClassA=0,
EClassB,
EClassC,
EClassD,
EClassE,
};
Parent* CreateObject( EClasses type )
{
Parent* pObj = NULL;
switch( type )
{
case EClassA:
pObj= new CClassA();
break;
case EClassB:
pObj= new CClassB();
break;
..etc..
}
return pObj;
}
const int MAX_CLASSES = 10;
typedef struct tagExtractOps
{
std::string strExtractName;
int nCtorCount;
EClasses pClasses[MAX_CLASSES];
} TExtractOps;
const int NUMBER_OF_OPS = 3;
TExtractOps ExtractOps[NUMBER_OF_OPS] = {"OP_1",2,{EClassA,EClassB},"OP_2",3,{EClassA,EClassC,EClassD},"OP_3",1,{EClassE}};
for ( int i = 0; i < NUMBER_OF_OPS; i++ )
{
for ( int j = 0; j < ExtractOps[i].nCtorCount; j++ )
{
Parent* pExtract = CreateObject( ExtractOps[i].pClasses[j] );
if ( pExtract )
{
delete pExtract;
}
}
}
-- modified at 9:58 Wednesday 1st November, 2006
|
|
|
|
|
Thanks. I'll give some thought to a class factory. Ultimately I'm trying to avoid coding some gigantic switch statment that just implements the assignment and 'new' operations. I trying to figure out a way to just code that line once.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
A colleague of mine is a big fan of using complex define systems
something like:
ClassDefinitions.h
DECLARE_CLASS( ClassA )
DECLARE_CLASS( ClassB )
DECLARE_CLASS( ClassC )
enum EClasses
{
#define DECLARE_CLASS( unique_class_name ) E##unique_class_name,
#include "ClassDefinitions.h"
#undef DECLARE_CLASS
}
Parent* CreateObject( EClasses type )
{
Parent* pObj = NULL;
switch( type )
{
#define DECLARE_CLASS( unique_class_name ) \
case E##unique_class_name: \
pObj= new C##unique_class_name(); \
break;
#include "ClassDefinitions.h"
#undef DECLARE_CLASS
}
return pObj;
}
This means you don't need to manually update the enum and factory, you just have to update the single header file. However, it makes code that is much harder to read and understand, so there's a tradeoff there
|
|
|
|
|
Hi, I stuck with gethostbyaddr() function. When I try this function with IP add = 127.0.0.1 it gives me “WSANO_DATA (11004)” error. Now when I am using gethostbyname() function with name = localhost. It is working perfectly can I know what is the problem with this. Thanks in advance.
Priaynk
This is working
LPHOSTENT hostEntry;
hostEntry = gethostbyname("localhost");
This is not working
char* ipadd = "127.0.0.1";
LPHOSTENT hostEntry1;
hostEntry1 = gethostbyaddr(ipadd,4,AF_INET);
|
|
|
|
|
priyank_ldce wrote: hostEntry1 = gethostbyaddr(ipadd,4,AF_INET);
The first argument to gethostbyaddr() must be in network byte order (instead of host byte order). Use inet_addr() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: The first argument to gethostbyaddr() must be in network byte order (instead of host byte order). Use inet_addr().
Thanks for the reply. But inet_addr() function returns unsigned long value of IP address while the first parameter of gethostbyaddr() should be const char*. Can I know how can I use it in gethostbyaddr() function. I am new in C++ programming.
|
|
|
|
|
priyank_ldce wrote: Can I know how can I use it in gethostbyaddr() function.
ULONG ulAddress = inet_addr("127.0.0.1");
if (ulAddress != INADDR_NONE)
pHostInfo = gethostbyaddr((char *) &ulAddress , sizeof(ulAddress), AF_INET);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for your help. it works.
|
|
|
|
|
For the life of me i cannot seem to be able to detect and produce a list of video capture devices connected to a computer. I am using directshow and i need to populate a combobox(IDC_COMBO1) in a dialog(IDD_PROPERTYDIALOG) with the device names.
Any help?
|
|
|
|
|
How are you detecting and producing the list? Filling the combo box should be the easy part
Are you having trouble getting the list or populating the combo box?
Are you using code like this to get the device list - Selecting a Capture Device[^]?
|
|
|
|
|
Ive sorted to problem now thanks for your help though
|
|
|
|
|
Hi.
Some years ago I wrote an ActiveX Control, (MFC), just a 3 state button. Now I want to add some new stuff to this old control, but I want to keep safe the old project, so I though to copy the project to a new folder and use that copy for the new project. But how could I change the name of the project to get a new activex control???.
The name of the old project is: "FlashButton" now I want to rename the copy of that project to "FlashButton2007" and add the new stuff here.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Hi
Ther's a tool right here on CP. Fairly simple, it's just a string search and replace job. It's called vsrename.exe and it comes from an article titled "The Code Project - Visual Studio Project Renamer - Free Tools.htm"
Tom
PS make sure you back up your project fist though, as I said it is pretty simple.
|
|
|
|
|
Hi ...
Please tell me how to access the performance objects from perfmon. I am new to this.
I came to know that we can access the objects from the Provider classes. But please tell me how to access a single object i.e Pool NonPagedBytes.
Thanks in advance.
Suresh
SUresh
|
|
|
|
|
suresh_suryavanshi wrote: Please tell me how to access the performance objects from perfmon.
There are a few examples at the bottom (comments section) of this article.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi DavidCrow,
I saw the example. But i am newbie for this. If possible give me the exact steps and which functions to use. i gone through the msdn library... now i am totally confused.
I want to access the PoolNonPagedBytes of Win32_PerfFormattedData_PerfProc_Process for only one process. Please suggest me the steps.
I am very greatful if u help me out to sort this problem.
Thanks in Advance.
Regards,
Suresh
|
|
|
|
|
suresh_suryavanshi wrote: If possible give me the exact steps and which functions to use.
I provided you with actual code. Short of hand-delivering it to you, what more do you want?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hey there,
I would like to disable paint-updates to my tree control while i fill it with data using MFC, but cant
find the api to use.. can anybody help?
|
|
|
|
|
Have you tried using LockWindowUpdate() and UnlockWindowUpdate().
|
|
|
|
|
flippydeflippydebop wrote: I would like to disable paint-updates to my tree control while i fill it with data using MFC, but cant
find the api to use.. can anybody help?
To switch off painting call SetRedraw( FALSE ) . To turn painting on again SetRedraw( TRUE ).
|
|
|
|
|
cheers guys... I have just used lockWindowUpdate/UnlockWindowUpdate which works a treat..
thanks for your prompt replies...
|
|
|
|