home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / os2 / programm / 3935 < prev    next >
Encoding:
Internet Message Format  |  1992-07-31  |  1.8 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!src.honeywell.com!mail-enters-news
  2. From: bergstro@src.honeywell.com (Pete Bergstrom)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Summary: how to give program the focus
  5. Message-ID: <9207311741.AA21159@data.src.honeywell.com>
  6. Date: 31 Jul 92 17:41:12 GMT
  7. Sender: daemon@src.honeywell.com
  8. Organization: Honeywell Systems & Research Center
  9. Lines: 39
  10. To: comp.os.os2.programmer
  11. Posted-Date: Fri, 31 Jul 92 12: 41:12 CDT
  12. Received-Date: Fri, 31 Jul 92 12: 41:14 CDT
  13.  
  14.  
  15. Thanks for the responses.  Several hours after posting the original question,
  16. I got back home and tried out a hunch and it turned out to be mostly
  17. correct.  Michael Harris pointed out the rest of the solution.
  18.  
  19. The scenario:
  20.   In my application, I want to capture the position of the mouse when
  21.   the user clicks a button.  If I simply record the position
  22.   parameters and return (MRESULT)0, which indicates that I've
  23.   processed this message, the frame for the entire application loses
  24.   the focus, which means that I can't use the ALT-F, etc keystrokes to
  25.   access the menus.
  26.  
  27. The solution:
  28.   Call DefWindowProc() (whatever the default window message handler is
  29.   called ) *BEFORE* you fully process the WM_BUTTON1DOWN message.
  30.  
  31. For example, this might look like this: (details escape me at the
  32. present)
  33.  
  34.   ...
  35.   switch(...) {
  36.       case ... :
  37.  
  38.       case WM_BUTTON1DOWN:
  39.           defResult = DefWindowProc(hwnd,msg,mp1,mp2);
  40.       savedPointerPos.x = SHORT1FROMMP(mp1);
  41.       savedPointerPos.y = SHORT2FROMMP(mp1);
  42.       return defResult;
  43.       case ... :
  44.       ...
  45.   }
  46.   ...
  47.  
  48. This ordering guarantees that the application window will retain the
  49. focus (including coming to the foreground) and that you will also be
  50. able to process the mouse button click message.
  51.  
  52. Pete
  53.