viewpoint-particle

Author Topic: Editbox Scroll  (Read 120 times)

chrislegarth

  • Newbie
  • *
  • Posts: 31
Editbox Scroll
« 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
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

  • Pundit
  • *****
  • Posts: 794
Re: Editbox Scroll
« Reply #1 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")

td

  • Tech Support
  • *****
  • Posts: 2595
    • WinBatch
Re: Editbox Scroll
« Reply #2 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
         case 3
             cntrlnum = 2
             DialogControlSet(dlghandle, cntrlnum, 3, "Now displaying a very long password")
             DialogControlState(dlghandle, cntrlnum, @dcsSetFocus, 0)  
             break
 

"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


chrislegarth

  • Newbie
  • *
  • Posts: 31
Re: Editbox Scroll
« Reply #3 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:
  • 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!!