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 

Still on a Quest to re-blank an %rf box ...

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



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

PostPosted: Mon Dec 06, 2021 10:46 pm    Post subject: Still on a Quest to re-blank an %rf box ... Reply with quote

Some time ago, I made the suggestion that there should be a REBLANK@ routine. I revisited that in another post, and Paul made the suggestion that I use (my coding):

Code:
          BLANK    = CHAR(0)
          NW = SendMessage (iHandle, EM_SETSEL,  0, -1)
          NW = SendMessage (iHandle, EM_REPLACESEL, 0, BLANK)


I ran the demonstration code, entered 123 into the %rf box, and pressed the button to reblank it, and the box showed D@@. On looking into EM_REPLACESEL in MSDN, I came to the conclusion that maybe I should use

Code:
          BLANK    = CHAR(0)
          NW = SendMessage (iHandle, EM_SETSEL,  0, -1)
          NW = SendMessage (iHandle, WM_SETTEXT, 0, BLANK)


Later on, Paul suggested that I use:

Code:
           L  = SetWindowText(iHandle, "")


where L is LOGICAL.

None of the alternatives actually blanks the box. I could really do with a routine that actually did re-blank the box!

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


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

PostPosted: Tue Dec 07, 2021 9:26 am    Post subject: Reply with quote

Eddie

Here is a sample program for you to try...

Code:
module md
use mswin
integer(7) hwnd
double precision x
contains
 integer function cb()
 integer(7) han
 if(SetWindowText(hwnd,"")) x = 0d0
 han = SetFocus(hwnd)
 cb = 2
 end function
end module

winapp
program main
use md
integer iw
x = 1d0
iw = winio@("%cn%rf&",x)
iw = winio@("%lc&",hwnd)
iw = winio@("%2nl%cn%^8bn[Clear]",cb)
end program
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



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

PostPosted: Tue Dec 07, 2021 11:43 am    Post subject: Reply with quote

Paul,

Your demo works fine. I copied the operative bits to my code, and the %rf box didn't blank. After a lot of experimentation I found that it did if I added UPDATE_WINDOW@ with the dialog window handle.

I don't think that I've ever used UPDATE_WINDOW@ before, except when I confused it with WINDOW_UPDATE@ ... a rather common occurrence!

Many thanks

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


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

PostPosted: Tue Dec 07, 2021 11:49 am    Post subject: Reply with quote

Eddie

Maybe the return value for cb should be 1 for your program.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



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

PostPosted: Tue Dec 07, 2021 12:10 pm    Post subject: Reply with quote

Hi Paul,

I tried that already, and it didn't work. Currently, I'm having trouble with the SetFocus, which doesn't work at first and then catches up.

Here's part 1:

Code:
      WINAPP
      OPTIONS (INTL, DREAL)
      PROGRAM SPEED
C     -------------
      INCLUDE <WINDOWS.INS>
      COMMON /SPEEDER/ RADIUS, iRAD, iGREY, HGV_LIMIT
      COMMON /SPEEDEX/ RAD_LOW, RAD_HIGH, iHandle
      COMMON /WINDER/  jHandle
      INTEGER, EXTERNAL :: KB_LIST, KB_RAD

      CHARACTER*(20) SPEED_LIST(4)
      CHARACTER*(20) HGV_LIMIT
      HGV_LIMIT = 'As adjacent road'
      SPEED_LIST(1) = 'Bridge not curved'
      SPEED_LIST(2) = 'Radius < 600m'
      SPEED_LIST(3) = 'Radius = 600m'
      SPEED_LIST(4) = 'Radius > 600m'
      iRAD     = 1
      iGREY    = 0
      RAD_LOW  = 0.0
      RAD_HIGH = 1.0

      IW = WINIO@ ('%ca[Speed and radius]&')
      IW = WINIO@ ('%`^ls &', SPEED_LIST, 4, iRAD, KB_LIST)
      IW = WINIO@ ('%co[check_on_focus_loss]&')
      IW = WINIO@ ('  Radius: %fl%~^rf[initially_blank]%lc&',
     &                RAD_LOW,  RAD_HIGH,
     &                RADIUS,   IGREY,    KB_RAD,
     &                iHANDLE)
      IW = WINIO@ ('   Max HGV speed:  %`rs&', HGV_LIMIT)
      IW = WINIO@ ('%nl%rj%8bt[OK]&')
      IW = WINIO@ ('%hw&', jHandle)
      IW = WINIO@ ('%sf')

      WRITE(*,*) RADIUS
      END


      INTEGER FUNCTION KB_RAD()
C     -------------------------
      COMMON /SPEEDER/ RADIUS, iRAD, iGREY, HGV_LIMIT
      INCLUDE <WINDOWS.INS>
      CHARACTER*(20) HGV_LIMIT
C
C     calculate what the HGV speed limit is here. I will
C     just make a lot of guesses

      IF (iRAD .EQ. 1) THEN
          HGV_LIMIT = 'As adjacent road'
      ELSE IF (iRAD .EQ. 2) THEN
          HGV_LIMIT = '20 mph'
      ELSE IF (iRAD .EQ. 1) THEN
          HGV_LIMIT = '40 mph'
      ELSE
          HGV_LIMIT = '60 mph'
      ENDIF
      CALL WINDOW_UPDATE@ (HGV_LIMIT)

      KB_RAD = 2
      END
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Tue Dec 07, 2021 12:11 pm    Post subject: Reply with quote

And part 2:

Code:
      INTEGER FUNCTION KB_LIST()
C     --------------------------
      COMMON /SPEEDER/ RADIUS, iRAD, iGREY, HGV_LIMIT
      COMMON /SPEEDEX/ RAD_LOW, RAD_HIGH, iHandle
      COMMON /WINDER/  jHandle
      INCLUDE <WINDOWS.INS>
      CHARACTER*(20) HGV_LIMIT

      IF (iRAD .EQ. 1) THEN
!     ---------------------
          iGREY    = 0
          RAD_LOW  = 0.00
          RAD_HIGH = 0.500
          RADIUS   = 0.0
          CALL set_float_limits@ (iHandle, RAD_LOW, RAD_HIGH)
          CALL WINDOW_UPDATE@ (RADIUS)
          HGV_LIMIT = 'As adjacent road'           
          CALL WINDOW_UPDATE@ (HGV_LIMIT)
          IF (SetWindowText(iHandle, "")) RADIUS = 0.0
!         ... focus not required if the target %rf is greyed out
          CALL UPDATE_WINDOW@ (jHandle)

              ELSE IF (iRAD .EQ. 2) THEN
!             --------------------------
              RAD_LOW  = 0.00
              RAD_HIGH = 600.000
              RADIUS   = 300.00
              CALL UNBLANK_CONTROL@ (iHandle)
              CALL WINDOW_UPDATE@ (RADIUS)
              CALL set_float_limits@ (iHandle, RAD_LOW, RAD_HIGH)
              HGV_LIMIT = '20 mph'           
              CALL WINDOW_UPDATE@ (HGV_LIMIT)
              IF (SetWindowText(iHandle, "")) RADIUS = 300.00
              iGREY = 1
              JAN   = SetFocus (iHandle)
              CALL UPDATE_WINDOW@ (jHandle)

          ELSE IF (iRAD .EQ. 3) THEN
!         --------------------------
          RAD_LOW  = 599.9
          RAD_HIGH = 600.1
          RADIUS   = 600.0
          CALL UNBLANK_CONTROL@ (iHandle)
          CALL set_float_limits@ (iHandle, RAD_LOW, RAD_HIGH)
          CALL WINDOW_UPDATE@ (RADIUS)
          HGV_LIMIT = '40 mph'           
          CALL WINDOW_UPDATE@ (HGV_LIMIT)
          iGREY = 0
          CALL UPDATE_WINDOW@ (jHandle)

              ELSE IF (iRAD .EQ. 4) THEN
!             --------------------------
              RAD_LOW  = 600.000
              RAD_HIGH = 100000.000
              RADIUS   = 600.00
              CALL UNBLANK_CONTROL@ (iHandle)
              CALL WINDOW_UPDATE@ (RADIUS)
              CALL set_float_limits@ (iHandle, RAD_LOW, RAD_HIGH)
              CALL set_float_limits@ (iHandle, RAD_LOW, RAD_HIGH)
              HGV_LIMIT ='60 mph'
              CALL WINDOW_UPDATE@ (HGV_LIMIT)
              IF (SetWindowText(iHandle, "")) RADIUS = 600.0
              iGREY = 1
              JAN   = SetFocus (iHandle)
              CALL UPDATE_WINDOW@ (jHandle)

          ENDIF

      KB_LIST = 2
      END
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Tue Dec 07, 2021 12:11 pm    Post subject: Reply with quote

(Duplicate post edited out)

Last edited by LitusSaxonicum on Tue Dec 07, 2021 12:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Tue Dec 07, 2021 12:15 pm    Post subject: Reply with quote

The user can change their mind about which of the 4 %`ls options they choose and the other boxes respond accordingly. It would be nice if options 2 and 4 set the focus reliably, but it doesn't matter all that much. It's only a development of something much larger, and it is fairly obvious that the Radius box has to have something in it as the next step, but even so, it is nice when it gains the focus straightaway.

Please don't waste your time on it - I only posted it so that you can see what I'm up to.

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


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

PostPosted: Tue Dec 07, 2021 1:09 pm    Post subject: Reply with quote

Eddie

A direct way to redraw a window is to call RedrawWindow as follows. The given interface must be modified in order to provide a NULL pointer for the rectangle.

Code:
module md
use mswin
integer(7) hwnd
double precision x
contains
 integer function cb()
 integer(7) han
 logical L
 stdcall Redraw_Window 'RedrawWindow'(VAL,VAL,VAL,VAL):logical*4
 if(SetWindowText(hwnd,""))then
   x = 0d0
   L = Redraw_Window(hwnd,0,0,RDW_INVALIDATE+RDW_ERASE)
 endif 
 han = SetFocus(hwnd)
 cb = 2
 end function
end module

winapp
program main
use md
integer iw
x = 1d0
iw = winio@("%cn%rf&",x)
iw = winio@("%lc&",hwnd)
iw = winio@("%2nl%cn%^8bn[Clear]",cb)
end program
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



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

PostPosted: Tue Dec 07, 2021 1:54 pm    Post subject: Reply with quote

Hi Paul,

Many thanks for that code. I will take a look and try to understand it. I found that UPDATE_WINDOW@ (along with your previous suggestion) did the trick with the re-blanking, more or less, and I'd moved on to the SetFocus issue (i.e. it doesn't always happen).

I struggle to understand what MSDN is saying, but persevere - as a result I am much happier when using a bona fide ClearWin+ routine rather than attempting to interface to one of the Windows routines directly.

Eddie
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