Showing results for 
Search instead for 
Did you mean: 

Image clicable labwindow

Go to solution



Je cherche à rendre une image chargée grâce à DisplayImageFile(panel, PANEL_PICTURE, file_path); clicable.

C'est en réalité une image GPS, je voudrais ensuite demandé à l'utilisateur de cliquer sur les quatres extrémités puis qu'il entre les coordonnées GPS des quatres points cliqués.


Je ne sais pas trop comment faire. Enregistrer chaque pixel dans un tableau de bouton transparent ?


Merci d'avance

0 Kudos
Message 1 of 5

Hello, I'll answer in English, as I do not speak French...


You can install a callback in the picture control and respond to EVENT_CLICK event: with GetRelativeMouseState you can obtain the mouse coordinates of the clicked pixel. You'll have to remap those coordinates according to the scaling between your original image and the (possibly scaled) image in the control, next you'll have to remap those coordinates to GPS data or do what you want on them.

Please note that coordinates returned by the function are relative to the top, left corner of the control and increase respectively downward and rightward.


You can have some operative suggestion looking at the example <CVI sample folder>\userint\canvas.prj: here in a timer control the mouse coordinates are used to draw on a canvas.

Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5

Thanks for your answer !


The problem is that I don't know how my picture can wait an EVENT.

To load my picture I use :


FileSelectPopup ("", "*.jpg", "*.*", "Charger une carte", VAL_LOAD_BUTTON, 0, 0, 1, 0, file_path)
//Récupération de l'image
GetBitmapFromFile (file_path, &image_GPS);
//Affiche l'image
DisplayImageFile(panel, PANEL_PICTURE, file_path);

0 Kudos
Message 3 of 5
Accepted by topic author ZazOufUmI

Even if the picture control can be set only in indicator mode, its callback can still respond to some events: among them EVENT_LEFT_CLICK event can be used to intercept user actions on the image.

You can easily see which event a picture control can respond to by right-clicking it in the UIR editor and selecting "Control help" in the context menu, next "Picture control events" in the help page that is shown this way; this procedure is valid for each control.


Just as a side note, in the code you posted GetBitmapFromFile is not needed as you are not using the resulting bitmap. In case you need it for other parts of your program, remember to free associated resources with DiscardBitmap when you no longer need it: this may be beneficial in case you want to treat more images one after the other as you will avoid memory leaks due to resources allocated and not freed.

Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 5

Thank you for your help 🙂

0 Kudos
Message 5 of 5