Sample chapter from my C++/CLI book

Manning has something called MEAP (Manning Early Access Programme), where they make available unedited drafts of chapters for people who apply for MEAP. It’s not free, but they usually give one free MEAP chapter. My book’s chapter 1 is now available for free from the Manning MEAP page for my book (other MEAP chapters are available too, but those are not free). Interested folks can go to and read my first chapter for free (remember that this is an unedited draft though). Feel free to give me your feedback either via the Manning author forum or via this blog.


New article : Drag/Drop a non-existent file into Windows Explorer

Here’s an article I wrote for The Code Project that shows how you can drag and drop a virtual file (one that does not physically exist on disk) from your app into Windows Explorer. It’s useful for scenarios like extracting a file from an archive or where the source file is on a remote machine.

Microsoft on its way out from schools in Kerala

The Government of Kerala (my state in India) has passed a ruling that public schools in the state will base their computer curriculum entirely on Linux. Initially the idea was to give schools the option to choose between Microsoft and Linux, but later this was narrowed down to limiting any Microsoft related topics to that of migrating to Linux from Windows based operating systems. The state is currently ruled by a leftist party, and the leaders of the party are strong proponents of open source software, specially after a couple of visits by Richard Stallman in the last few years.

Now, personally, I feel that Linux is an excellent choice as an OS platform in high schools. It comes with an entire set of development tools, and while Microsoft gives away free editions of its compiler IDEs (the Express editions), they are limited in functionality, and the C++ version of the Express editions does not even support a resource editor. Also, the Linux OS comes with complete source code, and as a student, there can be nothing more exciting than to dig into the OS source code. And lastly, there are no installation costs for Linux (compared to Microsoft, even accounting for academic discounts). And in schools, there won’t be much of a maintenance cost either, because every school will have a few Linux geeks who’d help with maintaining the school network.

But, I still strongly disapprove of the decision to totally ban Microsoft software from schools. Kids should still have a choice, and they need to know that there are other options outside of Linux. By restricting them forcibly to a particular OS, without their explicit (or implicit for that matter) permission, you are virtually diminishing their chances of going into a successful professional career based on Microsoft products. The smarter geekier kids would obviously find their own way, and make their own choices, and would probably have multi-boot systems at home. It’s the ordinary kids that are doomed to a narrow career path due to a decision that was made by a short sighted government.

What’s ironic is that, just as RMS is losing popularity with most of the open source world, he’s gaining it in Kerala. And for all his principles of freedom, that’s the one thing that he’s helped to take away from Kerala’s school children – the freedom of choice. :hmmm:

ShowDialog and centering the window

I was using ShowDialog to show a Xaml window and was surprised to find that it wasn’t easy to get it to center on the calling Window. Setting the WindowStartupLocation property to CenterOwner did not seem to have much effect. That’s when I realized that the Owner has to be explicitly set. Now, I was calling ShowDialog from a Grid which was at least 5-6 levels nested in a parent Window, so I had to find the closest ancestor window that was a Window object. The code’s simple but I thought if anyone else wanted to center a dialog on screen, he could reuse this code. For all I know there might be an easier way to do this – probably some property or method that I missed. If so please let me know via a comment, so I can feel like an idiot. 🙂

DialogWin dwin = new DialogWin();

FrameworkElement fwElem = this;
while(!(fwElem is Window))
	if (!(fwElem is FrameworkElement))
	fwElem = fwElem.Parent as FrameworkElement;
if (fwElem is Window)
	dwin.WindowStartupLocation = WindowStartupLocation.CenterOwner;
	dwin.Owner = fwElem as Window;