Sign in to follow this  
Followers 0
yawoo

UDF _GUICtrlListBox not working for chinese characters

2 posts in this topic

I would like to write a ListBox with UP and DOWN button to move the selected item going up and down.

The code is worked for plain ASCII lists. But if the list item contains chinese characters, the chinese characters will be trimed about two characters each move, as shown in screenshots. It seems that the UDF code is still not worked for non-plain ASCII characters yet. Any workaround solution? Thx a lot.

CODE
Case $iMsg = $hBatchUp

$i = _GUICtrlListBox_GetCurSel($hBatch)

If $i > 0 Then

_GUICtrlListBox_SwapString($hBatch, $i-1, $i)

_GUICtrlListBox_SetCurSel($hBatch, $i-1)

EndIf

Case $iMsg = $hBatchDown

$i = _GUICtrlListBox_GetCurSel($hBatch)

If $i <> -1 Then

_GUICtrlListBox_SwapString($hBatch, $i+1, $i)

_GUICtrlListBox_SetCurSel($hBatch, $i+1)

EndIf

post-5354-1218129622_thumb.jpg

post-5354-1218129635_thumb.jpg

post-5354-1218129645_thumb.jpg

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It seems that _GUICtrlListBox_GetText cannot return the chinese string properly.

Here is my solution, it use GUICtrlRead to retrieve the list string instead of.

CODE
Case $iMsg = $hBatchUp

$i = _GUICtrlListBox_GetCurSel($hBatch)

If $i > 0 Then

$s = GUICtrlRead($hBatch)

_GUICtrlListBox_SetCurSel($hBatch, $i-1)

_GUICtrlListBox_ReplaceString($hBatch, $i, GUICtrlRead($hBatch))

_GUICtrlListBox_ReplaceString($hBatch, $i-1, $s)

_GUICtrlListBox_SetCurSel($hBatch, $i-1)

EndIf

Case $iMsg = $hBatchDown

$i = _GUICtrlListBox_GetCurSel($hBatch)

If $i <> -1 Then

$s = GUICtrlRead($hBatch)

_GUICtrlListBox_SetCurSel($hBatch, $i+1)

_GUICtrlListBox_ReplaceString($hBatch, $i, GUICtrlRead($hBatch))

_GUICtrlListBox_ReplaceString($hBatch, $i+1, $s)

_GUICtrlListBox_SetCurSel($hBatch, $i+1)

EndIf

Edited by yawoo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0