Page 1 of 1

oGet:setSel() not working?

PostPosted: Fri Feb 03, 2006 4:07 pm
by James Bott
I can't seem to get the setSel() method of the TGet class to work. The following code doesn't show any highlighted text.

Code: Select all  Expand view
#include "fivewin.ch"

function main()
   local oDlg, oGet, cString:= "1234567"

   define dialog oDlg title "Test Get Select"

   @ 2,2 get oGet var cString of oDlg update

   activate dialog oDlg;
      on init (oGet:setSel(2,5), oGet:refresh())

return nil


It doesn't work with FWH 2.6, May 2005 build/Harbour 43, nor with Clipper. Am I doing something wrong, or maybe setSel() does something else?

James

Re: oGet:setSel() not working?

PostPosted: Fri Feb 03, 2006 5:54 pm
by Enrico Maria Giordano
This is a working sample:

Code: Select all  Expand view
#include "fivewin.ch"

function main()
   local oDlg, oGet, cString:= "1234567"

   define dialog oDlg title "Test Get Select"

   @ 2,2 get oGet var cString of oDlg update

   oDlg:bStart = { || oGet:SetSel(2,5) }

   activate dialog oDlg;
//      on init (oGet:setSel(2,5), oGet:refresh())

return nil


EMG

PostPosted: Fri Feb 03, 2006 8:11 pm
by James Bott
Enrico,

How odd. When I use the ON INIT it actually preprocesses to this:

{ |self| oGet:SetSel(2,5) }

If I do:

oDlg:bInit:= { |self| oGet:SetSel(2,5) }

It works just like you said also. But the same code doesn't work when assigned via the ON INIT clause. Strange.

I also tried doing it from a button action, but that wouldn't work either. I really need to do it via the GET's ON CHANGE clause. I have tried this:

@ 2,2 get oGet var cString of oDlg update on change oGet:setSel(2,5)

But that doesn't work either. The GET must be getting refreshed after bChange is called. I guess that is expected.

I am trying to build an autoComplete system, so I need to set the selected text after each keystroke. Any ideas?

James

PostPosted: Fri Feb 03, 2006 8:40 pm
by James Bott
Enrico,

Whoops. I didn't realize you were using oDlg:bStart NOT oDlg:bInit. bInit does not work, but bStart does. Now I get it.

I still need to figure out how to highlight text after each keystroke. I tried bKeydown also and that doesn't work either.

James

PostPosted: Fri Feb 03, 2006 9:58 pm
by Enrico Maria Giordano
Try this:

Code: Select all  Expand view
#include "fivewin.ch"

#define EM_SETSEL      177

function main()
   local oDlg, oGet, cString:= "1234567"

   define dialog oDlg title "Test Get Select"

   @ 2,2 get oGet var cString of oDlg update on change oGet:PostMsg( EM_SETSEL, 2, 5 )

   activate dialog oDlg

return nil


EMG

PostPosted: Fri Feb 03, 2006 10:05 pm
by James Bott
Enrico,

Wow, that seems to work!

I had already tried:

SendMessage( oGet:hWnd, EM_SETSEL, 2, 5 )

but that didn't work.

Thanks a lot.

James

PostPosted: Fri Feb 03, 2006 10:12 pm
by Enrico Maria Giordano
You're welcome, James! By the way, can we have the honour to see your face? :-)

EMG

PostPosted: Sat Feb 04, 2006 12:31 am
by tnhoe
James,

Sandeep's TDD class does it : Auto-complete from dbf

I use it since fw 1.95

U can download it from Patrick Mast's www.fivewin.info

PostPosted: Sat Feb 04, 2006 4:11 am
by James Bott
Hoe,

Thanks. I'll take a look. I do have mine working also, so it will be interesting to see how he did it too.

James