|
I had to dig around in MSDN and trace through a few MFC based allocation failures to find out how to change the MFC handler and came across AfxSetNewHandler which does (confirmed this) set the handler for allocation failures in an MFC application.
The last time I checked this out (MFC allocation failures) was 7 years back and I only remember walking away with confirming what MSDN says about CMemoryException - "Memory exceptions are thrown automatically by new". Its probably good for one to revisit this topic every so often as I had been concerned that I had been protecting my new incorrectly all this time after seeing the wizard code.
Thanks for helping me get to the bottom of this.
modified 11-Nov-11 21:10pm.
|
|
|
|
|
bob16972 wrote: My question was not a complaint
Sure sounded like one.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Nah. I was just trying to figure out what the Microsoft programmers were attempting to protect against as I hadn't contemplated the scenario that Chuck O'Toole brought up in a different post.
He gave me a swift kick in the right direction and I think the mystery is now solved.
Thanks for your time.
|
|
|
|
|
The C++ standard requires that the new operator throws upon failure, but MS for some unknown reason implemented their compiler otherwise: it will return 0 upon failure and not throw.
In short, Visual C++ is not standard compliant, in this, and various other things, mostly related to templates. If you code platform-independent, you will have to specifically take care of these discrepancies, but since you are using MFC, I suppose that is not the case.
|
|
|
|
|
In this case, the compiler is not at fault. Since VC2005, Visual C++ compilers have been good at adhering to the standard, and has largely been at par with the other compilers out there in that regard.
In VC2008, new throws as it should, but the code in the question above is automatically generated, and that generator has apparently not been updated since the bad old days of VC6.0
Since Herb Sutter - the convener of the C++ standards committee - started working for Microsoft as an architect in the developer tools division, they have spent a lot of time and effort on becoming standards-compliant, and you do them a disservice to claim that the recent compilers are as bad as the steaming pile of wossname that VC6 is.
|
|
|
|
|
Ah, good to know. I only recently switched from 2003 to 2010 and only knew this used to be at fault in VS 2003.
|
|
|
|
|
Hello,
I´d appreciate it if anyone can tell me how to execute a dev-c++ program in the background as stand-alone.
Kindest regards
|
|
|
|
|
Define "in the background," and "as stand-alone."
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
That's pretty much what I answered, but made a couple of guesses...
|
|
|
|
|
Hi Richard,
Sorry about that. What I mean is a program which only has to be executed once,and just runs all the time doing the work it`s supposed to. I´d thought of putting it into an endless loop using "while (condition which never happens)" >> run sort of thing, but that´s not ideal. Maybe you know a different more effective way?
Thanks for answering so promplty.
|
|
|
|
|
RealHigh wrote: background
Make it a windows service[^] (if you want it to run in multiple operating systems, you can always make the application run on an invisible window).
RealHigh wrote: stand-alone
Not sure what you mean by stand-alone, could mean you don't want to bind to libraries, in which case, don't use libraries or make sure they're statically linked.
|
|
|
|
|
If you are referring to Windows Services, here's a link[^] that might help you get started. Google will supply a whole lot more, though.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Are you referring to something like WinExec() , or CreateProcess() ?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi David,
I know it´s pretty tiresome playing a game in which the other guy doesn´t know the rules. Truth is, I`m just trying to learn from this forum, which I think is very good, excellent. Now, my knowledge of c++ programming is rudimentary. Not a single person was born knowing all about it, and it´s really tough being bombarded with info which I don´t know how to use, yet.
Anyway, thanks to all who answered.
|
|
|
|
|
I`m looking for help with writing a program for electronic signature of XADES-BES for the xml file. Magazine of the certificate is available from the IE browser. How do it in C++ Builder?
|
|
|
|
|
Hi all,
I am trying to play video and i came to know about directshow.
I tried coding through direct show and play my video it is done successfully, but video plays in different full screen window.
I want that these video should play on my dialog box inside any control.
I don't know it is possible or not.
If it is possible then anybody can please guide me in doing so???
|
|
|
|
|
How you choose to do it may depend on what renderer you are using. You could position the renderer's window (HWND) on/in a control. For windowless renderer you could render the video directly on a control or on a window in/on a control...
Mark Salsbery
|
|
|
|
|
thanks a lot.
If you can give me some example of how to implement it. It will be really helpful for me.
I am having problems in implementing it...
|
|
|
|
|
Hi all,
I want to display a Bitmap on my static control.
For Doing so i have written this line of code
<pre>m_Bitmap.SetBitmap( ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMP1)) );</pre>
But it is not displaying the bitmap.
What should i do..
|
|
|
|
|
Are you sure that LoadBitmap() is correctly returning a handle to the image? Also MSDN recommends you use LoadImage()[^] in preference.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
My application is developed using Visual studio 2008 and it is MFC application. It is using one XML configuration file and it is deployed with the application. As per the change of requirment, we should not deploy the XML file in to customer machine instead we have to deploy the binary of that file.
How can I convert the XML in to binary file and get the data from the binary file again?
I am thinking serializtion is one option, is there any easy way to do this?
Thanks in advance.
-Mutpan
|
|
|
|
|
It depends on what type of data you need with the application. Is there any reason why you cannot add this as a resource?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
The file is not the same for all the user of the application, it is different for each user. So i cann't add it to resource.
|
|
|
|
|
In that case why use XML at all? Just create a binary file that encodes the information you require, and add code to your application or installation program to read and process the contents.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I imagine the changed requirement is to prevent your customers from seeing the details of the configuration file?
If so, I'd suggest simply obfuscating the XML by running it through some encoder/decoder. This way, you still have the benefits of an extensible and flexible format, at the cost of an extra step when reading/writing the file.
Of course, how complicated this would be depends on what XML parser you are using, as I don't think there's one in MFC.
If your parser can parse from and export to a string - and if the string isn't excessively large - you can simply read your encoded binary data from file, decode it to a string, and parse that. Similarly, when saving the config, you'd export to a string, encode that, and save it to file. If your parser needs to work with files, you can use the %TEMP% area for the conversion.
There are plenty of encoders you could use, from base64 to libzip to various crypto algorithms, so just pick one that is quick, and simple to integrate.
|
|
|
|