home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / CHKEVENT.PRG < prev    next >
Text File  |  1993-05-11  |  3KB  |  108 lines

  1. //    chkevent.prg - check/handle events
  2. //
  3. //    Written by:    John M. Skelton, 27-Aug-92.
  4. //
  5. //    Copyright (C) 1992 Skelton Software, Kendal Cottage, Hillam, Leeds LS25 5HP, UK.
  6. //    All Rights Reserved.
  7.  
  8.  
  9. #include "windows.ch"
  10.  
  11.  
  12. external errorsys        // remove this if you don't want it!
  13.  
  14.  
  15. function ChkEvent()        // --> nEvent
  16. local    ev, hWnd, hMenu, nId
  17. do while .t.
  18.     ev = _ChkEvent()
  19.     if ev == EVENT_NONE
  20.         exit
  21.     endif
  22.  
  23.     // can do mapping in here
  24.  
  25.     if ev == EVENT_MENU
  26.         // handle menu selection immediately
  27.         SelectWindow(hWnd := _LasthWnd())
  28.         ExecuteMenu(hWnd, _LastwParam())
  29.     elseif ev == EVENT_ACCELKEY
  30.         if (hMenu := GetMenu(hWnd := _LasthWnd())) == nil
  31.             // hWnd has no menu, try to default
  32.             hMenu = GetMenu()
  33.             hWnd = nil
  34.         endif
  35.         if hMenu != nil                    ;
  36.            .and. GetMenuId(hMenu, nId := _LastwParam()) != nil
  37.             // handle menu selection immediately
  38.             SelectWindow(hWnd)
  39.             ExecuteMenu(hWnd, nId)
  40.         else
  41.             // an accelerator, but not for any obvious menu
  42.             exit        // return the event to the caller
  43.         endif
  44. //    elseif ev == ...
  45. //        // ...
  46.     else
  47.         exit
  48.     endif
  49. enddo
  50.  
  51. //
  52. //  At this point, _LastMsg(), _LastwParam() and _LastlParam(), together
  53. //  with the other functions mentioned, have other useful information,
  54. //  as follows:
  55. //
  56. // event type:            other info:
  57. //
  58. //    EVENT_KEY        inkey()        the keystroke
  59. //
  60. //    EVENT_LCLICK        MouseX(), MouseY()    the x,y position
  61. //                MouseRow(), MouseCol()    the row,col position
  62. //    EVENT_LDBLCLK \
  63. //    EVENT_RCLICK   \
  64. //    EVENT_RDBLCLK   >---    see EVENT_LCLICK
  65. //    EVENT_MCLICK   /
  66. //    EVENT_MDBLCLK /
  67. //
  68. //    EVENT_REDRAW        none; just re-draw the client area
  69. //
  70. //    EVENT_SETFOCUS        none; window is being given input focus
  71. //
  72. //    EVENT_KILLFOCUS        none; window is losing input focus
  73. //
  74. //    EVENT_WINMOVE        _LastLolParam() is the x position
  75. //                _LastHilParam() is the y position
  76. //
  77. //    EVENT_WINSIZE        _LastLolParam() is the new width in pixels
  78. //                _LastHilParam() is the new height in pixels
  79. //
  80. //    EVENT_CONTROL        _LastwParam()    the control's id
  81. //
  82. //    EVENT_HSCROLL        _LastwParam()    the scrollbar code
  83. //                        (one of the SB_* values)
  84. //
  85. //    EVENT_VSCROLL        _LastwParam()    the scrollbar code
  86. //                        (one of the SB_* values)
  87.  
  88. return ev
  89.  
  90.  
  91.  
  92. function Event()
  93. local    ev := _LastEvent()
  94. // can do mapping in here
  95. return ev
  96.  
  97.  
  98. // mouse X when click occurred - now written in C
  99. //function MouseX()
  100. //return _LastLolParam()
  101.  
  102. // mouse Y when click occurred - now written in C
  103. //function MouseY()
  104. //return _LastHilParam()
  105.  
  106. // Also: MouseRow() and MouseCol() give row and col position
  107.  
  108.