home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISPEED2.LZH / GEMDEMO / EVENTS.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-02  |  3KB  |  81 lines

  1. {-------------------------------------------------------------------------
  2.                 HighSpeed Pascal GEM-interface demo program
  3.  
  4.                             EVENT LIBRARY DEMO
  5.  
  6.                       Copyright (c) 1990 by D-House I
  7.                             All rights reserved
  8.  
  9.                       Programmed by Martin Eskildsen
  10. -------------------------------------------------------------------------}
  11. {$R-,S-,D+}
  12.  
  13. program Events;
  14.  
  15. uses GemAES, GemVDI, GemDecl, GemInterface;
  16.  
  17. const
  18.   Clicks        = 1;    { number of mouse clicks to wait for }
  19.   Mask          = 3;    { left and right mouse buttons       }
  20.   State         = Mask;
  21.  
  22. var
  23.   key           : Integer;      { evnt_keybd key scan code      }
  24.   s, s1         : String;       { multi-purpose                 }
  25.   x, y          : Integer;      { mouse x,y coordinate          }
  26.   buttons       : Integer;      { mouse button state            }
  27.   keys          : Integer;      { keyboard state (ALT, CTRL etc)}
  28.   times         : Integer;      { number of mouse clicks done   }
  29.   speed         : Integer;      { double click speed            }
  30.  
  31. begin
  32.   if Init_Gem then begin
  33.     Message('Welcome to the event library demonstration!');
  34.  
  35.     Inform('We''re waiting for a keyboard event...');
  36.     key := evnt_keybd;          { get scan code }
  37.     Str(key, s);
  38.     Message('The key''s scan code is : ' + s);
  39.  
  40.     Inform('Now we''re waiting for both mouse buttons...');
  41.     graf_mouse(M_ON, NIL);
  42.     times := evnt_button(Clicks, Mask, State, x, y, buttons, keys);
  43.     graf_mouse(M_OFF, NIL);
  44.     str(x, s);  str(y, s1);
  45.     s := 'Mouse (x,y) = (' + s + ',' + s1 + ')';
  46.     Message(s);
  47.  
  48.     Message('Please use the mouse to click "Ok" now!');
  49.     Inform('Try to enter the Output window');
  50.     OpenOutputWindow;
  51.     graf_mouse(M_ON, NIL);
  52.     with OutputWindow do
  53.       evnt_mouse(0, wX, wY, wW, wH, x, y, buttons, keys);
  54.     graf_mouse(M_OFF, NIL);
  55.     CloseOutputWindow;
  56.     str(x, s);  str(y, s1);
  57.     s := 'You entered the work area at (x,y) = (' + s + ',' + s1 + ')';
  58.     Message(s);
  59.  
  60.     Inform('Hang on 1.234 seconds!');
  61.     evnt_timer(LoWord(1234), HiWord(1234));
  62.  
  63.     Message('We''re back!');
  64.     Message('Now we''ll determine the mouse double click speed');
  65.     speed := evnt_dclick(0, 0);
  66.     case speed of
  67.       0 : s := 'slow';
  68.       1 : s := 'below medium';
  69.       2 : s := 'medium';
  70.       3 : s := 'above medium';
  71.       4 : s := 'fast'
  72.     else
  73.       s := 'Should never come here!'
  74.     end;
  75.     Message('The double click speed is "' + s + '"');
  76.     Message('That''s all folks!');
  77.  
  78.     Exit_Gem
  79.   end
  80. end.
  81.