Editbox Scroll

Started by chrislegarth, September 28, 2018, 11:32:00 AM

Previous topic - Next topic

chrislegarth

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

stanl

maybe try adding  dialogcontrolstate(dlghandle, 2, 1, 2048) after dialogcontrolset(dlghandle, 2, 3, "Now displaying a very long password")

td

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


"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

chrislegarth

Thanks stanl/td!  I knew there had to be an easier way.

I accomplished what I need by doing the following:

  • Setting the On Focus No Selection, Cursor at Beginning style on the editbox.
  • Setting the focus on the editbox after updating it.
  • Returning focus to the control that updated the editbox.

Thanks again!!