|
That's not what the author wanted - he wanted to be able to implement something like co-routines or resumable exceptions with his code (which is why set/longjmp attracted him, he could branch from an arbitrary lump of code back to another arbitrary lump). Exceptions are just good for a one way trip up the call stack.
Oh, and as an aside - if you use C++ exceptions follow the rule "throw by value, catch by reference." The last thing you want to be doing is resource management when you're trying to handle exceptions - it's complete madness. And if you think I'm talking complete rubbish consider what happens if printSomething throws - you'll leak a pointer to a TException object.
And I've just noticed you're using that cardinal sin void main(). Guess what? That doesn't compile on any standard conforming C++ compiler. Use one of the two standard forms instead:
int main()
or:
int main( int argv, char *argv[] )
Ash
|
|
|
|
|
Thanks your pointing out.
That was a Java style coding. In c++, ordinarily;
throw TException("func1");
catch(TException& e) {
}
And I know void main is not compatible in c++.
That was only concept codes, but may not be so good example.
|
|
|
|
|
The Java style of exceptions was actually around a couple of years before Java first came out. Microsoft had an exception handling mechanism in MFC 1 and 2 that threw by pointer and caught by pointer requiring the caller to delete the exceptions. It also used setjmp and longjmp to transfer control despite all the problems with that. It's still there in MFC 19 years later (but uses real C++ exception handling these days).
The only reason I brought the point up was I didn't want another neophyte C++ programmer getting the idea that the correct way to throw and catch was some knackered old view of the world imposed by a second rate C++ compiler from 20 years ago. The poor souls have enough to cope with!
Cheers,
Ash
|
|
|
|
|
In which scenario,Sendmessage and Postmessage should be used?
Thanks,
|
|
|
|
|
You can send a standard Windows message or a user defined message using both SendMessage and PostMessage .
SendMessage will wait for the message handler to complete the action, whereas PostMessage will simply queue the message to the target window's message queue.
These APIs can be use to send messages to any window whether in the same process or not.
|
|
|
|
|
thanks. I want to know in which case we should use sendmessage and postmessage functions?
|
|
|
|
|
There can be many uses.
One such use is for simple interprocess communication like sending a WM_CLOSE message to an external application.
Another frequently used scenario is when you declare your own custom messages like WM_USER + 1 or WM_APP + 1 .
|
|
|
|
|
|
PostMessage places a message in the window's message queue and then returns without waiting for the corresponding window to process the message.
The SendMessage function calls the window procedure directly and does not return until that window procedure has processed the message.
--
"Programming is an art that fights back!"
|
|
|
|
|
as others wrote ist right.
I use PostMessage more for better user experience because it is non-blocking.
SendMessage only for critical message. It works like a callback.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
I want to devlop cutom radio button with images. I have two images. One is selected image and othe is unselected. I want to put those image on the radio button on their particular state(Selected and deselected). Can anybody help me how to achive this ?
Thanks
|
|
|
|
|
|
You might need a third image for focused state (maybe even four, one for focused /selected and one for focused/unselected)
|
|
|
|
|
Hi,
Could u please send me sample code.
|
|
|
|
|
But of course! Check this[^] out!
|
|
|
|
|
I didn't find any help from this link. As radio button doesnot support OwnerDarw, its difficult ot custumize it. I already drived one class from CButton nad wrote some code on OnCreate function. Now I want to put some image on the radio button. Can u please help me in this regards..
Thanks...
|
|
|
|
|
Hi,
VC++ 2008
The following function will return false because the registry path contains space between 'Windows' and 'NT':
BOOL OpenKey()
{
HKEY hKey = NULL;
hReg = RegOpenKey (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\Whatever", hKey);
if (hReg != ERROR_SUCCESS)
return FALSE;
}
Google failed me, any work around? thanks
|
|
|
|
|
From MSDN:
This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the RegOpenKeyEx[^] function.
Are you programming 16 bit Windows?
|
|
|
|
|
WOW, I really need to visit an eye doctor, that did the trick, thank you very much
|
|
|
|
|
Being slightly cynical the function will return FALSE as the only line with return on it is return FALSE;
Cheers,
Ash
|
|
|
|
|
pubis wrote: HKEY hKey = NULL;
hReg = RegOpenKey (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\Whatever", hKey);
if (hReg != ERROR_SUCCESS)
return FALSE
why don't you utilize CRegKey class for handlling registry operation!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
If RegOpenkey() fails, the return value is a nonzero error code. So what value does hReg have?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this...
Thanks in Advance...
|
|
|
|
|
The language provides the sizeof operator [^], please use it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Pardhu2 wrote: I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this...
if it string,it would 1 byte per char!
if it int, it would be 4 byte per variable!
Shoot me down, if i am wrong!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|