forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question concerning use of %gr

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
dgurok



Joined: 26 May 2011
Posts: 37

PostPosted: Wed Feb 24, 2016 11:56 am    Post subject: Question concerning use of %gr Reply with quote

I would like to know if it is possible to figure out if my mouse cursor is outside of a graphic region (%gr).

The callback of %gr is always recognized when the mouse curser is in the graphic region. How can I recognize if my mouse cursor is outside of a given graphic region?

I tried this with GET_MOUSE_INFO@ but this method is imprecise because it depends on how fast the mouse is moved out of the graphic area. The position x,y of GET_MOUSE_INFO is still in the graphic area although the current mouse cursur position is outside.

Code:

      PROGRAM TEST
C     
      include <windows.ins>
C     
      INTEGER ctrl,hnd1,f_test
      DATA hnd1 /1/
      external f_test
C
c
      i=winio@(
     * '%`^gr[rgb_colours,black,full_mouse_input]&',
     * 400L,400L,hnd1,f_test)     
      i=winio@('%ff%^bt[test]&',f_test)
      i=winio@('%ww%lw',ctrl)
      i=select_graphics_object@(hnd1)
      CALL draw_line_between@(100,100,300,200,RGB@(0,0,255))
C     
      END
     
     
      function f_test     
C     
      include <windows.ins>
C       
      integer*4 f_test,x,y,f
      integer*4 idum1,idum2,idum3,idum4,idum5,idum6,idum7,idum8
      CHARACTER*256 CDUM
      LOGICAL*2 LOGGRA
C
      CDUM=CLEARWIN_STRING@('CALLBACK_REASON')
      IDUM1=CLEARWIN_INFO@( 'CALL_BACK_WINDOW' )
      IDUM2=CLEARWIN_INFO@( 'CURSOR_WINDOW' )
      IDUM3=CLEARWIN_INFO@( 'FOCUS_WINDOW' )
      IDUM4=CLEARWIN_INFO@( 'GRAPHICS_HDC' )
      idum5=CLEARWIN_INFO@( 'LATEST_WINDOW' )
      idum6=CLEARWIN_INFO@( 'LOSING_FOCUS' )
      idum7=CLEARWIN_INFO@( 'GRAPHICS_MOUSE_X' )
      idum8=CLEARWIN_INFO@( 'GRAPHICS_MOUSE_Y' )
C
      LOGGRA=.TRUE.
C
      CALL GET_MOUSE_INFO@(X,Y,F)     
      if(X.LE.1) LOGGRA=.FALSE.
      if(Y.LE.1) LOGGRA=.FALSE.
      if(X.GE.399) LOGGRA=.FALSE.
      if(Y.GE.399) LOGGRA=.FALSE.
      if(idum3.eq.0)  LOGGRA=.FALSE.
C     
C      write(*,*) CDUM(1:12),x,y,f,idum1,idum2,idum3,idum4,idum5,idum6
      write(*,*) LOGGRA,idum1,idum2,idum3,idum4,idum5,idum6,idum7,idum8

      f_test=2
      end
C
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Wed Feb 24, 2016 1:14 pm    Post subject: Reply with quote

Part of the answer to your question is the additional question "Why do you need to know?" The reason for this is that until there is a click, the position of the mouse pointer is immaterial. If you have a callback to your %gr area, and you have not specified full_mouse_input, then the callback is only called when a click event is detected, and you do the necessary handling including getting the position of the mouse pointer when the click happened from within the callback (and of course in any subprograms that are called). You donít get the callback if the click is outside the %gr area.

If on the other hand you do have the full mouse input then you get far more invocations of the callback, including every little movement of the pointer. There are lots of discussions of this on the forum, and are regularly given piece of advice is to compare the cursor position with the previous position and simply throw it away if there is been no movement and no alteration of the button states. Once again, you will not get the callback invoked if the pointer lies outside the %gr area.

You probably also donít need to know where the mouse pointer is outside the %gr area because Windows will only do something if you go to another control and interact with it, and then the callback for that control is invoked.

There is one exception to the above, and that is if you are struggling to give a mouseover response to a toolbar icon of the %tb variety. Some years ago I requested a mouseover response, and Paul did implement it for %ib, because as you read the documentation you will see that %ib was intended to supplant %tb. Sadly, since Windows 8 and therefore in Windows 10 as well, necessary effects are not achievable with %ib, only with the older %tb. Iíve never been able to produce a mouseover effect with %tb except by invoking the pop-up help balloon, and Paul (having resisted my blandishments to do it for %tb before he got involved with the 64-bit version of FTN95) has probably got other things on his plate that are more urgent at the present.

If you do definitely need to know the position of the mouse pointer and whether or not it is in the %gr area, I suggest a search of past related discussions in the forum.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4883
Location: Salford, UK

PostPosted: Wed Feb 24, 2016 1:23 pm    Post subject: Reply with quote

The Windows API function GetCursor returns a handle to the current cursor and this will be different inside and outside of the region.

An interface for GetCursor can be found in win32api.ins.
The function returns a 32 bit integer for 32 bit applications and a 64 bit integer for 64 bit applications.
Back to top
View user's profile Send private message
dgurok



Joined: 26 May 2011
Posts: 37

PostPosted: Wed Feb 24, 2016 2:23 pm    Post subject: Reply with quote

Thx Paul, your workaround was very helpful. The behavior is now like we wish!

I use %mg in combination of %gr. In some cases I need to know if mouse cursor is inside or outside of %gr area. The mouse cursor position x and y outside of %gr area is not important in our case!

I want to switch automatically between Iím in ď%gr area modeĒ or ďnot %gr area modeĒ using mouse movement only.
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 526

PostPosted: Thu Feb 25, 2016 9:27 am    Post subject: Reply with quote

Quote:
The Windows API function GetCursor returns a handle to the current cursor and this will be different inside and outside of the region.


I'm lost as to why the cursor handle will be different depending on whether or not it is inside or outside of 'the' window.

On my PC I only have one cursor Wink

Is it a 'virtual cursor' handle . then ? i.e. does windohs internally change the handle depnding on where it floats over on the screen ?

And If so, how does one determine which is the 'original' window (the %gr one) handle ? .. .as I assume we're not clicking.

Isn't GetCursoePos needed instead/in combo with GetCursor ?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4883
Location: Salford, UK

PostPosted: Thu Feb 25, 2016 10:55 am    Post subject: Reply with quote

A cursor is stored as a form of image together with a "hotspot". As a file it normally has the extension .cur. Windows provides a number of standard cursors but one could use others.

In a program the image is represented by a HANDLE (basically a pointer). At a given moment, the cursor that is currently displayed (arrow, hand etc) will vary and GetCursor tells you which image (arrow etc) is being displayed.

In the case in point it is not necessary to identify the image from its HANDLE. All we need to know is that it changes when moving in and out of a %gr region.
Back to top
View user's profile Send private message
dgurok



Joined: 26 May 2011
Posts: 37

PostPosted: Thu Feb 25, 2016 11:08 am    Post subject: Reply with quote

I use GetCursor in two different callbacks now.
In the callback of %gr I use GetCursor which provides me the current handle of the mouse cursor (cross form) which is used in %gr area.
In another callback of %mg I use GetCursor similar and I compare if the handles are different.
This means now the mouse cursor is outside of the %gr area. This solution works well.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group