August 4th, 2009

Programming means that sometimes you have to snap two blocks together

Part of the challenge of programming (and for some people, the reason why programming is fun in the first place) is looking at the building blocks provided to you and deciding how to assemble them to build something new. After all, if everything you wanted a program to do already existed ready-made, it wouldn’t be called programming any more. It would be called shopping.

Is there an API or a quick way to find out which window the mouse is in?

I replied, “The LEGO Group does not make a piece for every possible object. Sometimes you just have to take two LEGO blocks and click them together. Here are some interesting blocks: GetCursorPos, WindowFromPoint.”

Thanks for your reply. But WindowFromPoint gives me the window of the object at the location of the cursor. But I’m looking for the top level window containing the cursor.

Fine, then use a different block. I wonder how it is these people manage to write programs at all. I get the impression they write code by asking a million tiny questions and cutting and pasting together all the replies.

No wait, pasting together the replies counts as snapping blocks together. Maybe they just ask for completed programs.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.