flat assembler
Message board for the users of flat assembler.

Index > Windows > need help regarding rich edit STREAMIN callback function

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi,
i can't figure out, why my text wouldn't show in the richedit window using the following code. could somebody please give me some advice.

Code:
t1      db 'The callback function return...',13,10,0
t2      db 'An EM_AUTOURLDETECT message enables or di...',13,10,0

struct EDITSTREAM
        dwCookie        dd ?
        dwError         dd ?
        pfnCallback     dd ?
ends
    

Code:
        invoke  lstrlen,t1
                        mov  [siSize],eax
                        mov  [chatEs.dwCookie],t2
                        mov  [chatEs.dwError],1
                        mov  [chatEs.pfnCallback],proc_streamin_callback
        invoke  SendMessage,[ppH],EM_STREAMIN,SF_TEXT,chatEs
    


and the callback function
Code:
proc proc_streamin_callback dwCookie,pbBuff,maByte,transByte
                push ebx esi edi
        
                ; the maByte value is 4kb

                push [siSize]
                pop  [transByte]
invoke  RtlMoveMemory,[pbBuff],[dwCookie],[transByte]

invoke  MessageBox,NULL,[pbBuff],f0,MB_OK

                ; mov  eax,0 <- result error if eax = 0
        
                pop  edi esi ebx
                ret
endp
    


Description: the full source (lite testing code)
Download
Filename: test.zip
Filesize: 2.46 KB
Downloaded: 80 Time(s)

Post 07 Jan 2006, 04:13
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
vbVeryBeginner,

The callback function should return 0, zero, to indicate sucess. You have mov eax, 0 commented out. Try uncommenting it.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 07 Jan 2006, 16:41
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi farrier,
i got this if i mov eax,0
Image
thats why i commented it out

i read that too from PSDK,
psdk wrote:

The callback function returns zero to indicate success.

but i don't know which part i am wrong. Sad
Post 07 Jan 2006, 19:07
View user's profile Send private message Visit poster's website Reply with quote
jdawg



Joined: 26 Jun 2005
Posts: 39
jdawg
When you make a MessageBox, eax is the location of the return value of the button being pushed. Try making a little exception handler for the MessageBox before you return from the procedure. something like this.
Code:
proc proc_streamin_callback dwCookie,pbBuff,maByte,transByte 
                push ebx esi edi 
         
                ; the maByte value is 4kb 

                push [siSize] 
                pop  [transByte] 
invoke  RtlMoveMemory,[pbBuff],[dwCookie],[transByte] 

invoke  MessageBox,NULL,[pbBuff],f0,MB_OK 
                
                cmp   eax,ID_OK   ;allows you to hold for a button press which will then allow you to write to eax           
                je      @f
 
           @@:
                mov  eax,0          
                pop  edi esi ebx 
                ret 
endp
    
Post 07 Jan 2006, 21:58
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
well, even if i commented the invoke MessageBox, the error still occurs.

Code:
                invoke  RtlMoveMemory,[pbBuff],[dwCookie],[transByte]
                ;comment ---- invoke    MessageBox,NULL,[pbBuff],f0,MB_OK
                        mov  eax,0 ;<- result error if eax = 0
                        pop  edi esi ebx
    


actually the MessageBox is a test function to see if i successfully copied the string t2 into pBuff, and it seems the string is copied into the buffer. but it just won't show up in richedit control.

Code:
cmp   eax,ID_OK   ;allows you to hold for a button press which will then allow you to write to eax    

sorry, i couldn't understand wat you mean.
Post 07 Jan 2006, 23:20
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
hi, i have this from a very old project, sorry its nasm (before i discovered the magic of fasm xD)

Code:
%define cookie ebp+8
%define pbbuf ebp+12
%define cb ebp+16
%define pcb ebp+20
@streaminproc:
    push ebp
    mov ebp, esp

    push ebx
    push esi
    push edi

    push 0
    push dword[pcb]
    push dword[cb]
    push dword[pbbuf]
    push dword[cookie]
    call [ReadFile]

    xor eax, 1

    pop edi
    pop esi
    pop ebx

    mov esp, ebp
    pop ebp

    retn 16
;---
    

_________________
redghost.ca
Post 08 Jan 2006, 03:35
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
thanks redghost,
that is to use the readfile function to handle to streamin process.

wat i wish to attain is just to simply move a string into the rich edit control. i think it should be simple, but somehow, i don't know why, and which part i made mistake. Confused

ps:i know the SetWindowText :p k, but need to use streamin for some reason.
Post 08 Jan 2006, 04:06
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
vbVeryBeginner,

Well, if you want to do it the easy way:

Try EM_REPLACESEL and EM_SETSEL. To add text to the current cursor positon, EM_SETSEL with -1, -1 to unselect all text and EM_REPLACESEL with TRUE, pointer_to_text

All my experience has been exactly like RedGhost, using EM_STREAMIN with ReadFile to do printing from an RTF control.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 08 Jan 2006, 14:32
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
ya farrier, i see that from tomasz's quetannon example too.
but i find it weird, why i can't use the EM_STREAMIN to insert just a sentence of ascii? and when i mov eax,0, the application clashed.

but according to psdk, this callback function is not limited on the just readfile and writefile.
Post 08 Jan 2006, 23:30
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.