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 

Getting the current mouse state

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



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Wed Aug 05, 2020 5:21 am    Post subject: Getting the current mouse state Reply with quote

I think I know the answer, but will ask it anyway.

Is there a way to get the state of the mouse (left, right,etc.) when a window is being moved?

I am trying to distinguish between the window being drawn and the user physically moving the window.

Thanks,
Bill
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Wed Aug 05, 2020 8:50 am    Post subject: Reply with quote

You could try using add_cursor_monitor@. This will enable you to track mouse move messages. An alternative is to use %mg with WM_MOUSEMOVE.
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Wed Aug 05, 2020 2:59 pm    Post subject: Reply with quote

Paul, I tried the %mg, and only was able to capture mouse movements in the client area, not the window border area. Stated another way, when the %mv callback function was activated, the callback function for mouse movement received no messages. I figured they were already processed by the system and the %mv function.

I'll look at add_cursor_monitor. Since there is not a "control" that is selected when the window is moved, I'm unsure how I might get the state of the mouse buttons using CLEARWIN_INFO@()
Back to top
View user's profile Send private message Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat Aug 08, 2020 3:27 am    Post subject: Reply with quote

I am also interested with the following functionality: suppose we have some window, you move this whole window with mouse into new place and close the window. Next time this window will be opened it will pop in this last position.

Current Clearwin facilities allow to do that only if you add one more step: after you move window to new place you also resize this window or run something from it (say you will implement additional button: "Save This Window State"). In this case its current position can be determined. You will then use this information to next time open window in this new position usual way with %sp or %ap
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Aug 08, 2020 7:57 am    Post subject: Reply with quote

Dan

You can probably do something with %cc together with a callback function that calls get_window_locatation@.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



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

PostPosted: Sat Aug 08, 2020 10:42 am    Post subject: Reply with quote

Dan,

I've been doing 'sticky windows' where Windows remember where they were when they were last closed and reopen there.

In my app I have 80 different windows. I store the coordinates of those windows in arrays in COMMON. Each dialog 'knows' which number it is. In this example, subroutine POP is No. 75.

Code:
       SUBROUTINE POP(TEXT)
C      --------------------
C
C      Pops up the text message sent as a parameter with an "Oops"
C      caption, denoting some sort of error. The box will pop up where
C      the previous POP box was.
C                                                                      .
C      -----------------------------------------------------------------
C                                                                      .
       INCLUDE <WINDOWS.INS>
       INTEGER, EXTERNAL ::  GET_POSITION_FN
       CHARACTER*(*) TEXT

       COMMON/PLACE/  IWINDPOS_X(80), IWINDPOS_Y(80)
       COMMON/STICKY/ NPOS, KHAND
C                                                                      .
       NSAVE = NPOS
       KSAVE = KHAND
       IA = WINIO@('%ca[Oops!]&')
       IA = WINIO@('%bg[white]&')
C
       NPOS = 75
       IA = WINIO@('%sp&', IWINDPOS_X(NPOS), IWINDPOS_Y(NPOS))
       IA = WINIO@('%hw%cc&', KHAND, GET_POSITION_FN)
       CALL SET_FONT_INFO
C
       IA = WINIO@('%cn%si!'//TEXT//'&')
       IA = WINIO@('%2nl%cn%`7bt[OK]')
       KHAND = KSAVE
       NPOS   = NSAVE
C
       RETURN
       END


You have to store the previous handle and dialog box type or you get in a muddle.

Code:
      INTEGER FUNCTION GET_POSITION_FN()
C     ----------------------------------
C
C     ... called on closure control %cc of a sticky window to get final
C         position, so window can be restored there when next opened.
C
C     ------------------------------------------------------------------
      COMMON  /PLACE/   IWINDPOS_X(80),     IWINDPOS_Y(80)
      COMMON  /STICKY/  NPOS,     KHAND
      COMMON  /FOR_NOW/ NSCREEN,  IXSCRN,   IYSCRN
      INCLUDE <WINDOWS.INS>
C     ------------------------------------------------------------------

      CALL GET_WINDOW_LOCATION@ (KHAND, IX, IY, IWID, IHT)
      IF (NPOS .GT. 0 .AND. NPOS .LE. 80) THEN
         IF (IX .GE. 1 .AND. IX .LE. IXSCRN-100) THEN
         IWINDPOS_X(NPOS) = IX
         ELSE

         IWINDPOS_X(NPOS) = 100
         ENDIF
         IF (IY .GE. 1 .AND. IY .LE. IYSCRN-100) THEN
         IWINDPOS_Y(NPOS) = IY
         ELSE

         IWINDPOS_Y(NPOS) = 100
         ENDIF
 
      ENDIF

      GET_POSITION_FN = 0                  ! Guarantees continue to exit
      RETURN
      END


continued ...
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Sat Aug 08, 2020 10:46 am    Post subject: Reply with quote

... continued

And also you have to make sure that the dialog pops up so that it is visible and/or movable, so it pays you to compare to the previously determined screen sizes.

Once you have a routine, it becomes second nature to make sure that all dialogs come back to where they were last closed.

Apologies for the inelegance of my examples.

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat Aug 08, 2020 6:00 pm    Post subject: Reply with quote

Thanks Eddie,
I know and use your method with your nice POP utility. It helps me to handle numerous warnings, errors and comments in the running code, as sometimes 4-5 of them run at the same time. As a results I permanently have full 4k screen filled with the warnings. These windows wash away by themselves (fade out, thanks to you again), or disappear when I hover the mouse over them (no clicks used, no time sometimes for even click), or work some other ways including clicking to close them.

But I just moved to the next level of craziness and ordered 8k monitor of even larger size, now 65", there exist an option with 82" which is offered for very very cheap but probably this will be an overkill, will see. In this case the mess and possible disorder on my screen will be so toxic that I need to think in advance how to handle multiple windows with minimal efforts

The method you propose with %cc will still require one more click to determine and save its current state. What I am interested is the functionality that saves window position automatically, effortless, when I move the window into new position: I move the window, close it (clicking cross, or push ESC), and next time this window will appear it will be opened in this last position
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Sat Aug 08, 2020 7:07 pm    Post subject: Reply with quote

Hi Dan,

Then put a timer in the window with %dl and keep saving the position instead of just doing it at close time.

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat Aug 08, 2020 11:58 pm    Post subject: Reply with quote

I already use timers done a bit differently on some windows which are not very important to miss not being seen. Important windows have to stay till you remove them manually
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Aug 09, 2020 11:48 pm    Post subject: Reply with quote

Though thinking more may be your idea with %dl could be useful here too. Will wait till Paul tell about feasibility of what was asked initially, and if this can not easily done with just one more easy control, may be I will try to do workaround with %dl. Essentially what I ask is to find the way to call GET_WINDOW_LOCATION@ when you move the entire window not just resize it or click inside it. I think Bill is also talking along something similar

I understand your suggestion that the %dl has to permanently call GET_WINDOW_LOCATION@ with interval of seconds and each time save its current coordinates into the program settings, correct?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Aug 10, 2020 11:54 am    Post subject: Reply with quote

Here is a sample that illustrates what I had in mind. Alternatively you could use %gp and %sp but %gp gets the position of a control so you would have to work out the offset of that control relative to its parent and apply this offset when applying %sp.

Code:
winapp
program main
use clrwin
integer,external::cb
integer(7) hwnd
integer ix,iy
common hwnd,ix,iy
ix = clearwin_info@("SCREEN_WIDTH")/2
iy = clearwin_info@("SCREEN_DEPTH")/2
do
  iw = winio@("%hw&",hwnd)
  iw = winio@("%sp&",ix,iy)
  iw = winio@("%cc&",cb)
  iw = winio@("%cn %bt[Close] %bt[Re-open]")
  if(iw /= 2) exit
end do
end program

integer function cb()
use clrwin
integer(7) hwnd
integer ix,iy
common hwnd,ix,iy
call get_window_location@(hwnd, ix, iy, iw, ih)
cb = 0
end function
Back to top
View user's profile Send private message AIM Address
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