Access Violation with Finddragtarget

Asked

Viewed 29 times

0

I need to detect what kind of component the user clicked. For this I am using the following check, every time the left mouse button is clicked:

if FindDragTarget(Mouse.CursorPos, True).ClassType = TEdit then
//Código

However, when the user clicks on the virtual keyboard of windows and its keys, I get the message from Access Violation; I imagine it is because I am calling the function but it does not recognize the type of component. I am in the Windows 10 and my Delphi is the XE7; Maybe he doesn’t recognize the virtual keyboard component so he can’t do the verification. Anyway, there are other alternatives to check what type of component the user clicked?

1 answer

0


You are assuming that the Finddragtarget(Mouse.Cursorpos, True) function returns ALWAYS a value, which may not be happening.

You should check it out first, something like

ct:=FindDragTarget(Mouse.CursorPos, True);
if (ct<>nil) and (ct.classtype=TEdit) then
    ...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.