|
1. Include any external C source code files in the project, the same as including a C++ file. The compiler knows the difference between the two file types base on the file extension.
2. Enclose the prototypes for the C functions in the header file or anywhere that a C prototype is provided [in a C++ file], using the extern “C” declaration as follows:
extern "C"
{
void prn();
}
3. Now you are set to do what ever you want as far as MFC development is concerned.
There is one other possibility; copying all your C files along with their headers into the project folder and changing the extension to ‘.cpp’. I generally do not recommend this if you have other C programs that depend on the same sources, as it is usually better to avoid having multiple copies of the same sources. Then again doing this makes the sources more specific to the C++ project being developed.
Any way you get the general idea of how it works.
Oh, you will have to change any code that is dependent on user interaction via standard input/output or any other non-Windows method. The difficulty of that depends on how you wrote the original code to begin with.
Good Luck!
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
OK I tried adding all C and .h files to the MFC project. There are many errors.
I'll change all the printf() calls to Afxmssg type. Now one of the main culprit is directory fns & variables. I think those also need to be replaced with MFC part. With code properly arranged out I'll get back to you.
As of now there are no calls from MFC code to any of the C fns. I understand that this has to be done within externC.
Thanx for the reply.
|
|
|
|
|
This is the first time I have been back since I posted my answer to you, but it appears you get the idea. Please do not use synonyms or Web acronyms when talking about coding, use the complete word so every one knows what you are talking about (assuming fns means function).
During the process I would be surprised if you did not receive many errors. Most of those should be related to I/O, always try to separate the I/O from the code that actually does the work as much as possible. Your ultimate goal is to write a solution (program) that has a back end (which does the work) and a front end (which show it to the user). If you do it right, then the back end will be portable (at least in theory).
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Please help me!!! Can any one tell me how to delete a line in text file. Please tell me how to do it in C (not MFC, C++)
Thanks...
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
You can't. What you have to do is read the file in memory, erase the line and write the complete file back. An alternative is to open a temporary file, write line by line in it (except for the line you want to remove), delete your original file and then rename your new file.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
I cannot take big data inside memory because I may have 1 Lakh records to be written to the file. I cannot also use temp file because I may to exchange data from original file to temp file alteast 50,000 times.
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
|
There is no way of doing that.
Mmmh, I think there is problem with your design: if you have to update files so many times, I don't think this is the right choice. Can't you use a database for that ?
What is the purpose of this file exactly ?
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Requirement is we have to query data from database and modify the recordsets and write the data into the text file.
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
An optimization is to write the remaining file from the point of the deleted data rather than the entire file.
Bahadur - yar - Jung wrote: I cannot take big data inside memory because I may have 1 Lakh records to be written to the file.
Use buffered IO
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
hi
how can i change the background color of a slider ctrl.
can anybody help me?
thanx
nirmal
|
|
|
|
|
nirmal wrote: how can i change the background color of a slider ctrl.
can anybody help me?
HBRUSH CEttDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd==GetDlgItem(IDC_SLIDER1))
{
hbr=CreateSolidBrush(RGB(123,123,13));
}
return hbr;
} Here IDC_SLIDER1 is the control ID of Slider control.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Is it possible to create in C++ the equivalent of the command window in matlab, i.e. a window ( the command prompt I guess), that would be launched at the beginning of a debbug session. While the debug is paused at the breakpoint, a chosen operation ( say viewing the value of an object) could be invoked on some object ( say "Matrix A")in the current namespace, by typing the corresponding command in that window ( say "View(A)") that would return the entries fo matrix A. One could also think of the computation of the condition number of that matrix, while the debug is stopped at the breakpoint, throught the command "cond(A)".
Any suggestion greatly appreciated
McBridou
-- modified at 8:45 Tuesday 23rd May, 2006
|
|
|
|
|
Hi
How I can draw animation on the desktop window (like Sheep or snow or MSAgent program)?
Thanks
|
|
|
|
|
1)Create a transparent window and draw over it.
2)If you want to draw directly over the desktop you can use GetDesktopWindow()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thank you, but
1) Drawing just one bitmap in transparent window is ok, but second one makes problem
2)it has same problem (redrawing previous area?)
|
|
|
|
|
Hadi Dayvary wrote: 1) Drawing just one bitmap in transparent window is ok, but second one makes problem
2)it has same problem (redrawing previous area?)
Use proper raster operation of drawing ..
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hadi Dayvary wrote: How I can draw animation on the desktop window (like Sheep or snow or MSAgent program)?
http://www.codeproject.com/com/msagent.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
|
|
|
|
|
Thank you
I don't wanna use MSAgent, I want to write same program, an Agent editor and a dialog for showing it.
|
|
|
|
|
hi,
i have a CTreeCtrl derived class CTreeCtrlEx. in it i have the OnSelchanged().
My Msg loop:
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
my problem is that the OnSelchanged doesnt fire sometimes!!
What is causing this? Any ideas? Thnx in advance...
|
|
|
|
|
Hi
I have a _bstr_t object and I need to convert it into a string and use it as an argument for cout. How do I convert it?? Please provide me some example for this conversion
-- modified at 8:21 Tuesday 23rd May, 2006
|
|
|
|
|
koumodaki wrote: I have a _bstr_t object and I need to convert it into a string and use it as an argument for cout. How do I convert it?? Please provide me some example for this conversion
cast _bstr_t object to char*
_bstr_t g("alok");
std::cout<<(char*)g;
"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
|
|
|
|
|
|
C++
Hi i have a function FTPcommand(CString command)
FTP
i want to give the command "put filename"
but because the filename got spaces (An Example.mp3)
i have to give the command "put "An Example.mp3""
C++
(Variable CString Filetitle = "An Example.mp3")
I type FTPcommand("put """+Filetitle);
I think i am wrong.If i am how i can type it so it would be correct?
|
|
|
|
|