FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oGet:setSel() not working?
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

oGet:setSel() not working?

Posted: Fri Feb 03, 2006 04:07 PM
I can't seem to get the setSel() method of the TGet class to work. The following code doesn't show any highlighted text.

#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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: oGet:setSel() not working?

Posted: Fri Feb 03, 2006 05:54 PM
This is a working sample:

#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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

oGet:setSel() not working?

Posted: Fri Feb 03, 2006 08:11 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

oGet:setSel() not working?

Posted: Fri Feb 03, 2006 08:40 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

oGet:setSel() not working?

Posted: Fri Feb 03, 2006 09:58 PM
Try this:

#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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

oGet:setSel() not working?

Posted: Fri Feb 03, 2006 10:05 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

oGet:setSel() not working?

Posted: Fri Feb 03, 2006 10:12 PM

You're welcome, James! By the way, can we have the honour to see your face? :-)

EMG

Posts: 83
Joined: Tue Nov 08, 2005 11:09 AM

oGet:setSel() not working?

Posted: Sat Feb 04, 2006 12:31 AM

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

Regards

Hoe, email: easywin3@yahoo.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

oGet:setSel() not working?

Posted: Sat Feb 04, 2006 04:11 AM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion