home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / mwatch / mwatch.txt < prev   
Text File  |  1992-08-12  |  4KB  |  88 lines

  1. MWATCH.DLL
  2. DLL to monitor the position of the mouse and provide dynamic feedback
  3. to the VB programmer, primarily in the context of providing a status
  4. bar for the user.
  5. By Jonathan Zuck
  6. Copyright 1992 User Friendly, Inc. and Jonathan Zuck
  7.  
  8. Liscence:
  9.         You are hearby liscensed to use MWATCH.DLL freely within your
  10. own programs, paying no royalties to UFI or Jonathan Zuck. There is
  11. only one caveat: IF YOU DISTRIBUTE YOUR SOURCE, you MUST also 
  12. distribute this text file, explaining the usage of the DLL.
  13.  
  14. The Problem:
  15.         A number of people have asked for a way to provide a status
  16. bar for the user, depending on the position of the mouse. There are
  17. two aspects to this. First, it is necessary to know when a menu item
  18. has been highlighted by the user (althought not yet selected). Both
  19. MS EXCEL and MS WORD for WINDOWS provide a short help prompt depending
  20. on which menu item is highlighted.
  21.         The second part of this task is to provide some help prompt
  22. when the mouse is hovering over a particular control. While the
  23. Mouse_Enter event is available under HyperCard and Toolbook, it is
  24. missing from VB (and from Windows, in general).
  25.  
  26. The Solution:
  27.         As you might guess, MWATCH.DLL is the solution!<g>...or at 
  28. least a partial one. Once you register your Form with MWATCH, a
  29. Form_KeyDown event will be triggered every time the cursor is
  30. someplace different, either over a new control or in a menu. If
  31. the cursor has been moved over a control, the hWnd of that control
  32. is passed to the _KeyDown event in the KeyCode parameter. If a menu
  33. item has been selected than the Menu ID of that menu item is passed
  34. as a negative number in the KeyCode parameter.
  35.  
  36. The Cursor Enters a Control:
  37.         Once the cursor moves over a control, the Form_KeyDown event
  38. is triggered with the hWnd of the control in the KeyCode parameter, 
  39. as noted above. You can determine the hWnd of various controls at
  40. start-up, using various methods, including my CTLHWND.DLL and then
  41. use a Select Case loop to determine the help text to display.
  42.         Alternatively, MWATCH also exports a couple of useful utility
  43. functions to assist you: HWndCtlName and HWndTag. HWndCtlName$ will
  44. return the name of a control, given its hWnd and HWndTag will return
  45. the text in the .Tag property of the passed hWnd. Using this technique,
  46. you can either used a Select Case loop through the CtlName's to 
  47. determine the help text or, if you don't need the .Tag property for
  48. something else, the easiest thing is to put your help text in the .Tag
  49. property and simply use HWndTag to retrieve this text at run-time.
  50. Please see the sample app MENTER.MAK for demonstrates of these
  51. functions in context.
  52.  
  53. The Cursor Enters a Menu:
  54.         Once the cursor highlights a menu item (or it is triggered
  55. with the keyboard), the Form_KeyDown event is triggered with the
  56. MenuId in in the KeyCode parameter. Once again, you can check these
  57. once when you are finished designing your menu because they will be
  58. the same (except for the top-level menu heading) every time the app
  59. is run. You could then set up a Select Case statement to check KeyCode
  60. against various MenuIds.
  61.         Alternatively, MWATCH exports a function called: MenuCaption.
  62. The MenuCaption$ function takes a MenuId as a parameter and returns
  63. the caption of the menu item. See MENTER.MAK for an example of this
  64. function in use. PLEASE NOTE: the MenuCaption function was written
  65. specifically for this DLL to save you calling a bunch of Windows
  66. API functions and it WILL NOT work outside of your Form_KeyDown
  67. handler! The HWndCtlName and HWndTag functions can be used in other
  68. contexts but this is NOT THE CASE with the MenuCaption function.
  69.         Also, at this point, MWATCH doesn't generate an event when the
  70. user is in the system (or control) menu. I was just lazy. If a lot
  71. of people request it, I can add it.
  72. People Using HOTKEY.DLL
  73.         Many of you are using HOTKEY.DLL (which makes me happy, of 
  74. course!) and you are using your Form as the "hotkey handler." Since
  75. HOTKEY gives you a choice of hWnd's and MWATCH does not, you will
  76. need to copy your current Form_KeyDown code to a hidden Picture Box
  77. or something, if you want to use both DLLs.
  78.  
  79. Hope you find this useful! Enjoy! 
  80. -=- Jonathan Zuck 
  81. User Friendly, Inc.
  82. 1718 M Street, N.W.
  83. Suite 291
  84. Washington, DC 20036
  85. (202) 387-1949
  86. (202) 785-3607 FAX
  87. 76702,1605     CIS
  88.