What’s the difference between EM_UNDO and WM_UNDO?

Date:September 11, 2007 / year-entry #338
Tags:code
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20070911-00/?p=25183
Comments:    2
Summary:Daniel Chait wonders why we have both EM_UNDO and WM_UNDO. You know, I wonder the same thing. But I'm going to make an educated guess. Actually, most of what I write is just a lot of educated guessing. Like my explanation of why GetWindowText has such complicated rules? A guess. Why address space granularity is...

Daniel Chait wonders why we have both EM_UNDO and WM_UNDO. You know, I wonder the same thing. But I'm going to make an educated guess.

Actually, most of what I write is just a lot of educated guessing. Like my explanation of why GetWindowText has such complicated rules? A guess. Why address space granularity is 64KB? A guess. Why most EM_* messages are in the system message range? A guess. Mind you, it's logical guesswork, usually strongly guided by the principle of "Imagine if this were possible."

Today's guesswork: The history of EM_UNDO and WM_UNDO.

It seems obvious that EM_UNDO came first. After all, why would there need to be a EM_UNDO message if a WM_UNDO already existed?

At some point, somebody decided, "Hey, this sounds like something that people might want to do more generally." New messages WM_CUT, WM_COPY, WM_PASTE, WM_CLEAR, and WM_UNDO were added, and the first control to implement them was the edit control.

Therefore, the answer to the question is that for edit controls, the difference is that there is no difference.

The window manager does not provide a default implementation for any of these new messages. (Obviously, because the window manager is not psychic.) If you want your control to support those operations, you'll have to respond to the messages yourself.



*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index