Silverfrost Forums

Welcome to our forums

Various Problems with Clearwin - (1) getting mouse data

29 May 2005 5:41 #175

Hi there,

running my programs I encounter a few problems, where clearwin behaves differently from what I expect it to do. I would appreciate any support to get a starting point where to start my bugsearch.

I am running clearwin in a MS XP-home edition environment, SP 1 included (not SP2).

Here is the first one, concerning the mouse. I boiled down a far bigger routine to that few lines of code still showing my problem:

(1) include <windows.ins> (2) ictrl=0 (3) iwin=winio@('%gr[grey]&',400,200) (4) iwin=winio@('%lw',ictrl) (5)10 call get_mouse_info@(ix,iy,iflag) (6) print*,ix,iy,iflag (7) if(iflag.eq.0) then (8) call sleep@(0.5) (9) goto 10 (10) endif (11) stop (12) end

The idea is, I want to get info on the cursor position at any time the cursor is inside of the graphic window.

From what I get from the docs about get_mouse_info I would expect to receive ix and iy any time get_mouse_position is called, each .2 seconds here. After some time with the mouse in the graphic window I should expect a number of printouts in the textwindow, giving cursor positions.

Without line# 4, I only get a printout after I clicked lmb, otherwise the whole program seems to be on hold.

With line #4 (and the appropriate & in line #3) I get a series of prints, but all being 0, unless lmb is pressed.

Oh by the way, I am one of the fossils relying on implicit data types, that's why ix, iy, iflag are integers.

Any ideas ??

Norbert

30 May 2005 9:40 #177

Thanks Sten,

it sure is of some comfort to know not to be the only one to have such problems. You know, you would start thinking what makes you different from the rest of the users, them being happy using this stuff and only stupid me ...

Well, I will work through your hints one after the other and will give some feedbeack on what did succeed (that's optimism, isn't it ?).

Norbert

1 Jun 2005 8:38 #180

Norbert,

The documentation for get_mouse_info@ (in the FTN95 manual) states that it should only be used inside a %gr callback routine. However, contrary to this, it seems you can actually use the routine wherever you like as long as you specify the full_mouse_input option for the %gr.

Martin

4 Jun 2005 6:57 #181

Martin,

thank you, this one did it. I get all the mouse info I want any time get_mouse_info is called, when full_mouse_input is specified as option for the grahics window. 😃 😃 😃

Norbert

8 Jun 2005 1:39 #185

Here is some sample code that may help.....

  winapp

c--------------------------------------------------------------- include <windows.ins> integer mstat character30 cstat common/control/ mstat,cstat integer i,gr_func external gr_func cstat=' ' mstat=0 i=winio@('%ww[no_border]&') i=winio@('%ca[Box Selection]&') i=winio@('%mn[E&xit]&','EXIT') i=winio@('%ob&') i=winio@('%^gr[black,box_selection,full_mouse_input]&', + 300,300,gr_func) c See also set_graphics_selection@ i=winio@('%cb&') i=winio@('%ob[status]%20st%cb',cstat) end c----------------------------------------------------------- integer function gr_func() include <windows.ins> integer mstat character30 cstat common/control/ mstat,cstat integer x1,y1,x2,y2,nstat,a,b call get_mouse_info@(x1,y1,nstat) write(cstat(1:30),'(3I7)') x1,y1,nstat call window_update@(cstat) if(and(nstat,MK_LBUTTON).eq.0.and.and(mstat,MK_LBUTTON).ne.0)then call get_graphics_selected_area@(x1,y1,x2,y2) if(and(nstat,MK_SHIFT).eq.MK_SHIFT) then call rectangle@(x1,y1,x2,y2,12) elseif(and(nstat,MK_CONTROL).eq.MK_CONTROL) then a=0.5*(x2-x1) b=0.5*(y2-y1) call ellipse@(x1+a,y1+b,a,b,12) else call draw_line@(x1,y1,x2,y2,12) endif endif mstat=nstat gr_func=2 end

c-----------------------------------------------------------

11 Jun 2005 7:23 #189

Thanks Paul,

I did test your code and it works fine. I will try to adapt my coding to this example and see how far I can get with this. Maybe all the other problems I have encountered - and was about to post here - will be solved along with this one here.

Thanks again.

Norbert

Please login to reply.