bb.donnay-software.com

Donnay Software Web Forums
It is currently Wed Aug 12, 2020 3:13 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: DCSTATIC
PostPosted: Sun Jul 05, 2020 5:20 am 
Offline

Joined: Thu Jan 28, 2010 3:48 am
Posts: 18
Roger,

I use DCSTATIC Type XBPSTATIC_TYPE_TEXT together with the VSCROLL-command successfully.
Now it would be fine if I could also use the mouse wheel to execute a vertical scroll.
Do you or anybody have an idea to get this property?

I use xbase++ Version 2.0 and express 2.0.266.

Regards,
Werner


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Sun Jul 05, 2020 9:33 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 789
Location: Berlin, Germany
Hi, Werner.

1. Add a custom handler to your dialog using the HANDLER or the HANDLERBLOCK option.

2. Catch the xbeM_Wheel-event (IF nEvent == xbeM_Wheel), look whether the mouse is over your static or not (using the object sent as the fourth parameter to the handler and the coordinates in the second parameter)

3. Send 1 or -1 to the scrollbar with oScrollbar:SetData(1/-1) depending on whether the wheel was moved up- or downwards (third parameter sent to the dialog positive or negative)

That's it.

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Sun Jul 05, 2020 10:43 am 
Offline

Joined: Thu Jan 28, 2010 3:48 am
Posts: 18
Hi Tom,

thank you very much for your response.

Up to now I have never created a own event handler, but I will try it following your detailed instructions.

Best regards,
Werner


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Mon Jul 06, 2020 12:05 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 789
Location: Berlin, Germany
Maybe I can build a short sample during the day.

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Mon Jul 06, 2020 1:52 am 
Offline

Joined: Thu Jan 28, 2010 3:48 am
Posts: 18
It would be a great help to get a sample, if you have time.

Here my current dcstatics.
Now dcstatic Textbox oStatic3 has the vscroll command which offers the vertical scrollbar but does not allow to use the mouse wheel
as already explained.

@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX size 54*sf, 12.5*zf ;
OBJECT oStatic1

@ .5,1 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT size 53*sf, 11.5*zf ;
OBJECT oStatic2

@ 1,1 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT size 52*sf, 250 ;
OBJECT oStatic3 ;
PARENT oStatic2 ;
caption cText ;
option XBPSTATIC_TEXT_WORDBREAK ;
FONT trim( DC->mailfont ) ;
VSCROLL oStatic1 RANGE 0, 5000 ;
helpcode mprogn + "dcstatic"

.....

dcread gui modal clearevents options getoptions ;
setFocus @oStatic1 setAppWindow fit ;
eval {|o|o : show() } ;
title "TEXT-Dokument " + cDatei

Regards, Werner


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Mon Jul 06, 2020 4:08 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 789
Location: Berlin, Germany
Hi, Werner.

I modified your code a little, please take a closer look to the oTextStatic:SetPos() in the handler function, this may need some additional clearing. Remark: It seems you use the vars "sf" and "zf" to create something like scaling. Take a look at the "SCALEFACTOR" option of DCGET OPTIONS - this makes scaling much easier!

Code:
#include "dcdialog.ch"
#include "appevent.ch"
#pragma library("dclipx.lib")

FUNCTION Werner()
LOCAL GetList := {}, GetOptions := {}, oStatic1, oStatic2, cText := "", nCtr, sf := 1, zf := 1, oVScroll

FOR nCtr := 1 TO 100
  cText += Str(nCtr)+" Dies ist ein Test"+Chr(13)+Chr(10)
NEXT

@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX size 54*sf, 12.5*zf ;
OBJECT oStatic1

@ .5,1 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT size 53*sf, 11.5*zf ;
OBJECT oStatic2

@ 1,1 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT size 52*sf, 250 ;
OBJECT oStatic3 ;
PARENT oStatic2 ;
caption cText ;
option XBPSTATIC_TEXT_WORDBREAK ;
VSCROLL oStatic1 RANGE 0, 50 OBJECT oVScroll

dcread gui modal clearevents options getoptions ;
setFocus @oStatic1 setAppWindow fit ;
eval {|o|o : show() } ;
title "TEXT-Dokument " ;
HANDLERBLOCK {|a,b,c,d,e|MyHandler(a,b,c,d,e,oStatic3,oVScroll)}

RETURN NIL

STATIC FUNCTION MyHandler(nEvent,mp1,mp2,oXbp,oDlg,oTextStatic,oVScroll)
STATIC nTextScrollStartPos := 0
LOCAL nScrollDirection

IF nTextScrollStartPos = 0
 nTextScrollStartPos := oTextStatic:CurrentPos()[2]
ENDIF

IF nEvent == xbeM_Wheel .AND. IAmOverObject(oTextStatic,mp1)
  nScrollDirection := IF(mp2[2]>0,(-1),1)
  IF oVScroll:IsVisible() .AND. oVScroll:GetData()+nScrollDirection >= oVScroll:Range[1] .AND. ;
                                         oVScroll:GetData()+nScrollDirection <= oVScroll:Range[2]
    oVScroll:SetData(oVScroll:GetData()+nScrollDirection)
    oTextStatic:SetPos({oTextStatic:CurrentPos()[1],nTextScrollStartPos+oVScroll:GetData()})
  ENDIF
ENDIF
RETURN DCGUI_NONE

FUNCTION IAmOverObject(oXbp,mp1,aRefPos)
* tests if the coords in mp1 reflect to oXbp
DEFAULT aRefPos := {{0,0},oXbp:CurrentSize()} // {{oXbp:CurrentPos()[1],0},oXbp:CurrentSize()}
IF mp1[1] >= aRefPos[1,1] .and. mp1[1] <= aRefPos[2,1] .and. ;
   mp1[2] >= aRefPos[1,2] .and. mp1[2] <= aRefPos[2,2]
   RETURN .T.
ENDIF
RETURN .F.


Edit: Correction. Now scrolling works good in both directions!

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Tue Jul 07, 2020 1:24 am 
Offline

Joined: Thu Jan 28, 2010 3:48 am
Posts: 18
Tom,

Thank you for your effort to create a detailed sample code for my request, that works well!

There is only a certain flickering during the movement of longer static text, but I think that you cannot improve this behaviour.

You are right, zf and sf ( Zeilen/Spaltenfaktor), are for scaling I use since we have changed from DOS to WINDOWS.

I should really check the scalefactor command of the dcget options, thank you this advice!

Regards,
Werner


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Tue Jul 07, 2020 2:03 am 
Offline
User avatar

Joined: Thu Jan 28, 2010 12:59 am
Posts: 789
Location: Berlin, Germany
Hi, Werner.

I'm happy about that. The flickering comes from the fact that the static is repositioned in very small steps. You have to play around a bit with the range of the scroll bar. oDialog:LockUpdate does not help because you only change one element.

DCGETOPTIONS ... SCALEFACTOR is a great improvement. You may keep your zf/sf-calculation and just move this to the SCALEFACTOR array, and you will get rid of all the lines containting "*sf" and "*zf".

_________________
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."


Top
 Profile  
 
 Post subject: Re: DCSTATIC
PostPosted: Tue Jul 07, 2020 6:42 am 
Offline

Joined: Thu Jan 28, 2010 3:48 am
Posts: 18
Tom,

Testing the range of the scrollbar ist a good recommendation.

By the way: I replaced the VScroll-command with dcscrollbar to have better control.

Using the scalefactor would really reduce my program codes, thank you!

Regards, Werner


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group