Spinner Control Maximum Workaround?

Started by oradba4u, July 11, 2015, 05:57:36 AM

Previous topic - Next topic

oradba4u

All:
Using Winbatch 2008c

Manual says the spinner control "must be in the range of -32768 to 32767, and the difference between the values cannot exceed 32767"

Any workarounds for this? I want to be able to use, say, 100,000 for maximum


Many thanks

td

The range limit is in the manual because that is the range limit of the control.  You could try to use the Control manager extender or a DllCall to SendMessage to increase the range but getting the values back you would require another SendMessage call. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Hopefully, one of our more win32 savvy users will post an example, if you need more assistance.  If not, we might be able to put something together when things settle down a bit.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

One work around would be to used a dropdown rather than a spinner.

JTaylor

You beat me to it Stan :-)   But for what it is worth something like:

Code (winbatch) Select


Home_Path = DirScript()
DirChange(Home_Path)
GoSub Load_Routines
IntControl(49,3,0,0,0)

Spin_SubFormat=`WWWDLGED,6.2`

Spin_SubCaption=`Spin`
Spin_SubX=002
Spin_SubY=038
Spin_SubWidth=132
Spin_SubHeight=131
Spin_SubNumControls=002
Spin_SubProcedure=`Spin_Sub`
Spin_SubFont=`DEFAULT`
Spin_SubTextColor=`DEFAULT`
Spin_SubBackground=`DEFAULT,DEFAULT`
Spin_SubConfig=0

Spin_Sub001=`095,007,030,012,PUSHBUTTON,"exit",DEFAULT,"E&xit",1,33,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
Spin_Sub002=`023,041,074,011,DROPLISTBOX,"spindrop",spindrop,DEFAULT,DEFAULT,20,@csListOnly,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("Spin_Sub")

Exit

:Load_Routines



#DefineSubRoutine Spin_Sub(Ava_Handle,DMsg,DCID,DEInfo,ChangeInfo)

Switch (DMsg)
    Case @deInit
    DialogProcOptions(Ava_Handle, @deTimer,0)                             ; TimerEvent (0- Off).
    DialogProcOptions(Ava_Handle, @deClose,1)                             ; Close selected (IntControl(49....) (1-On, 0-Off).
    DialogProcOptions(Ava_Handle, @dpoDisable,0)                          ; Dialog Disable (1-Disable, 2-Wait cursor, 0-Enable).
    DialogProcOptions(Ava_Handle, @dpoBkground,-1)                        ; Change Dialog Background (Bitmap File or RGB String).
    DialogProcOptions(Ava_Handle, @dePbPush,1)                            ; Pushbutton/PictureButton.
    DialogProcOptions(Ava_Handle, @deDlChange,1)                          ; DropList.
   
    spindrop_list = ""
    spindrop = ""

    For x = 1 to 1000
      spindrop_list = spindrop_list:x:@TAB
    Next
    spindrop_list = ItemRemove(-1,spindrop_list,@TAB)

    DialogControlSet(Ava_Handle,"spindrop",@dcContents,spindrop_list)
    DialogControlSet(Ava_Handle,"spindrop",@dcSelect,spindrop)
   
    Break
  Case @deTimer
    Break
  Case @deClose
    Return 9
    Break
  Case @deDlChange
    Switch(DialogProcOptions(Ava_Handle,@dpoCtlNumber,DCID))
      Case DialogProcOptions(Ava_Handle,@dpoCtlNumber,"spindrop")
        spindrop = DialogControlGet(Ava_Handle,"spindrop",@dcSelect)
        spindrop_list = DialogControlGet(Ava_Handle,"spindrop",@dcContents)
        Break
    EndSwitch
    Break
  Case @dePbPush
    Switch(DialogProcOptions(Ava_Handle,@dpoCtlNumber,DCID))
      Case DialogProcOptions(Ava_Handle,@dpoCtlNumber,"exit")
        button_text = DialogControlGet(Ava_Handle,"exit",@dcTitle)
        Return -1
        Break
    EndSwitch
    Break
EndSwitch
Return -2

#EndSubRoutine
 

Return




td

Remembered that the  'SendMessge' approach would not work because of some error checking in the Dialog's subclassed version of the control.  That makes using a different UI approach as suggested above the best and perhaps only alternative.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

oradba4u

Sorry guys, but this does not work on my configuration.

Did I mention that I am running an antique version of Winbatch (2008c)?  WWWDLGED,6.1





....IFICantBYTE

Sorry, only just read that you are on 2008c after I knocked this example up... you could convert it to use the older Dialog constants etc though and get it working on your version...

Code (winbatch) Select
;Spinner control substitute example using other WB controls (edit box and two buttons) plus a timer to increment if mouse held down

; put whatever values you want here:
ebVariable1 = 99990;initial value
Maximum = 100000
Minimum = -25
Increment = 1

#DefineSubroutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Event,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
switch MyDialog_Event                                    ; Switch based on Dialog Message type
case @deInit                                          ; Standard Initialization message
DialogProcOptions(MyDialog_Handle,@deTimer,200)
DialogProcOptions(MyDialog_Handle,@dePbPush,@TRUE)
DialogProcOptions(MyDialog_Handle,@deEdText,@TRUE)
return(@retDefault)

case @deTimer
If MouseInfo(0)== "s" && MouseInfo(4) == 4 Then Goto UP
If MouseInfo(0)== "t" && MouseInfo(4) == 4 Then Goto DOWN
return(@retDefault)

case @dePbPush
if MyDialog_Name == "PushButton_OK"                ; OK
return(@retDefault)

elseif MyDialog_Name == "PushButton_Cancel"        ; Cancel
return(@retDefault)

elseif MyDialog_Name == "PushButton_3"             ; UP (ZDingbats "s")
:UP
ebVariable1 = DialogControlGet(MyDialog_Handle,"EditBox_1",@dcText)
ebVariable1 = ebVariable1 + increment
If ebVariable1 > maximum then ebVariable1 = maximum
; If ebVariable1 < minimum then ebVariable1 = minimum
DialogControlSet(MyDialog_Handle,"EditBox_1",@dcText,ebVariable1)
DialogControlState(MyDialog_Handle,"EditBox_1",@dcsSetFocus ,0)
return(@retNoExit)

elseif MyDialog_Name == "PushButton_4"             ; DOWN (ZDingbats "t")
:DOWN

ebVariable1 = DialogControlGet(MyDialog_Handle,"EditBox_1",@dcText)
ebVariable1 = ebVariable1 - increment
; If ebVariable1 > maximum then ebVariable1 = maximum
If ebVariable1 < minimum then ebVariable1 = minimum
DialogControlSet(MyDialog_Handle,"EditBox_1",@dcText,ebVariable1)
DialogControlState(MyDialog_Handle,"EditBox_1",@dcsSetFocus ,0)
return(@retNoExit)

endif                                              ; MyDialog_Name
return(@retDefault)

case @deEdText                                        ; ID "EditBox_1"  ebVariable1 0
ebVariable1 = DialogControlGet(MyDialog_Handle,"EditBox_1",@dcText)
If ebVariable1 > maximum then ebVariable1 = maximum
If ebVariable1 < minimum then ebVariable1 = minimum
DialogControlSet(MyDialog_Handle,"EditBox_1",@dcText,ebVariable1)
return(@retDefault)

case @deClose                                         ; System menu close event
return(@retDefault)

endswitch                                                ; MyDialog_Event
return(@retDefault)
#EndSubroutine                                               ; End of Dialog Callback MyDialogCallbackProc

;============================================================
;============================================================
;============================================================


MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=363
MyDialogY=084
MyDialogWidth=166
MyDialogHeight=131
MyDialogNumControls=008
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`017,109,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`109,109,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`057,039,036,012,EDITBOX,"EditBox_1",ebVariable1,"0",DEFAULT,30,@csDigits,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`093,039,008,006,PUSHBUTTON,"PushButton_3",DEFAULT,"s",2,40,DEFAULT,"ZDingbats|2560|50|2",DEFAULT,DEFAULT`
MyDialog005=`093,045,008,006,PUSHBUTTON,"PushButton_4",DEFAULT,"t",3,50,DEFAULT,"ZDingbats|2560|50|2",DEFAULT,DEFAULT`
MyDialog006=`059,023,044,012,VARYTEXT,"VaryText_1",Maximum,"Vary 1",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog007=`059,059,044,012,VARYTEXT,"VaryText_2",Minimum,"Vary 2",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog008=`107,041,044,012,VARYTEXT,"VaryText_3",Increment,"Vary 3",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Exit
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

oradba4u

I already fixed the ERROR
3220: Dialog: Format version not supported (I'm using 2008c which I believe uses MyDialogFormat=`WWWDLGED,6.1`

BUT...

Could someone explain what/why:
@csDefButton is in the pushbutton definition for MyDialog001 (FONT position?)

AND

@csDigits is in the pushbutton definition for MyDialog003 (FONT position?)


I'm getting errors with this code. I'm frustrated, obviously I'm missing something here,
and this is taking much longer than expected.

ERROR:

3957 Dialog: Bad Variable attribute found in definition variable
on line 95 of ....

ButtonPushed=Dialog("MyDialog")

When I press More Error Info:

It points to the "MyDialog001=....         line.


In my 2008c manual, the order for attributes is:
Variable Name/Control Number= Column, Row, Width, Height, Control Type, Variable Name, Text/pre-selected Item, Value,
Tab Order, Style, Font, Text Color, Background Color, Return variable name...

So my question is:

What/Why:
@csDefButton is in the pushbutton definition for MyDialog001 (FONT position?)

AND

@csDigits is in the pushbutton definition for MyDialog003 (FONT position?)


JTaylor

I try to be helpful but figured you could make any needed changes for an older version as easily as I could  ;)   Didn't figure you would use this code anyway other than to look at it for the concept.  Basically create a droplist box with the droplist size set so it doesn't show a droplist and set it to a List Only style.   Then populate it with your list of numbers.   The downside of this approach is that it sounds like your list would be very large and may make loading a bit slow.  If too slow you might be able to solve that by having a smaller list and make it grow in the appropriate direction as the user scrolls up or down.

Jim

Quote from: oradba4u on July 13, 2015, 07:15:23 PM
Sorry guys, but this does not work on my configuration.

Did I mention that I am running an antique version of Winbatch (2008c)?  WWWDLGED,6.1

stanl

I personally don't see the point of having a spinner up to 100,000 unless say the increments were 10,000. I suggested a drop down because you can vary the increments - a recent example I developed for call records looked like...

last 1/2 hour
last 3 hours
current day
back 3 days
back 7 days
back 14 days
back 1 month
Enter days back

the last option would bring up a edit cell to accept and validate a number. The other options were based on the most widely accepted ranges.

This replaced a spinner that went from 1-75 days which nobody liked dealing with.


....IFICantBYTE

Here is a version of my earlier post modified to work (I think) with your 2008c version and 6.1 dialogs.
It's not perfect, but works pretty well I think and looks a lot like a "real" spinner control.

Code (winbatch) Select
;Spinner control substitute example using other WB controls (edit box and two buttons) plus a timer to increment if mouse held down

; put whatever values you want here:
ebVariable1 = 99990;initial value
Maximum = 100000
Minimum = -25
Increment = 1


#DefineSubroutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Event,MyDialog_ID,MyDialog_EventInfo, rsvd)
switch MyDialog_Event                                    ; Switch based on Dialog Message type
case 0                                          ; Standard Initialization message
DialogProcOptions(MyDialog_Handle,1,200)  ;timer
DialogProcOptions(MyDialog_Handle,2,@TRUE) ;pushbutton
DialogProcOptions(MyDialog_Handle,5,@TRUE) ;editbox
return(-1)

case 1                                          ; Timer
If MouseInfo(0)== "s" && MouseInfo(4) == 4 Then Goto UP
If MouseInfo(0)== "t" && MouseInfo(4) == 4 Then Goto DOWN
return(-1)


case 2
switch MyDialog_ID
case 001                                     ; ID 001  OK
return(-1)

case 002                                     ; ID 002  Cancel
return(-1)

case 004                                     ; ID 004  s
:UP
ebVariable1 = DialogControlGet(MyDialog_Handle,003,3)
If IsNumber(ebVariable1) == @FALSE then ebVariable1 = 0
ebVariable1 = ebVariable1 + increment
If ebVariable1 > maximum then ebVariable1 = maximum
; If ebVariable1 < minimum then ebVariable1 = minimum
DialogControlSet(MyDialog_Handle,003,3,ebVariable1)
DialogControlState(MyDialog_Handle,003,1 ,0)
return(-2)

case 005                                     ; ID 005  t
:DOWN
ebVariable1 = DialogControlGet(MyDialog_Handle,003,3)
If IsNumber(ebVariable1) == @FALSE then ebVariable1 = 0
ebVariable1 = ebVariable1 - increment
; If ebVariable1 > maximum then ebVariable1 = maximum
If ebVariable1 < minimum then ebVariable1 = minimum
DialogControlSet(MyDialog_Handle,003,3,ebVariable1)
DialogControlState(MyDialog_Handle,003,1 ,0)
return(-2)

endswitch                                       ; MyDialog_ID
return(-1)

case 5                                        ; ID 003  ebVariable1 Edit 1
ebVariable1 = DialogControlGet(MyDialog_Handle,003,3)
If ebVariable1 == "-" then return(-1)
If IsNumber(ebVariable1) == @FALSE then ebVariable1 = 0
If ebVariable1 > maximum then ebVariable1 = maximum
If ebVariable1 < minimum then ebVariable1 = minimum
DialogControlSet(MyDialog_Handle,003,3,ebVariable1)
return(-1)

case 11                                         ; System menu close event
return(-1)

endswitch                                                ; MyDialog_Event
return(-1)
#EndSubroutine                                              ; End of Dialog Callback MyDialogCallbackProc

;============================================================
;============================================================
;============================================================



MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=363
MyDialogY=084
MyDialogWidth=166
MyDialogHeight=131
MyDialogNumControls=008
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`011,105,036,012,PUSHBUTTON,DEFAULT,"OK",1,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`117,105,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`061,031,036,012,EDITBOX,ebVariable1,"Edit 1",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`097,031,006,006,PUSHBUTTON,DEFAULT,"s",2,40,DEFAULT,"ZDingbats|2560|50|2",DEFAULT,DEFAULT`
MyDialog005=`097,037,006,006,PUSHBUTTON,DEFAULT,"t",3,50,DEFAULT,"ZDingbats|2560|50|2",DEFAULT,DEFAULT`
MyDialog006=`061,013,044,012,VARYTEXT,Maximum,"Vary 1",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog007=`061,051,044,012,VARYTEXT,Minimum,"Vary 2",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog008=`107,033,044,012,VARYTEXT,Increment,"Vary 3",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")


Exit
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)