March 23rd, 2009

What’s the point of the MoveWindow function when we already have SetWindowPos?

Commenter Phil Quirk notes via the suggestion box, “MoveWindow is just a weird function. I guess it’s easier to call than SetWindowPos, but that’s the only thing it seems to have going for it.”

Yup, that’s about right.

The MoveWindow function doesn’t really do anything you couldn’t already do yourself with SetWindowPos. It’s just a convenience function. And it you look at it pretty closely, it’s really not that big of a convenience either, saving you one parameter (hwndInsertAfter) and replacing the flag SWP_NOREDRAW with a boolean parameter.

Whoop-dee-doo.

It shouldn’t take too much imagination to figure out how this situation came about. It’s the same reason why you have both CreateWindow and CreateWindowEx.

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.