1. Win32lib addition....
- Posted by "H.W Overman" <euman at bellsouth.net> Nov 23, 2003
- 435 views
Hello Derek and Win32lib coders I needed this tid-bit of code for a recent little app Im writing I have the code below for the UPDOWN controls UDM_SETACCEL constant DRCGroup = createEx( Group, "", MainWin, 288, 56, 108, 96, 0, 0 ), c140 = createEx( EditText, "", DRCGroup, 20, 63, 86, 22, or_all({ES_CENTER, WS_EX_CLIENTEDGE}), 0 ), c150 = create( UpDown, "UpDown69", DRCGroup, 80, 56, 0, 20, or_all({UDS_AUTOBUDDY, UDS_WRAP, UDS_ALIGNRIGHT,UDS_SETBUDDYINT,UDS_ARROWKEYS})) setBuddy( c150, c140 ) setScrollRange( c150, 1000, 5000 ) atom MyAccel MyAccel = allocate(8) constant MyAccel_nSec = MyAccel + 0, MyAccel_nInc = MyAccel + 4 poke4(MyAccel_nSec, 0) poke4(MyAccel_nInc, 1000) VOID = sendMessage( c150, UDM_SETACCEL, 1, MyAccel ) setText( c140, "1000" ) With this you can count by a set number, in this case by 1000. Here is the recommended procedure addition: procedure SetUPDOWNAccel( atom hWnd, integer Time, integer Tickrate ) atom MyAccel, id MyAccel = allocate(8) poke4(MyAccel, Time) poke4(MyAccel + 4, Tickrate) id = getHandle(hWnd) -- maybe this isnt needed for the current version of win32lib VOID = sendMessage( id, UDM_SETACCEL, 1, MyAccel ) end procedure maybe usefull to someone. Euman
2. Re: Win32lib addition....
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Nov 24, 2003
- 439 views
----- Original Message ----- From: "H.W Overman" <euman at bellsouth.net> To: <EUforum at topica.com> Subject: Win32lib addition.... > > > Hello Derek and Win32lib coders > > I needed this tid-bit of code for a recent little app Im writing > > I have the code below for the UPDOWN controls UDM_SETACCEL > > constant DRCGroup = createEx( Group, "", MainWin, 288, 56, 108, 96, 0, 0 ), > c140 = createEx( EditText, "", DRCGroup, 20, 63, 86, 22, or_all({ES_CENTER, > WS_EX_CLIENTEDGE}), 0 ), > c150 = create( UpDown, "UpDown69", DRCGroup, 80, 56, 0, 20, > or_all({UDS_AUTOBUDDY, UDS_WRAP, > UDS_ALIGNRIGHT,UDS_SETBUDDYINT,UDS_ARROWKEYS})) > setBuddy( c150, c140 ) > setScrollRange( c150, 1000, 5000 ) > > atom MyAccel > MyAccel = allocate(8) > > constant > MyAccel_nSec = MyAccel + 0, > MyAccel_nInc = MyAccel + 4 > > poke4(MyAccel_nSec, 0) > poke4(MyAccel_nInc, 1000) > > VOID = sendMessage( c150, UDM_SETACCEL, 1, MyAccel ) > setText( c140, "1000" ) > > With this you can count by a set number, in this case by 1000. > > Here is the recommended procedure addition: > > procedure SetUPDOWNAccel( atom hWnd, integer Time, integer Tickrate ) > atom MyAccel, id > MyAccel = allocate(8) > > poke4(MyAccel, Time) > poke4(MyAccel + 4, Tickrate) > > id = getHandle(hWnd) -- maybe this isnt needed for the current version of > win32lib > VOID = sendMessage( id, UDM_SETACCEL, 1, MyAccel ) > end procedure > > maybe usefull to someone. > Fair enough. Here is my rendition of it... ----------------------------------------------------------------------------- --/topic UpDown Control --/proc setAcceleration( integer id, sequence Times ) --/desc Set the rate of change for an UpDown control --The UpDown control specified by /i id will change it's values while the user holds -- down the mouse button. You can alter the rate of the change by using this routine. /n -- The /i Times parameter is a list of /b pairs of values, in which the first of a pair -- is the number of seconds to elapse (from the time the button was pressed) before changing, -- and the second is the (positive) increment to change the current value by. -- --Example: --/code -- setAcceleration(myUpDown, { {2,2}, {3,4}, {4, 8}, {7,16} } ) --/endcode global procedure setAcceleration( integer id, sequence pTimes) atom lAccel atom lAddr pTimes = sort(abs(floor(pTimes))) lAddr = acquire_mem(0, length(pTimes) * 8) lAccel = lAddr for i = 1 to length(pTimes) do poke4(lAccel, pTimes[i]) lAccel += 8 end for VOID = sendMessage( id, UDM_SETACCEL, length(pTimes) , lAddr ) release_mem(lAddr) end procedure I'll probably do the getAcceration() routine too, just to be complete. -- Derek