|
Hi. Yes, I personally never use the catch(...) because of the very things you mention in your post. I didn't like the fact that I couldn't do anything intelligent from within the catch(...) block. If you do catch an error in catch(...) you could just tell the user and then either carry on and hope for the best or just shut down app.
Neither are optimal solutions.
If anyone has any contributions to this I would be interesting in hearing it.
Pete
|
|
|
|
|
leave it to the OS? you mean the lovely "This application has performed an illegal operation" message box?
ask the average user which is more important: leaking 30 bytes or preventing the app from crashing without warning.
if i do a "catch(whatever w)", i always follow it with a catch(...). or, if i'm wrapping C code, or someone else's code, or around code that has the potential to jump out pf array bounds (like when you are filling a buffer that you didn't allocate).
in fact, i often put a catch(...) around every major code section, just in case something gets by testing. i also make sure that i do something intelligent in the catch, like attempt to get into a safe state.
the headaches that little construct can save are worth megabytes of leaked memory, to the average user.
-c
|
|
|
|
|
Hi,
Try this one
catch(CException e) //i'm not sure if is pointer of not
{
TCHAR szCause[MAX_PATH];
szCause[0]=0x00;
e.GetErrorMessage(szCause,sizeof(szCause));//
}
But the best way is to read CopyConstructor help for CString because the exception types are defined there.
Best regards,
/REMUS
|
|
|
|
|
I had develop an application which is running fine in the debug mode. There is no warnings there in either debug mode.I had handled all the possible exception. When I try to run that code in release mode on my computer it works fine. but when i run that exe in some another computer it crashes it give some memory handled exception on other machine. Can anybody can guide on this.
Also if anybody know about the Purifiers available for the VC++6 on Windows NT platform please let me know.
Thanks in Advance,
N.S.
|
|
|
|
|
Hi,
Usually the problems appear so frequently from 2 resons.
If you use MFC and modify the prototype of message handlers like ON_MESSAGE(WM_WHATEVER,OnWhatever) ....
OnWhatever has prototype LRESULT OnWhatever(WPARAM,LPARAM) otherwise you get your crash...
Other reason is uninitialized mebers. Normaly to avoid such situations you should add for each members default values and so on.
By the way to debug it in release version use for your project settings at c/C++ tab page for debug info -> Program database , for optimizations -> Disable Debug and in Link tab check the generate debug info check box. And now you have debug info in release!!
Try to get them with Bug Trapper from www.mutek.com
I whish you luck and patience,
/REMUS
|
|
|
|
|
If it is always working OK on your machine I would guess that the problem is something to do with the DLLs linked to your app.
Have your tried statically compiling the application with MFC libraries?
|
|
|
|
|
This question looks very familiar and I think I have provided a reply already, so probably it was the CodeGuru web site that I saw it. That site has been having problems so perhaps my reply was lost.
One good possibility is that you might be using ASSERT or something like that; if so, then the code would be executed for the debug version only.
Another possiblity might be that you are not checking all return codes from SDK functions etc. and there might be an error that you could catch and provide an error message for and quit sooner so that it would be easier to fix.
The other answer about uninitiallized variables could be an explanation; I think that the debug version might (I am not sure) initialize memory to zeros eventhough they are not initialized explicitly.
|
|
|
|
|
I need to hide the windows menu in a NT 4.0 windows application. Originally, the design of the application had a menu but the "design" of the application "has been changed" to one without a menu.
The functionality of the menu is provided by button controls in a child window.
I searched the MSDN, MSDN online, CodeGuru, CodeProject, Experts-Exchange, etc. without finding any information on "hiding a menu" in a Windows application.
|
|
|
|
|
Read MSDN for
CDocTemplate
CSingleDocTemplate
CM....
maybe you will find a hint
/REMUS
|
|
|
|
|
Hi,
I'm working with a Single-Document-Interface application (SDI).
In the resource editor, (VC++6.0), I tried changing the default icon (16x16) and (32x32) for saved documents.
But now when I save, the file still gets the old default icon. What's going on?
I would appreciate it if someone can tell me how to fix it.
Thank you.
|
|
|
|
|
You need to rebuild your icon cache. Tweak UI will do it, or if you don't have that, go to Control Panel/Display/Appearance tab. In the Item combo box, select Icon. Change the size to 33, apply it, then back to 32. That will rebuild the cache.
|
|
|
|
|
Does anyone know how the Unicode (wide-char) string is constructed. I have a unicode text file and I want to use WideCharToMultiByte to manipulate the contents. My problem is that I read the file as binary (byte-by-byte) and I dont know how to construct the wide-character string (used as the input for the function) to result the ANSI string. My project doesn't define unicode (therefore doesn't support unicode).
Thanks a lot in advance for any ideas.
|
|
|
|
|
Unicode uses 2 bytes for one character.
"Byte-order Mark" MSDN article could be helpful for you.
|
|
|
|
|
Hello,
how can I view the items of an array or an MFC Collection in the watch view? Let's say I have an CObArray named m_Array. Now I've typed into the watch window "m_Array[0]" to have a look at the first item in the array, but this doesn't work.
Any ideas are very welcome.
Matthias
|
|
|
|
|
For a CArray you have to dereference the internal data pointer to the C style array within the CArray.
Any collection not using standard C style arrays for data storage, which I believe is everything but CArray derivatives, will not likely have its contents aligned in a contiguous portion of memory like a CArray will. So viewing such a container's contents would probably be very difficult if not impossible. However, viewing a CArray is easy.
For example, if you are stepping through a class with a CArray derived data member named m_array you can see the contents of index 4 by entering this in the watch window:
*m_array.m_pData[ 4 ]
This assumes that that the array has a size of at least 5. Overstepping the allocated size of the array will probably not hurt in this situation but you will see garbage instead of what you expect to see.
Just think of the watch window as a way to execute a limited line of code. Virtually any syntax you would use in your program should be valid in the watch window. However, don't forget about the scope of the data you want to watch. It's easy to assume that what you put in should work and then believe that the problem is not yours when it doesn't work as anticipated.
|
|
|
|
|
I have run across a problem using CfileDialog on Windows 2000 for which I have not yet found a solution. The problem is as follows:
If I instantiate an instance of a CFileDialog passing TRUE as the first parameter and accepting the default values for all other parameters, and then call DoModal(..) on the object, then the standard CFileDialog is displayed. However, if I navigate to any folder that contains a read-only files, then I hit a user breakpoint deep within NTDLL.
To see this problem, the simplest possible reproduction is to create a dialog based MFC app that uses CFileDialog as its main window.
I had thought that specifying the OFN_DONTADDTORECENT flag might fix this problem but it did not. I also tried getting rid of the OFN_HIDEREADONLY flag, but that had no effect either.
Once the breakpoint is called in NTDLL, you can step over it to receive a 2nd which can be stepped over as well, and then the program continues normally until you shut it down at which point 2 additional breakpoints are encountered. Of course, in release mode, the operation is seamless and no problems are evident.
I have not been able to find anything at MSDN online that gives a description of the problem or a work around. If anyone has any information on a workaround that will keep Win2000 from hitting this internal breakpoint, I would appreciate it
|
|
|
|
|
Sorry that this is not a answer to your problem, but I tried creating a dialog app using CFileDialog as the main window. It worked fine in debug mode on read-only files. The only thing I can say is I have Windows 2000 Professional with SR-1 and DevStudio 6.0 with SR-4.
Sorry I can't help,
Jonathan Craig
|
|
|
|
|
Is theree any decent documentation on writing DevStudio add-ins?
I want to be able to add a menu item to the context menu in the workspace ClassView tab, and then bring up my own dialog when the programmer selects my menu item.
Thanks in advance.
|
|
|
|
|
Hi, what I need is a C++ class to read/write zipfiles(jar-files). The class may not use MFC, because I'm writing the application with WTL. Any suggestions ?
|
|
|
|
|
I realise that you don't want to use MFC but there is an MFC class on this site. This may be a start for you. Otherwise try the ZLib library avaiable from all over the place.
HTH
Jerry
|
|
|
|
|
I saw the classes here at CodeProject. I don't know if it's difficult to remove the MFC-stuff. When I don't find another solution, I'll give it a try.
I also saw ZLib, but I can't find any good documentation about it to use it in VC++.
|
|
|
|
|
Try having another look at ZLib. It's not that difficult. t has some examples, one of which I think is in pure C++. There are other examples such as an ActiveX version.
Jerry
|
|
|
|
|
Try having another look at ZLib. It's not that difficult. It has some examples, one of which I think is in pure C++. There are other examples such as an ActiveX version.
Jerry
|
|
|
|
|
Hi everybody,
where do i find the RLMAN.EXE described in the MSDN to localize existing resources.
And, there must also be an UCONVERT.EXE to convert files from ANSI to UNICODE.
I have installed VC++6.0 professional, but it is not coming with it.
TIA, Chris
|
|
|
|
|
never heard of rlman.exe ... programming international apps means u have to use unicode from the start and use the generic text mapping functions ... as well as being aware of the small gotchas to do with the unicode versions of functions (like strlen giving chars NOT bytes)
look up UNICODE in the msdn and go from there
good luck
|
|
|
|