Yes, there's actually quite a large difference between a desktop application and a web application in this respect -- at least usually, though there are exceptions (e.g., Microsoft's Silverlight framework lets you do some things the same in a web app as you can in a desktop app).
How you connect things up on a desktop app varies widely. Raw Windows applications frequently include a giant switch statement based on the value of a "message". MFC uses what it calls Message Maps. Qt uses what it calls signals and slots.
It's probably worth mentioning, however, that in a typical case you don't really deal much with this in code. Most people let an IDE handle most of the details of connecting this up. It'll (typically) produce a skeleton function about like you have above (possibly with even more filled in to do things like calling parent class functions, etc.) so all you normally have to deal with directly is the //do some stuff
part.
Edit (in response to edit of question): a web page is probably the last thing you want to deal with right now. There's simply a huge range of variation in how you handle button events and such on web pages. In particular, you frequently get a combination of actions that happen inside the browser (e.g., in Javascript) and things that happen on the server (e.g., using AJAX). You can invoke functions on either the client, the server, or both, in response to a particular button click, etc., so this is actually quite a complex scenario in general.
While there's certainly variation between windowing systems and frameworks in desktop applications, at least the variation is over a rather smaller range.