When you have a dialog based app, and you don’t want it to close, what most people do is to override the handler for the
IDCANCEL button and comment out the call to
CDialog::OnCancel() which calls
CDialog::EndDialog(...) which then calls the
EndDialog API call. Now this is all fine except that the dialog won’t close if you click the top-right [x] button or if you press Alt-F4, and this can be confusing to the end-user since all windows are expected to close if you attempt one of the above. The solution is to also handle the
WM_CLOSE handler and to call
CDialog::OnCancel() from it as shown below :-
If you are wondering about this behavior, what happens is that when the default dialog box procedure gets a
WM_CLOSE message, it posts a
WM_COMMAND) message to the dialog box passing
IDCANCEL as the control id. Now this means that
OnBnClickedCancel (or whatever you called it) gets called and since this does not call
CDialog::OnCancel, the dialog just stays there like nothing ever happened.
I still remember fighting to hold back the tears when Goran lost the 5th set to Agassi in the ‘92 Wimbledon; also remember the straight sets loss to Sampras in ‘94 and then that 5-setter in ‘98 again to Sampras. It was really awful for Goran fans, the man who possessed the most destructive and unreturnable serve in the history of tennis might finish his career as the greatest player never to win a Grand Slam. Then, in 2001 when he beat Pat Rafter of Australia, the whole world heaved a sigh – Goran had finally overcome his greatest enemy – his temperament – and managed to win 7 straight games on the grass of Wimbledon. At the end of the match he said he didn’t care if he never won another match in his life – he was happy, happy like a child who had got his candy, and so were we all, exultant fans rejoicing for Goran.
Goran was never a perfect player, but everyone feared him, from the returning greats like Agassi and Chang to the scud-servers like Becker and Sampras. In fact Sampras has often stated how Goran was one of the toughest opponents he faced due to his astonishing unpredictability. You never know if he was going to play the worst tennis he can play, or win all service games love with that unplayable serve of his. I vaguely remember the 1990 Wimbledon, or it might have been some other grass court tournament, when Goran was down love-40 and on a second serve hit an ace and then 4 more to win the game, and continued on in that vein till he had the match.
Mom always wondered why I should almost break into tears and be totally depressed for a few days whenever he lost. She used to tell me that she couldn’t even pronounce his country – Croatia. I used to tell her that I don’t know why and to be honest I didn’t. Maybe it was because I empathized fully well with Goran’s moods, maybe because I myself am a very temperamental person or so they all tell me, those who know me. 2 days ago I watched with a choking feeling in my throat, as Goran played his last match on Wimbledon and lost to Leyton Hewitt in the third round, on centre court. Everyone bid him an emotional farewell, the crowds, his opponents and the press – including the British press who adored Goran. The press loved Goran, not because of his brilliant sarcasm and humor, not because on his day he could blast off the world’s best, but because he was Goran Ivanisevic. There will never ever be another like Goran in tennis, never ever, because some people are born unique, and it was so with Goran Ivanisevic, the volatile tennis great from Split, Croatia.
I was reading Brian Johnson’s Weblog and there was a comment by Ramon de Klein where he expressed unhappiness with the addition of so many new keywords in C++/CLI. I replied to Ramon saying that there were essentially just three new keywords that might clash with existing code –
And just to prove my point I typed in a simple
for loop into a test program and used some of the contextual identifiers as variable names. It compiled of course, but what made the whole thing funny was that the VC++ syntax colorizer was not able to identify their context and showed them in blue (as keywords) and this obviously produced some curious looking color-formatted code.
My blog’s syntax colorizer (developed by Jambo Johnson) also results in the same funny looking code and I thought I’d include it here for you all to see
int finally = 0;
int delegate = 6;
for(int abstract=0; abstract<10; abstract++)
finally += abstract * delegate;
You will indentify the humor only if you’ve used VC++ for a while now and are used to the syntax colorizer, because only then will the fact that everything is in blue (keyword color) will strike you flat on your face😀
I’ve finally got around to writing another C++/CLI article for CodeProject.
Function overriding in C++/CLI
The article covers the new function overriding features available in C++/CLI like explicit overriding, renamed overriding and multiple overriding. It also shows you how to use the
Recently this question came up in the Microsoft MFC Newsgroup, where someone was porting an MFC app to pure-API, and wanted to know what the
PreTranslateMessage equivalent was for the pure-API application. Essentially all you need to do is to put your code just before the
TranslateMessage call, as shown in the code snippet below :-
// Main message loop
while (GetMessage(&msg, NULL, 0, 0))
msg.hwnd, hAccelTable, &msg))
//Put your PreTranslateMessage stuff here
Or if you don’t want to do that, you could do this as well, though it seems less elegant :-
LRESULT CALLBACK WndProc(HWND hWnd,
UINT message, WPARAM wParam, LPARAM lParam)
//Put your PreTranslateMessage stuff here
message, wParam, lParam);
The basic thing to remember is that, there is no message called
PreTranslateMessage in Win32.
PreTranslateMessage is something the MFC developers added so that we have an option to do something before a call is made to
DispatchMessage; and incidentally, some Win32 Gurus like Joe Newcomer for instance, are quite vocal about their opinion that using
PreTranslateMessage is bad style.
I admit to having a gmail account of my own, just like most of you guys do. And I also admit to experiencing a substantially pleasurable mood when I did get my own gmail account. But now that I have it, I don’t really use it. At my bandwidth (or rather the lack of bandwidth), web mail is not usable for any professional or meaningful purpose. And considering that gmail does not offer an IMAP/POP interface for fetching mail, the only purpose I seem to have for my gmail account is to use it as a sort of online brief-case folder (like the one we had in Win95 before MS scrapped it).
I am also sure that most people have their own domain names and therefore their custom mail IDs, often having 200 MB to 2 GB of POP space, and for people who have their own servers on an ISP’s shared or unshared server rack, the POP limit is the free space on the hard disk partition containing the mail spool folder. So, why is it that people make such a big deal out of a gmail account? Yahoo upped their free mail space to 100 MB, and their paid Plus users have 2 GB of POP mail space now. Redif-India upped their free mailbox to 1 GB and paid users get 2 GB. But those sites don’t get the same kind of buzz that gmail does.
Here is what my friend and fellow-MVP Doctor Pavanaja had to say on gmail :-
What is so great about a gmail account? Is it the promised 1 GB mail box? Why should people be fascinated by some firstname.lastname@example.org account when they can have their own domain mails with POP access? I have my own domain, I can download the mails and keep them in my laptop, carry them around; read them in airports, while traveling in a flight etc. These are not possible with gmail. Every time, I have to be online to do anything with the mail.
So am I right in concluding that gmail is just a fashion statement? And a very strong one at that? Your thoughts on this are appreciated.
It was a little past 9:30 PM, and I was driving back home from the restaurant from where I had my supper, which incidentally consisted of curd-rice, two cups of coffee and a glass of pomegranate juice – yeah, yeah I know it’s a weird sort of supper to have. It was drizzling heavily enough for people to take shelter under bus-stops but not heavily enough to make driving difficult in the slightest way. For some reason, I felt like taking a longer drive home and so I just drove around the Trivandrum city main roads, and also played my Roxette CD just to bring in a bit of music. The same roads which were so clogged with traffic during day-time, that even a 1 KM stretch took about 10 minutes, 3 stops and 2 traffic lights, were mostly devoid of traffic of any kind. The darkness and the rain helped hide the dirty footpaths and open drainage gutters on the sides of the roads and all of a sudden, the typically dirty and uninspiring Trivandrum city roads became a sort of charming sensation of beauty for me.
I must have drove all over the main part of the city and covered about 20-25 KM, since I did manage to listen to 4-5 Roxette tracks in the mean time. Once in an odd while, some nasty driver’s rude high beam blinded me temporarily and left me seeing blurred light blots on my wind shield, but I only smiled sweetly back at them rather than swear at them with all my vocal might as I am usually prone to do. I really wish I had my camera with me though I am not really sure if any camera would have captured tonight’s beauty, for I feel tonight was something very special, and I am very much scared that tomorrow – I might not see things in the same lovely manner as I did tonight. I felt very warm and comfortable as I reached home finally – I am not sure how I reached home, but abruptly I found myself very near my apartment and must have subconsciously turned the right way. I’ve always been in love with my home-town, but tonight was the first time she kissed me goodnight.