12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

284 Day 8<br />

Table 8.3. cont<strong>in</strong>ued<br />

Event Description<br />

however, when the user switches forms or switches to another<br />

application.<br />

OnKeyDown This event is triggered when the user presses a key while the control<br />

has focus. Keys <strong>in</strong>clude all alphanumeric keys as well as keys such as<br />

the arrow keys, Home, End, Ctrl, and so on.<br />

OnKeyPress This event is also triggered when the user presses a key, but only when<br />

alphanumeric keys or the Tab, backspace, Enter, or Esc keys are<br />

pressed.<br />

OnKeyUp This event occurs whenever a key is released.<br />

OnMouseDown This event is triggered when the mouse button is pressed while over<br />

the component. The parameters passed to the event handler give you<br />

<strong>in</strong>formation on which mouse button was clicked, special keys that<br />

were pressed (Alt, Shift, Ctrl), and the x,y coord<strong>in</strong>ate of the mouse<br />

po<strong>in</strong>ter when the event occurred.<br />

OnMouseMove This event occurs any time the mouse is moved over the control.<br />

OnMouseUp This event is triggered when the mouse button is released while over a<br />

control. The mouse button must first have been clicked while on the<br />

control.<br />

OnPa<strong>in</strong>t This event is sent any time a component needs repa<strong>in</strong>t<strong>in</strong>g. You can<br />

respond to this event to do any custom pa<strong>in</strong>t<strong>in</strong>g a component<br />

requires.<br />

DEALING WITH MOUSE EVENTS<br />

Mouse events have a couple peculiarities that you should be aware of. If you are<br />

respond<strong>in</strong>g just to a mouse click on a component, you will want to keep it simple<br />

and only respond to the OnClick event. If you must use OnMouseDown and<br />

OnMouseUp, you should be aware that the OnClick event will be sent as well as the<br />

OnMouseDown and OnMouseUp events. For example, a s<strong>in</strong>gle click will result <strong>in</strong> these<br />

events occurr<strong>in</strong>g (and <strong>in</strong> this order):<br />

OnMouseDown<br />

OnClick<br />

OnMouseUp

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!