CommDlg seems to richedit control stuck...??? Help needed

Started by xandaz, January 20, 2011, 06:58:01 PM

Previous topic - Next topic

jj2007

                                   mov     StreamStruct.pfnCallback,offset StreamInProc 
                                   .data
                                   wtf db "So we need to clear?", 0
                                   .code
                                   invoke  SendMessage,hRichEdit,WM_SETTEXT,NULL,addr wtf
                       
                                   invoke  SendMessage,hRichEdit,EM_STREAMIN,SF_TEXT,addr StreamStruct


Win32.hlp:

The EM_STREAMIN message replaces the contents of a rich edit control

xandaz


xandaz

   Hey... Help needed. I'm not sure about the alloc stuff. Do i need heapAlloc before allocating memory from the heap? What is a heap? Damn.... help...:(
   Copy and pasting get crazy and prog shuts down. thanks

dedndave

it is easy to use the heap
and, there is a default handle created for the process

INVOKE GetProcessHeap

returns the handle in EAX - store it in hHeap

figure out how many bytes you need...

INVOKE HeapAlloc,hHeap,NULL,BytesRequired

or, if you want it zero'ed

INVOKE HeapAlloc,hHeap,HEAP_ZERO_MEMORY,BytesRequired

that will return an address in EAX
the address is a kind of a handle, in a way, as it uniquely identifies the allocated block
i like to save it as hBlock

then, when you are done using the allocated block...

INVOKE HeapFree,hHeap,NULL,hBlock

xandaz

   Hey.... It's working. Later i'll add more stuff.

Tedd

You don't even need an empty string (for File-New), invoke SendMessage, hRichWnd,WM_SETTEXT,NULL,NULL clears the current contents.

Also, this isn't required - modify is set internally whenever the text changes. (You only need to clear it after you've saved a file, or opened a new one.)
    .elseif  uMsg==WM_CHAR
          invoke  SendMessage,hWnd,EM_SETMODIFY,TRUE,NULL



For your main problem, you should make a function named "confirm" which will check if the text has been modified (EM_GETMODIFY) and then ask the user if they would like to save, if it has been. If they choose 'Yes' then you call your function to save the file, if not, do nothing; then the function simply returns.
Call this function before doing anything else for File-New and File-Open actions.
No snowflake in an avalanche feels responsible.

xandaz

   Thanks a lot Tedd. I've been looking at jj's example and i guess i missed the EM_XXXMODIFY. Thanks.
xandaz.orgfree.com