Here's what I am trying to do. I press a button on the form and it is suppose to concatenate the button's text to another variable. But it isn't doing it at all. Here's part of the code I am using...

code:--------------------------------------------------------------------------------
.DATA?
buff db 80 dup(?)
.
.
.
.CODE
.
.
.
.IF ax==BTN_ID1
     shr eax, 16
          .IF ax==BN_CLICKED
               INVOKE lstrcat, buff, ADDR b1Txt
               INVOKE SetWindowText, hEdit, ADDR buff
          .ENDIF
.ENDIF

;NOTE:  hEdit is the handle of my edit control and b1Txt is the text I want to add to buff.
--------------------------------------------------------------------------------
edit: check this when you wish to post code don't use PRE tag, use...s I am assuming that either "buff" is declared incorrectly, or I am screwing something up with the "lstrcat" call. If you would like to see the entire code, tell me. This message was edited by Hiroshimator, on 2/12/2001 9:24:22 PM
Posted on 2001-02-09 20:19:00 by James
The first argument of lstrcat is a pointer to the first string. So, just like the invoke of SetWindowText, you need to use ADDR buff.
Posted on 2001-02-09 21:01:00 by tank
It still won't do anything. "buff" still doesn't contain a value. :( Any ideas?
Posted on 2001-02-09 22:15:00 by James
You can always write the concatenation routine yourself. It's quite easy, in fact:

strcat proc OutString:DWORD,Str1:DWORD,Str2:DWORD
; OutString = Str1 + Str2
pushad

mov edi,Str1
mov ecx,-1
xor eax,eax
repnz scasb  ; Get string length
not ecx  ; This is a quick trick to obtain
dec ecx  ; the number of letters in the string

mov edi,OutString
mov esi,Str1
rep movsb  ; copy string - NULL terminator

mov esi,edi
mov edi,Str2
mov ecx,-1
xor eax,eax
repnz scasb  ; String length again
not ecx
; dec ecx   ; This time, we want the NULL terminator

mov edi,esi
mov esi,Str2
rep movsb  ; Copy string

popad
ret
strcat endp
edit check this: when you wish to post code don't use PRE tag, use...s Of course, this is a definite extreme, but if nothing else works, I'll guarrantee this routine does. :) This message was edited by Hiroshimator, on 2/12/2001 9:25:01 PM
Posted on 2001-02-10 03:49:00 by Racso
James, If you are using MASM32v6, use the library procedure "szCatStr" it will blow the API into the weeds. invoke szCatStr,ADDR lpszSource,ADDR lpszAdd (Next version is faster) :) Regards, hutch@pbq.com.au This message was edited by hutch--, on 2/10/2001 5:18:25 AM
Posted on 2001-02-10 05:17:00 by hutch--
Well if

    INVOKE lstrcat, ADDR buff, ADDR b1Txt
doesn't work, an improved version of lstrcat won't work any better. What is in buff and b1Txt just before lstrcat gets invoked? This message was edited by tank, on 2/10/2001 5:49:33 PM
Posted on 2001-02-10 17:45:00 by tank
lstrcat PROTO s1:DWORD,s2:DWORD

s1 is the first portion of the string, as well as the destination buffer, while s2 is the string to append to s1.  For instance:

.data

szDisplay db "Hello world!  ", 32 dup (0)
szStrcat  db "lstrcated!",0

.code

invoke lstrcat,addr szDisplay,addr szStrcat
edit: check this when you wish to post code don't use PRE tag, use...s Now, in szDisplay is "Hello world! lstrcated". That's how lstrcat works. It's a little screwy, if you ask me, which is why I prefer my routine. That way, you don't have to worry so much about having extra room in a string, or of ruining the contents of a string. This message was edited by Hiroshimator, on 2/12/2001 9:25:40 PM
Posted on 2001-02-10 23:58:00 by Racso
to Steve: From what I saw in numerous sources which used conplex one string formation from several strings (a la wsprintf) IMHO: The whole approach is deadly wrong - 1. We don't need to know SIZE of strings - we need to starting address to begin sending attachment to string 2. If we are to connect more then one string we can easilly manage that after first connection we have a pointer ready to use for next connection:

	mov edi,offset str1 -1
@@:	inc edi
	mov al,
	or al,al
	jne @B
;edi == address we start with
;attach 1st string
	dec edi
	lea esi,str2

@@:	inc edi
	mov al,
	mov ,al
	inc esi
	or al,al
	jne @B

;attach next string

	dec edi
	lea esi,str3 ;or string Next

@@:	inc edi
	mov al,
	mov ,al
	inc esi
	or al,al
	jne @B

;and so on no matter how many strings you want to attach to the end of
;made in prior formation. Result will always be ASCIIZ, and work is done
;without double cheking for zero end 1st when culculating size then
;decrimenting counter and cheking if it's zero

The above can be formated to C like proc with :VARARG of any number string
addresses.
Like CatManyStr proc NumOfArg:DWORD,StrToAttachTo:DWORD,StrAddresses:VARARG

 It will have prolog:

	mov edi,offset str1 -1
@@:	inc edi
	mov al,
	or al,al
	jne @B
;edi == address we start with

And inner loop:

	dec edi
	lea esi,strNext ;or string Next

@@:	inc edi
	mov al,
	mov ,al
	inc esi
	or al,al
	jne @B
edit: check this when you wish to post code don't use PRE tag, use...s To repead it as many times as number of string addresses it recieves. Using the number as counter and part of pointer to get next passed address from the stack. And it will do the work ~ 3 times faster than common approach. This message was edited by Hiroshimator, on 2/12/2001 9:26:30 PM
Posted on 2001-02-12 08:59:00 by The Svin

;To Hutch:
;check it out please - just wrote as a gift for your personal ;work
;with MASM32, hope it fits M32LIB
;IMNSHO it's fastest and universal ASCIIZ CatStrings proc
;change the names of arg if you like
;p1 = number of strings to attach p2 = addr of the string to attach to
;then addresses of strings in order you prefer them to be connected:

.386
.model flat,stdcall
option casemap:none
include C:\masm32\include\windows.inc
include C:\masm32\include\user32.inc
include C:\masm32\include\kernel32.inc
includelib C:\masm32\lib\user32.lib
includelib C:\masm32\lib\kernel32.lib

CatManyStrings proto C :DWORD,:DWORD,:VARARG
.data
num1 db 'one ',0
num2 db 'two ',0
num3 db 'three ',0
num4 db 'four ',0
msg db 'Begin: ', 128 dup (0)
.data?
emptystr db 128 dup (?)
.code
start:
;forward:
invoke CatManyStrings,4,addr msg,addr num1,addr num2,addr num3, addr num4
invoke MessageBox,0,addr msg,0,0
;forward + backward:
invoke CatManyStrings,4,addr msg,addr num4,addr num3,addr num2,addr num1
invoke MessageBox,0,addr msg,0,0
;forward + backward + odd:
invoke CatManyStrings,2,addr msg,addr num1,addr num3
invoke MessageBox,0,addr msg,0,0
;forward + backward + odd + even:
invoke CatManyStrings,2,addr msg,addr num2,addr num4
invoke MessageBox,0,msg,0,0
;forward to empty string:
mov emptystr,0
invoke CatManyStrings,4,addr emptystr,addr num1,addr num2,addr num3,addr num4
invoke MessageBox,0,addr emptystr,0,0
call ExitProcess
	
	
CatManyStrings proc C uses edi esi p1:DWORD,p2:DWORD,p3:VARARG
	mov edi,p2
	xor ecx,ecx
	lea edx,p3
	dec edi
@@:	inc edi
	mov al,
	or al,al
	jne @B
newstr:	dec edi
	mov esi,
@@:	inc edi
	mov al,
	mov ,al
	inc esi
	or al,al
	jne @B
	inc ecx
	cmp ecx,p1
	jne newstr
	ret
CatManyStrings endp
end start
edit: check this when you wish to post code don't use PRE tag, use...s This message was edited by Hiroshimator, on 2/12/2001 9:27:06 PM
Posted on 2001-02-12 14:28:00 by The Svin
when you wish to post code, use the appropriate tags. That way smilies won't kill your text and indentation is kept as you intended it to. look here for more info: when you wish to post code don't use PRE tag, use...s
Posted on 2001-02-12 21:28:00 by Hiroshimator