|
Hi to you all,
In a Dialog, I use an Edit element to enter a key value for new objects. I use the same dialog somewhere else to select one of the objects and I then replace this CEdit element with a CComboBox from which the value can be selected. I would likt to use the same CString variable. In the current version, this CString is connected to the CEdit object in the DoDataExchange by a DDX_Text(pDX,.....). I would likt (in the OnInitDialog routine) to disconnect this CString from the CEdit element, and reconnect it (with a new DDX_Text probably) to the CComboBox element. Is there a way in which one can disconnect the data exchange? Or should I take the DDX_Text for this element out of DoDataExchange and put it in OnInitDialog altogether?
Anyone have any suggestions?
Thanks in advance
William
|
|
|
|
|
Wim Engberts wrote: ...this CString is connected to the CEdit object...
Use a CEdit member variable instead. For the combobox control, use a CComboBox member variable.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
David,
This is indeed what I do, however, I would like both controls to do their data exchange with the same CString variable, since I always show only one of the two (either the CEdit or the CComboBox), depending on the mode that I have selected for the dialog.
I am now experimenting with a double DDX_Text in the DoDataExchange routine (referring both controls to the same CString). This compiles fine and it also seems to work properly. However, when starting the classwizard, I get an error. So far I have been able to go around this by putting the second DDX_Text outside of Microsoft's automatic data map (so putting it behind the "//}}AFX_DATA_MAP" line). So far, this seems to work properly.
Regards,
William
|
|
|
|
|
While ClassWizard is nice, do not let it ultimately govern how you lay out your code. It's meant to solve a problem a particular way, but that does not mean that other ways can't also be employed.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hello,
what is wrong with my application? i got an error message when i try to execute it.
The procedure entry point GetThreadId could not be located in the dynamic link library KERNEL32.dll
#include "stdafx.h"
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
GetThreadId((HWND)111);
return 0;
}
thank you
|
|
|
|
|
What version of Windows are you running it on? According to this[^], it's not available on all versions.
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]
|
|
|
|
|
hmm.. i am using windows xp
but how then i can send message to the thread process...?
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
HANDLE pKhwnd;
pKhwnd = CreateThread(0, 0, pKhookThread, &hInstance, 0, 0);
WaitForSingleObject(pKhwnd, 10000);
PostThreadMessage(GetThreadId(pKhwnd), WM_DESTROY, 0, 0);
FileWrite("Application Terminated");
return 0;
}
what function i have to use to get thread id?
|
|
|
|
|
Not knowing what your thread function does, just because you create a thread, what makes you think it will accept or handle your message? Possibly some of the articles here[^] might help you out.
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]
|
|
|
|
|
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.
|
|
|
|