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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending a Click message to a Button

Status
Not open for further replies.

lobOnline

Programmer
Apr 5, 2001
12
NL
Hi,

I have some code that at a certain points wants to kill it's own object.

A simple delete can't do the work here because the code will return to the object which by then has been destroyed. This way will automaticly generate an EAccessViolation.

I figured out how I could do this properly with windows messages. I have a button which deletes the object also, so I thought I could message a click to that button so the object will be deleted after my code returns. I tried it with SendMessage, but I don't now what exactly to send. Is the HWND the handle of the form the button is on or the button handle? I know I should send an WM_LBUTTONUP.

Anybody that knows how to send this message?
 
Greetinx!

1. To send message to obkect, you may use TObject's method of 'Dispatch' of the button.
2. Also you may find out HWND parameter of the button, and then sent to button messages like WM_LBUTTONUP, using WinAPI-functions of 'SendMessage' or 'PostMessage'.

PS: Exception is thrown due to you access to the button after that has been deleted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top