Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Memory Leak Pin
David Crow22-Jul-10 3:03
David Crow22-Jul-10 3:03 
QuestionCTabCtrl color background Problem [modified] Pin
etipaq21-Jul-10 5:50
etipaq21-Jul-10 5:50 
AnswerRe: CTabCtrl color background Problem Pin
Niklas L21-Jul-10 10:12
Niklas L21-Jul-10 10:12 
JokeRe: CTabCtrl color background Problem Pin
Code-o-mat21-Jul-10 10:34
Code-o-mat21-Jul-10 10:34 
GeneralRe: CTabCtrl color background Problem Pin
Niklas L21-Jul-10 10:54
Niklas L21-Jul-10 10:54 
GeneralRe: CTabCtrl color background Problem Pin
etipaq21-Jul-10 15:59
etipaq21-Jul-10 15:59 
QuestionCharacter Exception Pin
Pryabu21-Jul-10 3:54
Pryabu21-Jul-10 3:54 
AnswerRe: Character Exception PinPopular
Aescleal21-Jul-10 4:15
Aescleal21-Jul-10 4:15 
People on these forums seem a bit obsessed by exceptions...

- wsprintf is a windows API function. Windows API function have a C interface, not a C++ one. As C compilers don't understand C++ exception handling Windows API functions don't throw C++ exceptions. Therefore whatever wsprintf does it won't throw, ever.

- CException is an MFC class. The only thing that throws exceptions based on CException is MFC and clients of MFC. Even if the previous point didn't apply then wsprintf couldn't throw a CException.

- IF wsprintf threw a CException derived class you're still using it wrong. MFC (due to it's long history of working on brain damaged compilers) throws exceptions by pointer and not by value. When you catch an MFC exception AND handle it you have to delete the exception afterwards. Not generally using the delete operator either. Have a look at the docs for details.

- finally even if wsprintf threw what you want it to catching it would be a bad idea. You've got code that's writing to a random area of memory. Do you really expect to be able to scribble over your process address space and get away with it? Sometimes you might be able to recover and keep going, hopefully most of the time your code will crash in a heap.

So:

- stop obsessing about exceptions but if you can't stop learn the difference between a processor exception, an operating system exception and a C++ exception

- stop mucking about with low level stuff. Don't use array of characters use vectors or strings. Don't think they're something advanced - it's the stuff you're doing (pointers and arrays and not knowing the differences between them, using C functions like sprintf when stringstreams do in a far safer manner) that's advanced

Ash
AnswerRe: Character Exception Pin
Sauro Viti21-Jul-10 4:35
professionalSauro Viti21-Jul-10 4:35 
GeneralRe: Character Exception Pin
Aescleal21-Jul-10 4:55
Aescleal21-Jul-10 4:55 
GeneralRe: Character Exception Pin
Richard MacCutchan21-Jul-10 5:19
mveRichard MacCutchan21-Jul-10 5:19 
AnswerRe: Character Exception Pin
Chris Losinger21-Jul-10 4:36
professionalChris Losinger21-Jul-10 4:36 
AnswerRe: Character Exception Pin
Cool_Dev21-Jul-10 4:38
Cool_Dev21-Jul-10 4:38 
Question关于32/64位操作系统下,应用程序兼容性问题 Pin
xjh_sz20-Jul-10 23:38
xjh_sz20-Jul-10 23:38 
AnswerRe: 关于32/64位操作系统下,应用程序兼容性问题 PinPopular
Richard MacCutchan21-Jul-10 0:13
mveRichard MacCutchan21-Jul-10 0:13 
AnswerRe: 关于32/64位操作系统下,应用程序兼容性问题 Pin
Sauro Viti21-Jul-10 1:00
professionalSauro Viti21-Jul-10 1:00 
AnswerRe: 关于32/64位操作系统下,应用程序兼容性问题 Pin
Luc Pattyn21-Jul-10 14:41
sitebuilderLuc Pattyn21-Jul-10 14:41 
QuestionRe: About 32/64 bit operating system, application compatibility issues Pin
David Crow21-Jul-10 3:09
David Crow21-Jul-10 3:09 
JokeRe: About 32/64 bit operating system, application compatibility issues Pin
Yusuf21-Jul-10 7:08
Yusuf21-Jul-10 7:08 
AnswerRe: About 32/64 bit operating system, application compatibility issues Pin
David Crow21-Jul-10 7:41
David Crow21-Jul-10 7:41 
AnswerRe: 关于32/64位操作系统下,应用程序兼容性问题 [modified] Pin
sunlin721-Jul-10 3:13
sunlin721-Jul-10 3:13 
AnswerRe: 关于32/64位操作系统下,应用程序兼容性问题 Pin
Randor 21-Jul-10 14:03
professional Randor 21-Jul-10 14:03 
AnswerRe: 关于32/64位操作系统下,应用程序兼容性问题 Pin
xjh_sz21-Jul-10 14:59
xjh_sz21-Jul-10 14:59 
QuestionDeleting all columns in CListCtrl Pin
kishorekumar146 20-Jul-10 23:21
kishorekumar146 20-Jul-10 23:21 
AnswerRe: Deleting all columns in CListCtrl Pin
Code-o-mat20-Jul-10 23:26
Code-o-mat20-Jul-10 23:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.