|
Normally, what you have to do is to modify the .h-files for the C-sources
Before the first function prototype add this:
<br />
#ifdef __cplusplus<br />
extern "C" {<br />
#endif<br />
After the last function prototype, add this:
<br />
#ifdef __cplusplus<br />
}<br />
#endif<br />
Now you can call the C-functions from your C++-source.
Kakan
|
|
|
|
|
Hi Kakan,
thx for ur message,
i did as you said, and now i have another question,
i want to retrieve a string from C code into editbox,
i added the code to header files as you said, now how i have to initialise string to editbox,
for instance mamber variable of edit box is m_strEdit1,
and a function in c code returns the string "Hello", so how can i bring this string into editbox in vc.
thanking you.
|
|
|
|
|
Hello.
It's really very easy.
The C program returns a char* or a const char*.
Simply put it in m_strEdit1, and thats it!
But, there is an issue with MFC (and/or Windows): The editbox won't change it's value!
You have to call ::UpdateData(TRUE or FALSE), I never remember which, check the documentation. Then, you will see the newly assigned value in your editbox.
So do this (I assume the C string is in (char *) C_value):
m_strEdit1 = C_value;
UpdateData(TRUE or FALSE);
And that's it.
Good luck.
Kakan
|
|
|
|
|
Thx Kakan,
i have some questions,
ok i will explain what i need,
i developed one GUI in VC++, and there are microcontroller hardware progams written in Keil(is like C)for a microcontroller. now i have to select data from GUI and assign them to keil programs and retrieve data from keil and send it back to GUI, and again i have to send some other information to keil from GUI.
and for this do i need to write path to communiucate with other programs.
how to call the keil(C) programs in GUI and how to send and receive data from there.
|
|
|
|
|
Hello.
The question about how to execute other programs is very frequent at CP.
One way is to use ShellExecute, but there is others as well.
When it comes to communication, frankly, I don't know.
How does the Keil-program interface with the outer world?
stdin/stdout or another way?
If it uses stdin/stdout, you *might* be able to use the old C-function popen(). Check it out.
But I'm not sure if popen still exist.
Kakan.
|
|
|
|
|
Hi kakan,
thx for ur message,
and keil is similar to C.
And one old report i found that they used printf and scanf to send and receive from VC++.
|
|
|
|
|
Hello shesidar. It seems as if we live in different time zones...
The keil-program is the key here. I can think of two different scenarios, with two different solutions.
Scenario 1:
You start the Keil-program for every message to it. You give it the input via the command line. The Keil-program returns it's output to sidout and terminates itself.
For example:
<br />
C:\>Keil_program Status<br />
Status=2<br />
C:\><br />
Scenario 2:
You start the Keil-program. It reads it's input from stdin and responds to stdout. Then it awaits your next command.
For example:
<br />
C:\>Keil_program<br />
Status<br />
Status=2<br />
Exit<br />
Exiting...<br />
C:\><br />
Do you see the difference?
For scenario1, you can create a command line and redirect the output to a (temporary) text file. (Then you read the text file from your VC-program, and display it's result).
Example:
<br />
Keil_program Status >C:\tmp\output.txt<br />
Then read the file C:\tmp\output.txt and display it's content.
For scenario 2:
Have a look at the documentation of the _popen-function.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__popen.2c_._wpopen.asp[^]
Kakan
|
|
|
|
|
Hi Kakan,
Thx for ur message, but i am confused with how to call keil from VC, and how to send data from Keil to vc, i didnot understand your previous message.
Please donot mind, should i add any libraries in VC to communicate with kiel?
Thanking you,
sheshidar patnam
|
|
|
|
|
Hello.
I have taken for granted that the Keil program runs as a separate program in a DOS-box/command-prompt and you want to interact with it as such.
If you want to include the Keil-program INTO your Windows-program, then I don't know how to do it. You will have to read the manual(s) for Kiel, it should say something about how to do it.
Now, I will go on leave and I won't be back until the 2:nd of January 2006.
Maybe I will check out CP from time to time. But not on a regular basis, that's for sure.
Merry Christmas and Happy New Year to you.
Good luck.
Kakan
|
|
|
|
|
Thx , kakan,
and i wish you for merry christmass and happy new year, enjoy the events.. have a nice time.
bye.
sheshidar patnam
|
|
|
|
|
Dear Experts,
I need some information on dynamic updation of XML file.
Our application asks the user to insert a file by giving the user browsing option.
We want our XML file (which contains the information about the residing files) to be dynamically updated as soon user specifies the path of the inserted file.
The next task is to dynamically update the XML file once the user select the file to be deleted by clicking on the Application UI.
We have to develop the code in C++.
Kindly send across your suggestion, opinion and helpful codes.
Regards,
Mayank Srivastava
|
|
|
|
|
srimayank11_codeproject wrote: We have to develop the code in C++.
you don't need to develop/write any code, here this class will help :-
http://www.codeproject.com/soap/markupclass.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Dear sir,
i connect vritual com3 to com4.
i am writing one prgram for sending data to com port3 .and want to read at com port 4.i am able to write data from com3. but i am not able to read it at COM port 4
where is the problem
|
|
|
|
|
You can first test the port by connecting the com ports externally, then use HyperTerminal to test the connection. Run Hyperterminal twice, one for each port, and communicate between them; if it runs ok, then run your program on one end at a time, and communicate with HyperTerminal; that way you can find where the error is.
this is this.
|
|
|
|
|
I havent tried with the virtual ports
but it seens that the Hyperterminal solution is
good one to try .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I have grayed the dialog’s X button in traditional way by using pMenu->EnableMenuItem(SC_CLOSE, MF_BYCOMMAND | MF_GRAYED). The problem starts when I have two dialogs open at the same time. Normally if a dialog loses focus, the X button becomes dim. But if a dialog with grayed X button loses focus, the X button becomes red. It’s not as bright red as the unmodified X button, but certainly it doesn’t look dimmed. So every time when I’ve got two dialogs open the one with the focus will have dimmed X button and the unfocused dialog will have redder X button. How could I fix this?
|
|
|
|
|
Dear friends,
There are two object oriented languages. C++ and java.
which object oriented language is best and why. give me a
reply.
Regards
kedar
|
|
|
|
|
C++ Rules!!!
You can do anything and everything in C++.
This may not be the reply you are looking for, but consider this:
They took C++, cut off its arms and legs, put it into a wheelchair, put it on illegal drugs, and called it J**a.
A program written in J**a takes half a day to load, and takes another day to add two integers.
A typical software written in J**a (hypothetical):
IntegerSoft(R). Adds two integers, and outputs the result as integer.
Description: you can now add two integers without using a calculator. This great software uses state of the art (crappy) user-interface.
this is this.
|
|
|
|
|
don't be so rude with java !!! for many management programs, it's enough... all depends on what you need.
moreover, yes, they took some good things to C++, such as C++ took to C for the language syntax, to Algol, Simula, and several much languages...
and you know, .NET took to java quite its totality !!! so java certainly have some good points dude !
"A program written in J**a takes half a day to load, and takes another day to add two integers."
this is totaly wrong, i a wonder if you ever used Java one time in your life...!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
-- modified at 6:13 Friday 9th December, 2005
|
|
|
|
|
Agreed.
They knew everybody cannot program in C++, that is why J**a was invented, which is easier, etc etc.
I love J**a, but only for drinking purposes.
this is this.
|
|
|
|
|
i love C++ (which is my predilection language), but i cannot let you say these.
C++ is getting old man, and moreover, is not a totaly OO language (because of its C inheritence)...
Java is, and have some more features.
of, course, C++ still have multiple inheritance, templates, operator overloads, inlines, assembly keyword, etc, etc... but you cannot spit like this on Java.
One last thing : the day you'll design your own language, i will respect you as i do with Mr Stroustrup...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|
hi man,
you know, C++ and Java are not the only object oriented languages. nowadays, all .NET languages are, and some languages from the dark side of IT are OO too.
all depends on what you want to do, as i already answered to khan++.
C++ have the capability to allow you programming directly in native language, avoiding the use of a particuliar framework. in such a case, C++ would be a bit faster that Java. but here again, performance worthes only if you have to do very fast/heavy treatments...
Java have advantages on its side... automatic memory management (with its garbage collector) is one of the most famous !
point out what you have to do before choosing a language, not because it's best, but because it better deserves your problem...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|
vcforums wrote: There are two object oriented languages. C++ and java.
Both Langauge are best at there place.....
C++ is best when you are creating system based application
and
Java is one of best when you creating webbased application..... ( one of best because we have c# too)...
also one more point c++ is not purly OOPS oriented language it is object based language whereas java is object oriented langauge
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ThatsAlok wrote: c++ is not purly OOPS oriented language
True. It is a multi-paradigm language.
ThatsAlok wrote: it is object based language
False - an "object based language" (as defined by Lippman) does not have inheritance - C++ does.
ThatsAlok wrote: java is object oriented langauge
Java is an OO language, but not a "pure" OO language. Smalltalk is "pure OO language".
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Try C#! Tons of samples here. And here.[^] I'd say the library is extensive.
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|