home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!src.honeywell.com!mail-enters-news
- From: bergstro@src.honeywell.com (Pete Bergstrom)
- Newsgroups: comp.os.os2.programmer
- Subject: Summary: how to give program the focus
- Message-ID: <9207311741.AA21159@data.src.honeywell.com>
- Date: 31 Jul 92 17:41:12 GMT
- Sender: daemon@src.honeywell.com
- Organization: Honeywell Systems & Research Center
- Lines: 39
- To: comp.os.os2.programmer
- Posted-Date: Fri, 31 Jul 92 12: 41:12 CDT
- Received-Date: Fri, 31 Jul 92 12: 41:14 CDT
-
-
- Thanks for the responses. Several hours after posting the original question,
- I got back home and tried out a hunch and it turned out to be mostly
- correct. Michael Harris pointed out the rest of the solution.
-
- The scenario:
- In my application, I want to capture the position of the mouse when
- the user clicks a button. If I simply record the position
- parameters and return (MRESULT)0, which indicates that I've
- processed this message, the frame for the entire application loses
- the focus, which means that I can't use the ALT-F, etc keystrokes to
- access the menus.
-
- The solution:
- Call DefWindowProc() (whatever the default window message handler is
- called ) *BEFORE* you fully process the WM_BUTTON1DOWN message.
-
- For example, this might look like this: (details escape me at the
- present)
-
- ...
- switch(...) {
- case ... :
-
- case WM_BUTTON1DOWN:
- defResult = DefWindowProc(hwnd,msg,mp1,mp2);
- savedPointerPos.x = SHORT1FROMMP(mp1);
- savedPointerPos.y = SHORT2FROMMP(mp1);
- return defResult;
- case ... :
- ...
- }
- ...
-
- This ordering guarantees that the application window will retain the
- focus (including coming to the foreground) and that you will also be
- able to process the mouse button click message.
-
- Pete
-