Hello,
I want to add numbers from 2 to 99 to a combobox. How can i do this?
How can it be done faster?
I want to add numbers from 2 to 99 to a combobox. How can i do this?
How can it be done faster?
The following works for me:
or without the invoke syntax
Note: It's a bit hard to say how it can be done faster if you haven't shown any code to start with ;)
.data
FormatString db "%d",0
LOCAL Buffer[2]: BYTE
.
.
.
xor ecx, ecx
inc ecx
AddNext:
inc ecx
push ecx
invoke wsprintf, ADDR Buffer, ADDR FormatString, ecx
invoke SendMessage, hWndCombo, CB_ADDSTRING, NULL, ADDR Buffer
pop ecx
cmp ecx, 99
jne AddNext
or without the invoke syntax
.data
FormatString db "%d",0
LOCAL Buffer[2]: BYTE
.
.
.
xor ecx, ecx
inc ecx
AddNext:
inc ecx
push ecx
push ecx
push OFFSET FormatString
lea eax, DWORD PTR
push eax
call wsprintf
lea eax, DWORD PTR
push eax
push 0
push CB_ADDSTRING
push hWndCombo
call SendMessage
pop ecx
cmp ecx, 99
Note: It's a bit hard to say how it can be done faster if you haven't shown any code to start with ;)
Thank you Timbo.
By the word "faster" I meant, without using an API such as wsprint. Just using our own small and optimized proc if there are any.
By the word "faster" I meant, without using an API such as wsprint. Just using our own small and optimized proc if there are any.
Ah, I see. In the short time i've been using this board, I've come across a number of integer -> string conversion routines. Just search the board for dword to string or int to string and you'll come up with something. Here's some threads that might help you.
http://www.asmcommunity.net/board/index.php?topic=8716
http://www.asmcommunity.net/board/index.php?topic=16030
http://www.asmcommunity.net/board/index.php?topic=8716
http://www.asmcommunity.net/board/index.php?topic=16030
hakand: in this particular example I wouldn't worry too much about speed, even on the slowest machine able to run win95 it would be irrelevant :). But of course there's other situations where integer->string speed can matter, so it's a useful technique to know.
Also, moving this thread to WinAPI, since Algorithms is more about presenting and testing algorithms.
Also, moving this thread to WinAPI, since Algorithms is more about presenting and testing algorithms.