A few people have asked about how I was able to make a game in a Notepad window, as seen in Notepad Weekend. I dug out the source code and cleaned it up into a framework of sorts, which I’m posting here in case any of you would find it interesting!
Download notepad_hijack_framework.cpp [3.3 kB]
The code is pretty simple, but will only work on Windows due to the extensive use of the Windows API. It uses FindWindowEx() to find an open Notepad window, SetWindowsHookEx() to set a keyboard hook so that we can catch keyboard events, and SendMessage(WM_SETTEXT) to set the text in the main text box in the Notepad window. If you wanted to launch an instance of Notepad instead of requiring the player to do it, you could presumably use ShellExecute().
Setting keyboard hooks alerts many AV because that used to be the way keyloggers worked.
So get a proper AV then.
Can you please compile this to a lib?