 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Hello,
I’m new in MFC programming and I have a doubt about destructor's calling in a MFC application.
I wonder if it’s necessary to insert destructors for the classes of the project.
I suppose (but I’m not sure) that Windows automatically calls destructors for classes created by the project wizard (doc, view, frame…) when I stop the program execution and close the program window.
But what’s the situation for classes that I have inserted in the software?
I never put destructor for these objects (dialogs, strings, bitmap, controls, custom objects…)
Is this a problem? What could be the problems in this situation?
Best regards.
|
|
|
|
 |
lor75 wrote: I wonder if it’s necessary to insert destructors for the classes of the project. Yes, if you have clean up tasks that need to be done.
lor75 wrote: I suppose (but I’m not sure) that Windows automatically calls destructors for classes... Yes it does.
lor75 wrote: But what’s the situation for classes that I have inserted in the software? Please explain.
lor75 wrote: I never put destructor for these objects (dialogs, strings, bitmap, controls, custom objects…) You mean classes that you're using as opposed to those that you've created?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
 |
I try to explain with an example: I create a CBitmap object used to put a bitmap on a custom button control.
Do I have to destroy the object when I exit from the program or the object is automatically destroied?
|
|
|
|
 |
which is the best book to study about graohics in c , and which compiler is the best ? i have been looking orward to make a game using c. please guide me
|
|
|
|
 |
I generally use always plain C even for COM. Unfortunately nowadays almost all advanced libraries for graphics, comms, and whatever you want are available only in OOP and managed code.
But still you can do alot of things using plane C.
I suggest to start studying the old good GDI[^].
For games is available the evergreen Allegro library[^].
Hope this will help.
|
|
|
|
 |
c/c++ program of rabin cryptosystem
|
|
|
|
 |
If you mean "Please give me the source of a c/c++ program of rabin cryptosystem", then I am afraid you have come to the wrong place.
|
|
|
|
|
 |
Hello.
I am developing a small application using tapi. Well main problem is i can not have input and output voice at same time.after many search i found i should have full-duplex modem and TSP. But my modem is full-duplex so i guess all these problems is because of unimodem.tsp which does not support full-duplex. I decided to use other TSPs , but i do not know how to tell my TAPI object use another TSP not always unimodem.
Well with this situation, i should have one way voice, ok? (cause unimodem is half-duplex) but here we have another problem. I do not have any voice, not out going and neither incoming voice. It is weird. in events first i receive
JulMar.Tapi3.CALL_MEDIA_EVENT.CME_STREAM_ACTIVE
but after it another event raise, it says
JulMar.Tapi3.CALL_MEDIA_EVENT.CME_STREAM_FAIL
I found this error into callmedia event:
JulMar.Tapi3.TapiException (0x8007000E): Not enough storage is available to complete this operation.
JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_BAD_DEVICE
What it means "Not enough storage is available to complete this operation"?
I have much free memory, So what is it trying to say!?
I increased PageFile for virtual memory. Nothing changed.
I read somewhere i should not call COM object many times. But I have no idea, Cause it is event, i have no control how much event Tapi server raise.
Whats problem?
Thank you
A.H
[It is with Julmar and c#, but why i post this here, cause i think it is more ralted to COM and unmanaged tapi codes, and maybe memory management. ]
|
|
|
|
 |
I haven't direct experience with the issue, but as far I can see the error isn't to be interpreted as memory problem, but missing resource.
Probably what is not found is the codec, specifically the ACM.
Try to look if it is available and connected.
Good luck.
|
|
|
|
 |
Thank you to reply.
I forgot to say, in 4days before it was working, and i could hear one way voice(outgoing call in dialing, and incoming voice when answer call), also i could play wave file, and record conversations. I do not know what happened exactly, but i guess i changed modem .INF file in trying to full-duplex support, and all failed after it, then i reinstalled previous modem.
Also i do not know about ACM Codecs, i google it when i be in my work place.
Thank you again!
|
|
|
|
 |
Hi,
I have Binary Data to be included in a DLL. The Tool I have developed to generate this data, currently creates a BYTE array in a CPP File. This File is subsequently compiled into an .obj File as part of the project, and linked in the normal way with the linker. The next step forward would be to have the Tool produce an obj file in the first place. Anyone any ideas how to do this? Microsoft maintains that .obj files are standard COFF Files. I know from experience that this is not strictly the case. In any case there is very little documentation about the further details, such as identification of sections of the Obj File, etc. I would need to produce a File that meets the minimum MS Linking Spec. There is only One 'C' linkable variable, the name of the array.
Has anyone any ideas?
Regards
Bram van Kampen
|
|
|
|
 |
Hi,
Adding the file as a custom resource and then using FindResource set of api's to access it, does not fit your needs?
Regards,
Mauro.
|
|
|
|
|
 |
The format MS uses is standard indeeded, it is named PE (portable executable), and you can get whole documentation here[^]. It is made public to avoid penalties from antitrust because, if hided, it could be seen as an abuse.
It is based on COFF, and its almost the same, apart from the interpretation of location offsets that are different.
You can create a PE object header, include your data in an initialized data section and create a symbbol in relocation..
But if only need to access that data in the DLL the really easy solution is, as they already told you, to create a resource and use it.
|
|
|
|
 |
Hi everybody !
I am looking for an automated tool or script that will take a huge Borland C++ buider project and convert it into Visual Studio .NET project. A full conversion is not necessary, rather a starting point for manual intervention.
So, after researches, i focused on the vcl conversion part to .Net, win api, so i want to know if is there a tool that can do this , at worst, just partially,
|
|
|
|
 |
There is no tool to do this. You're going to have to either write the tool yourself or just skip it and convert the code by hand.
|
|
|
|
 |
Hello Friends
I converted MFC application to 64 bit using VS 2013. My exe is working in Release build.But As I run in Debug Build,it pops up with Window error saying "The Application was unable to start correctly(0x0c000007b).Click OK to close the application."
After Google, I tried different methods As suggested [Copied mfc100.dll,mfc00u.dll,msvcp100.dll,msvcr100.dll,msvcr100_clr0400.dll] to System32 folder.
I installed vs2010,vs2013 redistributable package too bt no Luck.
Any Ideas?
Thanks & Regards
Yogesh Sikri
|
|
|
|
 |
Debug builds are not intended to be run on other machines than the development system. So try to start your program in the debugger of your VS. If that works, all is OK.
Debug builds are linked to special versions of the runtime DLLs which did not exist on machines that have no VS installed. While it would be possible to copy these special DLLs, you should know that you are not allowed to do so.
|
|
|
|
 |
I am running debug build on development machine only.Still no Luck.
|
|
|
|
 |
Check the debug output window to see when the error appears. You may set a breakpoint at your InitInstance method. If the error appears before that it may be some DLL that does not match. Does your application uses some self-build or other non-MS DLLs? If so ensure that these DLLs are present as 64-bit versions. Check also your debug project settings for those DDLs to ensure that there is no entry to an old one.
The MS / MFC specific debug DLLs should be already present on your system (they have the letter 'd' at the end of the name).
|
|
|
|
 |
Check if there is any manifest resource in the project and check that this resource also is updated for X64.
Fast test: exclude the manifest from project and recompile.
|
|
|
|
 |
no, there is no manifest resource.
|
|
|
|
 |
This error comes on 64bits OS's when the loader try to link a wrong DLL (typically a 32bits DLL in a 64bits executable).
Check again your project and verify that you are correctly linking to 64bits versions of all DLL's.
Maybe your program use a DLL built for 32bits. The linking could complete even with wrong import library, then the error is triggered at loading time.
The most common case is when a manifest is present in whichever library reporting X86 build, the loader, and this made me mad, testardly try to load 32bits version of commctl32.dll
|
|
|
|
 |
Using Excel Automation in Visual Studio 2010 C++, how do I define a name? As a user of Excel, you can enter a name that then can be used in formulas to refer to a range of cells. The range changes as the user inserts columns or rows. My program has worked with various versions of Excel dating back to the early 2000’s. I have a bunch of classes derived from COleDispatchDriver: CXLApplication, CXLRange, CXLWorkbook, CXLWorkbooks, and CXLWorksheet that have many functions, but I have no documentation (anybody have any clues on where to find documentation?). Anyone know how to define a named range using functions of these classes (probably CXLRange)?
modified 4 days ago.
|
|
|
|
 |
Where do these classes come from?
|
|
|
|
 |
These classes were generated years ago from the Excel type library using Class Wizard. I note that these classes can be generated using Class Wizard on Visual Studio 2010 as well: MFC Class Wizard->Add Class (arrow)->MFC Class from Typelib...->Add Class from Typelib Wizard->Available Type libraries: Microsoft Excel 15.0 Object Library<1.8>. Then you add the classes, using whatever names you want and the files are automatically generated. However, the classes in my legacy code are a bit different than later versions of Excel. Also if you know where to find documentation for these classes, it would be much appreciated.
|
|
|
|
 |
Sorry, but you will have to figure it out then. I have no idea what they do.
|
|
|
|
|
 |
Hi
I am using g++ to compile on a raspberry pi.
using the following the project compiles:
g++ -c file1.cpp file2.ccp .....filen.cpp
however using the following I get numerous messages as follows:
filen.cpp: (.text+0xb73c): undefined reference to `*******
etc etc etc
these functions are defined in a header file in each of the file*.cpp files thus:
#include "funcdefs.h"
this header file is located in the same directory as the *.cpp files
the header file was originally entitled FUNCDEFS.H but I changed the name to lower case funcdefs.h to stop the compiler complaining.
the funcdefs file contains the following code:
#if !defined(funcdefs_h)
#define funcdefs_h
extern double func1 ( double f ) ;
extern void func2 ( double *input ) ;
#endif
I have tried making the preprocessor directive in the funcdefs.h file lower case (didn't make any difference) and have checked the include path using -H and it seems to find the file but cannot get it to link.
Any ideas?
Thanks
|
|
|
|
 |
The error does not occur during compiling but during linking. It tells you that the final program did not contain the functions in one of the compiled files.
You must also add the source files with those functions to your project. So copy the source file(s) (e.g. funcdefs.cpp) to your directory and add them to the g++ build command.
|
|
|
|
 |
Thanks Jochen
I might not have given you enough information. The actual text of the linking error message is:
In function `process(int, char*, ControlData*, char*, char*)':
PROCESS.CPP: (.text+0x788): undefined reference to `readsig(MiscParams*, char*)'
PROCESS.CPP: (.text+0xaac): undefined reference to `sig_save(Signal*, char*)'
PROCESS.CPP: (.text+0xdd4): undefined reference to `display(Signal*, MiscParams*, int)'.............
......etc etc etc
so there are many undefined references to functions from within the function 'process' contained in PROCESS.CPP
however; all these functions are defined in funcdefs.h as follows:
extern int readsig ( MiscParams *misc , char *namelist , int *nsigs ,
Signal ***signals , char *error ) ;
etc etc etc
as I understand it, the various individual *.cpp files are referring to functions that are defined within funcdefs.h shouldn't these definitions be included from this file by the pre processor instruction and therefore be defined references?
Or are you saying that it is the function 'process' in PROCESS.CPP that is calling other undefined references? The very first such call is 'readsig' which is defined in functions.h
Or are you saying that I should just call functions.h functions.cpp?
This is driving me nuts so thanks for your help!
++++++++++EDIT+++++++++++
Jochen - I think I'm beginning to get your drift! The fundefs.h file only contains function prototypes not definitions
modified 5 days ago.
|
|
|
|
 |
I just saw you edited your post and got it. But I will answer anyhow (I had already written this but the CP servers where unavailable for some minutes):
I suggest to read about definitions and declarations in C/C++ because these are often mixed up.
See the first answer of this Stackoverflow thread: http://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-declaration[^]
You have declarations for the functions in your header files. So the sources will compile.
But you don't have definitions for the functions in any of your source files. So the linkage will fail.
You must add the source files containing the definitions. For the readsig function this must be a source file containing:
int readsig ( MiscParams *misc , char *namelist , int *nsigs ,
Signal ***signals , char *error )
{
}
|
|
|
|
 |
You must include the library or object modules that contains the actual code of the missing functions. As Jochen already mentioned, these are linker errors, nothing to do with compiling or header files.
|
|
|
|
 |
class M { //variables public: protected: private: //functions public: M(); ~M(); virtual int foo(int); protected: private: M( const M &c ); M& operator=( const M &c ); int i, j; }; //M
Thanks, any help as always is appreciated. Cheers Vaclav
|
|
|
|
 |
They are merely section markers, probably put in by some automatic code generator. They allow the developer to easily add properties and functions in the correct places.
|
|
|
|
 |
If your question is, why the copy constructor and assignment operator are declared private: This is to prevent the users of the class from copying objects of that type. At least the assignment operator is created atomatically by the compiler, if the designer of the class doesn't explicitely specify one. This default assignment operator simply copies all members. So without the operator you could write
M m1, m2;
m2 = m1;
and it would compile. With this class definition as it is, you will get a compile time error that the operator is not accessible.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
 |
Hi All,
I am new to COM. I have a DLL which is written in C. I want to make that DLL a COM dll. SO that i can register it and my application can use it. I tried google a lot. But not finding any satisfactory answer.
Please answer if you have any idea about how to achieve the said.
Thanks in advance
|
|
|
|
|
 |
Below is my code tried
class CVersion
void CVersion::ReadValue(BYTE *Buffer, int n_Length, int n_Source)
{
EnterCriticalSection(&m;_sReadCritical);
CString tempBuffer((BYTE*)Buffer);
m_svalue = tempBuffer;
m_cData->Data(this);
LeaveCriticalSection(&m;_sReadCritical);
}
class CClassVersion
void CClassVersion::Data(CVersion *pcVers)
{
CString m_Value1 = pcVers->m_sValue;
this->SetDlgItemTextA(IDC_EDIT_VAL,m_Value1);
}
//Declared in CVersion header file
protected:
CClassVersion* m_cData;
An Runtime error occurs"Unhandled exception at 0x782ac7da in .exe:0xC0000005:Access violation reading location 0x00000020."
after SetDlgItemText stmt.
Please guide me for the same.
modified 2-Mar-15 1:23am.
|
|
|
|
 |
You should step through the code with your debugger to see which variable is invalid. There is nothing obvious in the above code, although it is not easy to understand what it is supposed to be doing.
|
|
|
|
 |
Can i use callback function over der?How??????please guide me for the same.Thankyou
|
|
|
|
 |
Member 11438021 wrote: Can i use callback function For what reason? You first need to diagnose what is happening in your code to cause the error. When you enter the critical section what are you trying to synchronise with?
[edit]
void CVersion::ReadValue(BYTE *Buffer, int n_Length, int n_Source)
{
EnterCriticalSection(&m_sReadCritical);
CString tempBuffer((BYTE*)Buffer);
m_svalue = tempBuffer;
m_cData->Data(this);
LeaveCriticalSection(&m_sReadCritical);
}
You are setting m_svalue to point to tempBuffer , but as soon as you exit this function that buffer will get released so the pointer is no longer valid. Looking at this code again I cannot see what useful purpose it serves.
[/edit]
|
|
|
|
 |
I want to update the text(string) on u/i page.I am sending the message on button click and want to receive the same string on Edit controlBox.
|
|
|
|
 |
Then you need to manage the lifetime of the string. If you pass it from one thread to another then you must ensure it is not deleted from its source until the destination has taken a secure copy. In your sample code your destination thread is taking a copy, but only into a temporary location which immeditely gets disposed. Assuming that m_svalue is a string pointer then you just need to allocate a buffer of the required size to it, and copy the message string across. You can then delete it at some later point.
|
|
|
|
 |
I assume this is a threading problem. The code can probably be called from different threads (that's why you use a Critical Section), but the control text can only be set from the GUI thread.
The easiest way to achieve this is using a timer. So in the ReadValue() fucntion you only put the data into m_svalue. And in the OnTimer() function (which runs in GUI thread) you call Data(). This would of cource mean that you need to store the most recently used CClassVersion object somewhere.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
 |
Can i use Handler or callback function,if yes.How???
Guide for the same.Ty.
|
|
|
|
 |
How is m_cData initialized?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|