[WD21] - Static Controls and Mouse Cursor

Startbeitrag von JP am 27.01.2017 08:05

Hi All

I have a window with a background image. Overlaid are several static controls. Static controls have no code options for handling mouse clicks. So I have click trapping code in the image control - left-button-up code. In this code I determine the x,y coordinates of the mouse click and determine if it was clicked over a static control. All works perfect.

Here is the issue: if you change the static control mouse cursor to a non-default cursor, e.g. the hand icon, then the mouse click is no longer received by the underlying image. It is consumed somehow by the static control even though the static control has no code options for processing mouse clicks.

A little irritating since it would be nice to use the mouse hand icon to indicate to users that the static control can be clicked on ... :(

Antworten:

JP,

in situations like this I replace the static control with a button control and make that button look like a static one.
But if you have a lot of those statics you have some work to do...

von Arie - am 27.01.2017 08:15
Hi JP,

You could make it work this way. The cursor style you've defined will be kept.

In the Initialize of your window :

WM_LBUTTONDOWN is int = 513
Event(ControlClicked, ".*", WM_LBUTTONDOWN)


Make a local procedure ControlClicked with this code :

PROCEDURE ControlClicked()
IF ControlOver() = "Static1" THEN
Info("Click on Static1")
END

Regards,
Bart

von Bart VDE - am 27.01.2017 09:15
Bart,

Thanks for this. Very cool solution which I have now implemented.

von JP - am 27.01.2017 13:21
Arie,

Thanks for the suggestion. I shall use this in future I'm sure.

Regards

von JP - am 27.01.2017 13:22
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.