Combobox - mark text and place cursor at the end in the SLE part of the CB

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
buddla59
Posts: 2
Joined: Tue Mar 29, 2016 9:45 am

Combobox - mark text and place cursor at the end in the SLE part of the CB

Post by buddla59 »

Hello,

after more than 10 years of abstinence from VO, I have to make some changes in an application (VO 2.8 SP4b) for my previous client.

Several combo boxes should be given an autofill function. This also works quite well so far. A text suggestion is written into the edit control of the combo box, only the cursor is placed at the beginning. However, the text change should be marked and the cursor should be placed at the end.

I implemented the search for a text suggestion in '__EditChange'.

Code: Select all

METHOD __EditChange() AS VOID PASCAL CLASS cmbAutoFill

   //
   // CurrenText in dem Item-Array suchen 
   //
   
   LOCAL dwItemNo    AS DWORD
   LOCAL cValue      AS STRING
   LOCAL dwLenValue  AS DWORD

   SUPER:__EditChange() 

   cValue     := SELF:CurrentText
   dwLenValue := SLen(cValue)

   IF SLen(cValue) > 0
      IF (dwItemNo := AScan(SELF:_aItemList, {|x| Upper(x) = Upper(cValue)})) > 0     
         SELF:CurrentText := AllTrim(SELF:_aItemList[dwItemNo])
      ENDIF 
   ENDIF

RETURN
How can I solve the problem?

Code: Select all

SELF:selection := Selection {dwOldCurPos, -1}
doesn't work or is not available.

Thanks for the help and sorry for my bad english.

Harry
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

Combobox - mark text and place cursor at the end in the SLE part of the CB

Post by Karl-Heinz »

Hi Harry,

You must send the selection to the edit control of the combobox.

Code: Select all

SELF:CurrentText := AllTrim(SELF:_aItemList[dwItemNo])
PostMessage( SELF:EditHandle , EM_SETSEL, 0 , -1 )   // <-------
regards
Karl-Heinz
buddla59
Posts: 2
Joined: Tue Mar 29, 2016 9:45 am

Combobox - mark text and place cursor at the end in the SLE part of the CB

Post by buddla59 »

Hi Karl-Heinz,

thanks for the help. Works as it should.

regards
Harry
Post Reply