2. the selection by default is wrong!
Here is a picture to show this bug:

http://tinypic.com/kmb0w
Moderators: Hacker, petermad, Stefan2, white
This can't be, the two are 100% code-identical except for the fix in the parallel port connection...Now it's clear that the rename bug is in v6.03a.
This functionality in v6.03 is ok.
Ghisler is right. I tested in Windows 2000 localized Chinese version and no problem too. So I suggest you should test it in Windows XP and you can represent the issue.ghisler(Author) wrote:I have just tried it with an English Windows 2000: Both with English and simplified Chinese as default language the selection is 100% correct! There must be something different to localized Chinese versions...
This can't be, the two are 100% code-identical except for the fix in the parallel port connection...Now it's clear that the rename bug is in v6.03a.
This functionality in v6.03 is ok.
Code: Select all
0042D184 /$ 55 PUSH EBP
0042D185 |. 8BEC MOV EBP,ESP
0042D187 |. 83C4 F8 ADD ESP,-8
0042D18A |. 53 PUSH EBX
0042D18B |. 56 PUSH ESI
0042D18C |. 8BF2 MOV ESI,EDX
0042D18E |. 8BD8 MOV EBX,EAX
0042D190 |. 8D45 FC LEA EAX,DWORD PTR SS:[EBP-4]
0042D193 |. 50 PUSH EAX
0042D194 |. 8D45 F8 LEA EAX,DWORD PTR SS:[EBP-8]
0042D197 |. 50 PUSH EAX
0042D198 |. 68 B0000000 PUSH 0B0
0042D19D |. 8BC3 MOV EAX,EBX
0042D19F |. E8 A870FFFF CALL TOTALCMD.0042424C
0042D1A4 |. 50 PUSH EAX ; |hWnd
0042D1A5 |. E8 EE8BFDFF CALL <JMP.&user32.SendMessageA> ; \SendMessageA
0042D1AA |. 0375 F8 ADD ESI,DWORD PTR SS:[EBP-8]
0042D1AD |. 8975 FC MOV DWORD PTR SS:[EBP-4],ESI
0042D1B0 |. 8B45 FC MOV EAX,DWORD PTR SS:[EBP-4]
0042D1B3 |. 50 PUSH EAX
0042D1B4 |. 8B45 F8 MOV EAX,DWORD PTR SS:[EBP-8]
0042D1B7 |. 50 PUSH EAX
0042D1B8 |. 68 B1000000 PUSH 0B1
0042D1BD |. 8BC3 MOV EAX,EBX
0042D1BF |. E8 8870FFFF CALL TOTALCMD.0042424C
0042D1C4 |. 50 PUSH EAX ; |hWnd
0042D1C5 |. E8 CE8BFDFF CALL <JMP.&user32.SendMessageA> ; \SendMessageA
0042D1CA |. 5E POP ESI
0042D1CB |. 5B POP EBX
0042D1CC |. 59 POP ECX
0042D1CD |. 59 POP ECX
0042D1CE |. 5D POP EBP
0042D1CF \. C3 RETN
Code: Select all
procedure TCustomEdit.SetSelLength(Value: Integer);
var
Selection: TSelection;
begin
SendMessage(Handle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
Selection.EndPos := Selection.StartPos + Value;
SendMessage(Handle, EM_SETSEL, Selection.StartPos, Selection.EndPos);
SendMessage(Handle, EM_SCROLLCARET, 0,0);
end;
As I mentioned above, EM_SETSEL is DBCS sensitive, that means even you set 3 to EM_SETSEL on 2 Chinese characters (4 bytes), it only select 1 character too (2 bytes). So I think you can just simply use Length() function to calculate the string length and pass it to EM_SETSEL will make it work fine in all versions of Windows.ghisler(Author) wrote:2cheming
Yes, Total Commander uses EM_SETSEL to set the selection length. However, it uses CharNext() to count the number of characters in the string. Actually this seems to be a bug in Windows XP that EM_SETSEL works differently than in all other Windows versions - EM_SETSEL seems to select bytes on XP, while it selects characters on all other windows versions.
I will try to solve it like this:
1. Select entire field
2. Check how long the selection is via EM_GETSEL
3. Depending on the return value, use the one or other length for EM_SETSEL