I understand how to stream text from a file into a rich edit control, but how do I stream data from tcp packets to rich edit control? What do I put in my StreamIn Proc?
Posted on 2003-05-15 18:42:03 by xkardisx
Assuming you want to capture all data coming through the socket, a very simple way to do it would be...

In the callback proc, call recv on a connected socket, specifying the pbBuff parameter of the EditStreamCallback as the buffer, and the cb parameter as the number of bytes to read. When recv returns, set the dword value pointed to by pcb with the number of bytes actually read, or return nonzero in eax if recv fails.

This will probably freeze your whole message thread while it waits on recv calls, so you might want to create the edit control in another thread.
Posted on 2003-05-15 19:03:59 by iblis
what do i put for the editstream.dwCookie field? im a bit confused and msdn isnt helping much either.

im using windows messanging to handle my sockets

when i get a fd_read call
i want to stream the whole data into the richedit field every single time. if u use wm_settext it just replaces it. its kinda of confusing. dont i need a file handle, or do i use the socket handle? gawd this is confusing. i just want continous text from the data packet inside the rich edit control everytime new data come. bleh.
Posted on 2003-05-15 19:31:24 by xkardisx
i dun think im doing it right, it keep crashin



invoke recv,[hSocket1],addr pBuffer,NumBytes,0
mov eax, NumBytes
mov pBytesRead,DWORD PTR eax
xor eax,1
ret


lol better to post wrong code then no code, im confused obviosly--how does the program know what NumBytes (cb) is?
Posted on 2003-05-15 19:55:46 by xkardisx
hmm probably using addr of pBuffer is wrong too, shud just be pBuffer.. one error solved, not for the rest? lol
Posted on 2003-05-15 19:59:46 by xkardisx
more bad code


invoke recv,[hSocket1],pBuffer,NumBytes,0
invoke lstrlen,pBuffer
mov pBytesRead,eax
xor eax,1
ret
Posted on 2003-05-15 20:02:11 by xkardisx
well last one didnt crash, but i dont get any text :(
Posted on 2003-05-15 20:02:57 by xkardisx
im curious, when i start typing, and then it try to read data, how come it overwrite the whole thing instead of adding to the end of whats there in the rich edit control?
Posted on 2003-05-15 20:04:16 by xkardisx
If you're using the FD_XXX windows messages, the socket isn't blocking, so you'll need to set it to blocking beforehand.

invoke WSAAsyncSelect, sockt, hwind, 0, 0
mov argp, 0
invoke ioctlsocket, sockt, FIONBIO, addr argp


edit: oh yeah don't forget to reset it when you're done. if you still want to get socket window messages.
Posted on 2003-05-15 21:51:53 by iblis
Okay an easier question, since I'm having too hard a time with this.

How do I append text to the end of a rich edit control? Let's just take for example, I have two normal edit boxes and I want to get the the text from the two edit boxes, and I want to add that to my rich edit control one after another. What's the easiest/best way to do that? :)

Okay, to be even simplier. Three edit boxes. Two of them are say 'username' and 'password', how would I add username then password one after another in the third box, and also add any other text (without typing or pasting them in). Would I have to recreate the buffer (ie, start a new buffer, add username, add password, and add any new thing) and then send another wm_settext message or is there a way to actually add on w/o rebuffering and resending every single thing (which is timeconsuming). I want a way to dynamically add text at any time, in addition to what's already there... it seem very easy but I'm struggling here. Bleh.
Posted on 2003-05-15 23:06:44 by xkardisx
invoke SendMessage, hEditWnd, EM_SETSEL, -1, -1
invoke SendMessage, hEditWnd, EM_REPLACESEL, 0, addr someString
Posted on 2003-05-15 23:31:19 by iblis
i love u ibilis, thanks
Posted on 2003-05-15 23:56:38 by xkardisx