WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: chrislegarth on September 28, 2018, 11:32:00 AM

Title: Editbox Scroll
Post by: chrislegarth on September 28, 2018, 11:32:00 AM
I am having difficulty getting the code to "scroll" to the front of the editbox to work.  I referenced a tech database article called Editbox Cursor Placement.
Not sure what I am missing/doing wrong.  I'm using a 6.1 dialog because I am updating an old script.
Thanks in advance!

Code (winbatch) Select
gosub appfunctions

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`Editbox Scroll`
MyDialogX=10
MyDialogY=10
MyDialogWidth=144
MyDialogHeight=035
MyDialogNumControls=005
MyDialogProcedure=`DialogProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`003,005,028,008,STATICTEXT,DEFAULT,"Password:",DEFAULT,99,@csRight,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`033,003,104,012,EDITBOX,txtPassword,DEFAULT,DEFAULT,10,@csCurLeft,"Fixedsys|6144|40|49","0|0|0",DEFAULT`
MyDialog003=`061,017,056,012,PUSHBUTTON,DEFAULT,"Long",2,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`003,017,056,012,PUSHBUTTON,DEFAULT,"Short",1,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog005=`119,017,020,012,PUSHBUTTON,DEFAULT,"Exit",3,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

:appfunctions
#DEFINESUBROUTINE DialogProc(dlghandle,ControlType,ControlID,res4,res5)
switch (ControlType)
case 0
DialogProcOptions(dlghandle, 2, 1) ;BUTTON
break
case 2
switch (ControlID)
case 3
dialogcontrolset(dlghandle, 2, 3, "Now displaying a very long password")

; SCROLL CODE START
cntrlnum = 2
EM_SETSEL = 177
chandle = DllCall(DirWindows(1):"USER32.DLL",long:'GetDlgItem',long:dlghandle,long:cntrlnum + 99)
SendMessageA(chandle, EM_SETSEL, 0, 0)
EM_SCROLLCARET = 183
;chandle = DllCall(DirWindows(1):"USER32.DLL",long:'GetDlgItem',long:dlghandle,long:cntrlnum + 99)
SendMessageA(chandle, EM_SCROLLCARET, 0, 0)
; SCROLL CODE END

break
case 4
dialogcontrolset(dlghandle, 2, 3, "Short Password")
break
case 5
exit
break
endswitch
return -2
break
endswitch
return -1
#ENDSUBROUTINE

return
Title: Re: Editbox Scroll
Post by: stanl on September 28, 2018, 01:57:07 PM
maybe try adding  dialogcontrolstate(dlghandle, 2, 1, 2048) after dialogcontrolset(dlghandle, 2, 3, "Now displaying a very long password")
Title: Re: Editbox Scroll
Post by: td on September 28, 2018, 02:51:47 PM
The example is very old and your script has several issues.  Consider the following change to the "case 3" code block:

Code (winbatch) Select
         case 3
             cntrlnum = 2
             DialogControlSet(dlghandle, cntrlnum, 3, "Now displaying a very long password")
             DialogControlState(dlghandle, cntrlnum, @dcsSetFocus, 0) 
             break


Title: Re: Editbox Scroll
Post by: chrislegarth on September 28, 2018, 02:58:25 PM
Thanks stanl/td!  I knew there had to be an easier way.

I accomplished what I need by doing the following:

Thanks again!!