Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PolyPolygon event

Status
Not open for further replies.

boguSY

Programmer
Jan 22, 2006
2
RO
For more than one polygon drawing on a form, how can I write a diferent event for each polygon (or region)???
 
Can you explain, please? Can't get what you are trying to do.

buho (A).

 
I have a TImage component that I want to divided in "n" polygonal region. When I draw a point on TImage.Canvas, I want to recive a message, that depends of the region who included the point.

(Sorry for my english)
 
I'll assume:

a) your own code is writing in the regions and for some reason I can't understand you want to generate messages.

b) the messages are sent to a form and not to a windowless thread.

Define a message like:

Code:
const
  WMU_RegionDirty = WM_USER + 100; // WParam = region number.

In your form interface:
Code:
type
  TMyForm = class(TForm)
  ...
  private
  procedure WMURegionDirty(var M : TMessage); message WMU_RegionDirty;
  ...
  end;

In your form implementation:

Code:
procedure TMyForm.WMURegionDirty(var M : TMessage);
  var
    Region : integer;
  begin
    Region := M.WParam;
    //Do whatever you need here
  end;

In your drawing code:

Code:
procedure DrawAndSignal(FormHandle : THandle; ....);
  var
    Region : integer;
  begin
  // Draw, identify the region and load the code in 
  // the var Region.
  PostMessage(FormHandle, WMU_RegionDirty, Region, 0);
  {You can use SendMessage too. Check the differences
  between Send and Post in the SDK. Can't know what is
  better for you here.}
  end;

Out of curiosity: why a message? A Delphi event is not enough?

HTH.
buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top