Silverfrost Forums

Welcome to our forums

Possible to detect %gr losing focus?

10 Sep 2021 7:38 #28241

Here's a simple program that tracks a cursor in a %gr drawing surface:

      WINAPP
      OPTIONS (INTL, DREAL)

      PROGRAM FOLLOW_THE_MOUSE
C     ------------------------
      COMMON /MOUSE/ IX, IY, LW, JX, JY
      INCLUDE <WINDOWS.INS>
      EXTERNAL KB_GET_CURSOR_POS
      DIMENSION IAR(3)
      IAR = 25                                 ! whole array
      JX = 0
      JY = 0
      IW = WINIO@ ('%ca[Follow the cursor]&')
      IW = WINIO@ ('%3sb%lc&', IAR, LW)
      IW = WINIO@ ('%`cu&', CURSOR_ARROW)
      IW = WINIO@ ('%^gr[blue,full_mouse_input]', 600, 400, 
     &            KB_GET_CURSOR_POS)
      END

      INTEGER FUNCTION KB_GET_CURSOR_POS()
C     ------------------------------------
      COMMON /MOUSE/ IX, IY, LW, JX, JY
      CHARACTER*(20) XTEXT, YTEXT
      INCLUDE <WINDOWS.INS>
      IX = CLEARWIN_INFO@ ('GRAPHICS_MOUSE_X')
      IY = CLEARWIN_INFO@ ('GRAPHICS_MOUSE_Y')
      WRITE(XTEXT,'('  X=',I4)') IX
      WRITE(YTEXT,'('  Y=',I4)') IY
      CALL DRAW_LINE_BETWEEN@ (JX, JY, IX, IY, RGB@(255,255,255))
      JX = IX
      JY = IY
      CALL SET_STATUS_TEXT@ (LW, 0, XTEXT)
      CALL SET_STATUS_TEXT@ (LW, 1, YTEXT)
      KB_GET_CURSOR_POS = 2
      END

Interestingly, the line becomes broken if I use USE_GDIPLUS@, so clearly it needs to be more than 1 pixel wide for the smoothing not to break up the line.

My question is: How do I detect the drawing surface losing focus? I could then blank the coordinates in the status bar (and also at the expense of a little programming, deal with re-entry properly, but after all, this is just a demonstrator).

Working with %sb, and comparing my efforts to MS apps, it does seem to me that it would be handy to have a slider %sl control in the status bar, wouldn't it? (for Zooming, principally).

Eddie

11 Sep 2021 6:48 #28242

Eddie

ADD_CURSOR_MONITOR@ can be used to detect the HWND of the control under the cursor. ADD_FOCUS_MONITOR@ tracks which control has the focus.

%1.3ob[status] could be used to add a slider to the status bar.

11 Sep 2021 8:57 #28243

Hi Paul,

Many thanks for the advice about the cursor and focus.

I realised that the %ob[status] could do it, but it was in the context of your new %sb that I was enquiring. You had a %br in there, and actually, %br is better in a dialog than tucked away because it basically says 'Go away, I'm busy', a message that has to be received to be understood, whereas a slider is where users get used to looking for it, being used to MS Office.

Eddie

11 Sep 2021 10:41 #28244

Eddie

I suggest trying %br preceeded by %ap. But the Z-order may not be what you need to make the bar visible. Try adding this at the end of the sequence. Otherwise you may need to call the Microsoaft API function BringWindowToTop for the bar.

Let me know how you get on. I might be able to add something useful to ClearWin+.

11 Sep 2021 5:39 #28245

Hi Paul,

Thanks for the advice. I'm currently having another go at %lv, and struggling. I'll have a look at the status bar again later.

I had a go with %bn, but couldn't see anything until I set 1 24 default.manifest in resources. The online help has %bt instead of %bn in the second example line.

Eddie

12 Sep 2021 8:04 #28247

Eddie

Thanks. I have corrected the typo. For me it works without the manifest but there is something wrong. The caption only appears when I use [text=...].

12 Sep 2021 9:43 #28250

Paul,

... and the arrow is blue!

I think that there may also be something wrong with 'notes'. I tried:

      IW = WINIO@('%16bn[Zoom,notes=Choose block select]')

and then I get an error that 'lock' isn't a valid option!

Eddie

(Using files like SALFLIBC.DLL from the forum)

12 Sep 2021 2:48 #28252

Try putting the string for notes= in quotation marks. Double quotes within single quotes should work.

Please login to reply.