All the magic is done via one important Windows API function
You create a non-rectangular region and call this function on some HWND when a handle of some window is already created. This make "real" non-rectangular window, not only visually, but observable via mouse hits. Don't mix it up with tricks performed on DC clip regions: they only give some visual effect, but the actual window, by a mouse hit test, is still rectangular.
I found a short manual, just to see what's involved: http://www.codeguru.com/cpp/w-d/dislog/non-rectangulardialogs/article.php/c5037/Creating-Shaped-Windows-Using-Regions-with-Win32.htm
There is no a problem to do it with MFC, which is tightly coupled with raw Windows API and based on it. Anyway, HWND window handle for controls is always accessible.