How to use SetDlgItemInt & SetDlgItemText to set numbers and text in a EDITTEXT in sequence

4example, I want use SetDlgItemInt to a number "40" to a EDITTEXT,and use SetDlgItemText to set the unit "GB" after the number in the same EDITTEXT,but the code below is that the 2nd cmd cover the 1st cmd, so it display only "GB" in the EDITTEXT.

invoke	SetDlgItemInt,hDlgItem,IDC_EDITTEXT,number,FALSE
invoke SetDlgItemText,hDlgItem,IDC_EDITTEXT,addr szFmt

How can solve the problem?
Posted on 2005-12-14 04:03:00 by Eric4ever
there is impossible. you should use eg. wsprintf for this, or you can set number into edit, then read it as text, add " GB" and send again into edit - it is possible, but does not look well
Posted on 2005-12-14 04:07:15 by Shoo
I can use fomat "%d GB" and wsprintf to solve it...

I want to know is there another way? Just get the end of text in the EDITTEXT,and SetDlgItemText after it 8)
Posted on 2005-12-14 04:23:39 by Eric4ever
then you may get offset of textbuffer of the editcontrol and directly add string to it, then update control.
Posted on 2005-12-14 04:51:46 by Shoo
though using dword2string+strcat would be better, here is api-only way:

invoke SetDlgItemInt,hDlgItem,IDC_EDITTEXT,number,FALSE
invoke GetDlgItem,hDlgItem,IDC_EDITTEXT
invoke GetWindowTextLength,eax
invoke SendDlgItemMessage,hDlgItem,IDC_EDITTEXT,EM_SETSEL,eax,eax
invoke SendDlgItemMessage,hDlgItem,IDC_EDITTEXT,EM_REPLACESEL,0,T(' GB')
Posted on 2005-12-14 15:50:57 by drizz