Silverfrost Forums

Welcome to our forums

DISPLAY_DIB_BLOCK@ and mouse

9 Dec 2022 1:57 #29684

I have a simple program that reads and displays an image file using DISPLAY_DIB_BLOCK@. It works just fine.

I now want to use the mouse to get a few pixel positions in the image, but seem to be caught in a catch-22. If I call clearwin_info@ to get the mouse flags and the x and y coordinates before the widow is closed, I don't see the image or the mouse cursor. If I close the image window first, then I can't get the mouse position and the program hangs.

...
kontrol = 0
i=winio@('%gr%lw&',nx1,ny1,kontrol)
CALL display_dib_block@(0,0,dib,nx1,ny1,0,0,nx1,ny1,0,0,ierr)
i=winio@('%nl%^bt[CLOSE]','EXIT')
iflags=0
10  iflags = clearwin_info@ ('GRAPHICS_MOUSE_FLAGS') 
if (iflags.ne.1) goto 10
mousex = clearwin_info@ ('GRAPHICS_MOUSE_X')
mousey = clearwin_info@ ('GRAPHICS_MOUSE_Y')
...

nx1, ny1 are the image dimensions that I got from a previous call to get_dib_size@ and the image file itself was imported using get_dib_block@

What am I doing wrong?

9 Dec 2022 3:14 #29685

Normally you would call clearwin_info@ from a callback function, in this case it would be attached to %gr using %^gr

integer,external::cbfunc

i=winio@('%^gr%lw&',nx1,ny1,cbfunc,kontrol)

9 Dec 2022 3:46 #29686

Many thanks, Paul. Yes, something stirs in my memory. I did this once before. This is the problem when coding only intermittently over a period of many years! I shall give that a try.

Please login to reply.