|
Oops really? I had tested the code in some sample application and it is working fine.
Are you sure that when you select the settings, on the second time, the control is coming to the same MainFrame object's OnSettings? And are you sure that the object is now member of the class?
Can you show me the relevant updations that you made?
- NS -
|
|
|
|
|
Thanks NS17.The problem was that i have given same ID for the two menu options in two menus.It is working fine.
Thanks
-- modified at 4:47 Friday 10th August, 2007
|
|
|
|
|
So you have two Settings dialog objects, rt? Can you make it global, instead of two member objects? If so only one object will be there.
- NS -
|
|
|
|
|
Welcome...
- NS -
|
|
|
|
|
This is obviously not going to work. When DoModal() is called, it does not return until the dialog has been dismissed. Therefore, OnSettings() will not get called more than once.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Is it possible to execute C, C+, and C# in C++?
|
|
|
|
|
Jay Minor wrote: Is it possible to execute C, C+, and C# in C++
Can you please explain what exactly do you mean by "executing". If you have exe's developed in any of the language you can execute them in C++ using the ShellExecute API.
It would be good if you can put some more thought and explain to everyone here what do you exactly want to achieve.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Can you more explain do you have any code on the C# if yes you cant use of them on the c++.
|
|
|
|
|
Well I don't care much about C#; most importantly I want to know if I can code C and C+ in C++. ex. a very basic app like some calculations
|
|
|
|
|
Sometime its possible use of C code on the c++ but for C# its different.
|
|
|
|
|
From what I understand if you want the C++ compiler to interpet a peice of code as C you preface it with extern "C" However I have a typedef of a fucntion with the word "class" and another with the word private I preface these typedef with extern "C" and still get an error re: the class syntax e.g the C code would be foo( int *class) I changed the code to read extern "C" foo(in *class) and it still flags the class keyword shoudn't the compiler compile the code as C becuase of extern "C" keyword ???
|
|
|
|
|
ForNow wrote: From what I understand if you want the C++ compiler to interpet a peice of code as C you preface it with extern "C"
Nope, that's not the purpose of extern "C". The purpose of extern "C" is taht your C++ compiler will create a C linkage of the functions inside the block. The difference between C and C++ linkage is that in C++ there is function overloading, meaning that you can have several functions with the same name but different arguments. The linker, to differentiate those functions uses name mangling (the function is identified by its name and with special characters that 'describe' its parameter list). In C, you don't have function overloading so the linker uses the name of the function only to identify a function.
So, when you specify an extern "C" block, all the functions inside that block will have a C linkage (meaning also that you won't be able to overload them).
So, you cannot simply have C++ code and wrap it with extern "C" so that it can be compiled with a C compiler.
|
|
|
|
|
Is there any method of mixing C an C++ code
|
|
|
|
|
Depends of what you mean by "mixing C and C++" ? If you have a C++ compiler, it should be able to compile C code. What is the problem exactly ? Could you describe it more in detail ?
|
|
|
|
|
As In the example above foo(int *class) will compile when the source of the program is .c
as In thefirst project but
in the second project with a .cpp program its is flagged as an error becuase "class" is a C++
keywords
|
|
|
|
|
If you have a file with a ".c" filename-extension, the compiler (actually, the IDE when generating the project) is treating it as a C-File. It can be linked seamlessly with a C++-application.
What exactly do you want to do?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
in the C++ program I am including a header which has (just an example) foo(int *class)
which compile cleanly in C but in C++ the word class is a keyword and get flagged as an error
|
|
|
|
|
Just change it?
The name should be irrelevant, the parameter position would be relevant.
Compile the C-Code as C-Code and link it to C++-code?
On C-Files, the compiler would automagically use the calling convention you otherwise enable with "extern C".
I don't know if it accepts C++-reserved keywords, though.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Thats The thing it doesn't extern C must be Just calling convention as far as Anything else if a C header is included in .cpp prog no matter what the prefix by that I mean by that (extern "C") the compiler will use C++ syntax checking
still the word class followed a data type e.g. int *class so.... even in C++ it should compile
Anyway thankx
|
|
|
|
|
ForNow wrote: the compiler will use C++ syntax checking
No he won't - but he is still bound to the C++ reserved words list. This can not ever be valid identifiers in a C++ program.
But I think they could in a C-Program compiled by the very same compiler.
As long as they do not appear in C++ context.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
I think my only soultion is to #ifdef __cplusplus C++ code #else C code #endif
thankx
|
|
|
|
|
let me tell the whole method:
i want to diaplay a modeless listbox on button click.i.e when i click a button a listbox pops-up.for this i hav made a new class named CMyLIst which is derived from CListBox.in CMyList i have made my own addstring function which is like this:
int CMyList::Addition(LPCTSTR lpszItem)
{
return CListBox::AddString(lpszItem);
}
In my Parent class which contains the button
i have declared an object of CMyList as:
CMyList myobj;
and i hav used it as
void CMyDemo::OnButton1()
{
CMyList myobj;
if(myobj.DoModal())
{
myobj.Addition("hye");
}
}
but i m getting error that DoModal() is not function of CMYList
May be this problem is because i have derived C
|
|
|
|
|
I thought DoModal is only for CDialog derived classes. Use a Dialog to hold the ListBox. Call the Dialog with DoModal, and implement the code of your listbox there. You will be able to acces the ListBox from outside the dialog (your button to add the string) using a pointer or a CListBox member variable related to your listbox in the dialog
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
tyagineha wrote: CMyList myobj;
if(myobj.DoModal())
{
myobj.Addition("hye");
}
Called With DoModal() , a dialog is modal (blocking the GUI until it goes away). So DoModal() only returns after your dialog has been closed. IDOK is the return value when the OK-Button was used, IDCANCEL when the cancel button was used.
So you are filling the Listbox only after it has ended.
Add you call to addition between the instantiation of CMyList and the call to DoModal() .
You probably will have to store the data in a variable in your derived class, because there is no such thing as a ListBox window you could call AddString() on.
Your class can then handle OnInitDialog() and fill the ListBox after the call to the base class.
All this is made easier by using a CDialog -derived class.
If you do not want to use CDialog , you would have to Create() the listbox yourself.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Can you explain why you derived CListBox do you have any intent of derived?
|
|
|
|