hung. Programs hang (or Program Not Responding). They are either waiting for
something that didn't happen or they are lost in some loop of code. If they
are truely wild they will crash, very soon, when they attempt something they
are not allowed to (the CPU knows and tells windows). Windows can make
guesses if a program has hung but can't know for sure. When Windows says a
program isn't responding then it is guessing becauuse Windows sent it a
message it needs answered (like we're shutting down) or the program hasn't
picked up it's messages for x number of seconds. Messages are things such as
user chose a menu, user moved the mouse, user pressed key, Windows is
shutting down, computer was docked, etc.
However the program may just have a lot of work to do and is poorly
programmed in not anticipating the time processing would take.
There are 2 smaller programs in a Windows program (plus resources such as
menus, icons, and text strings). The first runs when the program is loaded.
The second is then started and it basically just looks, over and over again,
to see if there are any new messages, and if so transfer control to whatever
subroutine it should. Say File Open menu is command 1
Is new message()
If yes then
If message = 1 then go do file open
If message = 2 then go do command 2
If message = 1 then go do [,,,]
If message = 1 then go do command n
End if
End
Programs only test for stuff they are interested in. Most messages have
Windows default handlers. If your program doesn't care (and a lot don't -
notepad doesn't) where the mouse cursor is (the most frequent message is
mouse has moved a little bit) then you just give the message back to windows
and as luck would have it windows can draw the mouse if needed. So a program
like notepad Only picks up menu clicks and movements solely to know what to
write in the status bar for the menu item help text. Most programs get the
end result of the users interaction with the menu. Run Command 1 - File -
Open.
So a program could get it's mouse moved messages (lots and lots a second),
as paint and word processors do (especially to set different cursor shapes
like text select over text and pointer over clickable things). They could
work out where the menu is and if the mouse is over it, and if the user also
clicked. Then translate it to it's internal command (#1 is the example we've
been using).
Or it could ignore these, and just respond to menus being highlighted and
clicked. Then it would need to handle translating menus (either by position
or menu text) to commands, dispatch the commands.
Or is could just answer the high level messages that say what command
attached to a menu was chosen. The program gets all three. This way is
almost no work for the programmer. The other two ways a a little more (maybe
three times as much) and lots and lots more.