How to add event handler for gdi+ drawn item

ymee
02-27-2004, 09:36 AM
Hi all,
I am drawing a rectangle and I want the user to be able to click on the rectangle and fire an event which will cause some other code to run. How do you add event handlers to objects you draw using gdi+
thanks

Bucky
02-27-2004, 01:01 PM
You can't. Store the rectangle in a module-level variable, and in the
MouseDown event of the control that the Rectangle is drawn on, use
the Contains() method to see if that point was inside the Rectangle.

There's a nice article about hit testing in MSDN titled "Hit Testing with a Region"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum