The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ossama on January 25, 2008, 05:41:18 PM

Title: rich edit and 'paste' operation
Post by: ossama on January 25, 2008, 05:41:18 PM
i create a richedit control , i need when i paste a text with diffrent font/color/... it will not change the font/color/... exactly like notepad in windows xp (try to copy a text with diffrent fonts/colors it will not be paste with that font/color) how can i do that in masm?
Title: Re: rich edit and 'paste' operation
Post by: jj2007 on January 25, 2008, 08:57:10 PM
Try this link (http://msdn2.microsoft.com/en-us/library/bb787877(VS.85).aspx). None of this is specific to MASM, so just use the official documentation.
Title: Re: rich edit and 'paste' operation
Post by: xmetal on January 26, 2008, 05:27:35 AM
When I first wanted such a functionality, I tried using EM_SETTEXTMODE. I had Windows 98 back then and the message simply didn't work. You could easily paste all the rich text you wanted in the "plain text mode" rich edit. I haven't tried it on Windows XP but I doubt it works. I think its one of those too-good-to-be-true offerings from Microsoft.

The solution that I have used thus far is this:


invoke SendMessage,[hwnd],WM_SETFONT,[hfont],1
invoke SendMessage,[hwnd],EM_SETCHARFORMAT,SCF_ALL,addr cfmt        ; cfmt.dwMask=CFM_COLOR


The order of calls is important.
Title: Re: rich edit and 'paste' operation
Post by: jj2007 on January 26, 2008, 09:13:12 AM
Try to paste some formatted text in the attached RichEd.exe. For me, simple pasting works fine.

[attachment deleted by admin]
Title: Re: rich edit and 'paste' operation
Post by: xmetal on January 26, 2008, 10:20:07 AM
Quote from: jj2007 on January 26, 2008, 09:13:12 AM
Try to paste some formatted text in the attached RichEd.exe. For me, simple pasting works fine.

It happily accepts rich text...
Title: Re: rich edit and 'paste' operation
Post by: ossama on January 26, 2008, 10:41:34 AM
when i paste a text with color/font it is pasted with that color/font
i think i didnt explain my problem well,what i need when i paste a text with any color and font it will be pasted with black and system font in the rich edit control
Title: Re: rich edit and 'paste' operation
Post by: hutch-- on January 26, 2008, 11:07:27 AM
ossama,

here is the code to use with riched 2 and later.


          Case 1101
            invoke SendMessage,hEdit,WM_UNDO,0,0

          Case 1102
            invoke SendMessage,hEdit,EM_REDO,0,0

          Case 1103
            invoke SendMessage,hEdit,WM_CUT,0,0

          Case 1104
            invoke SendMessage,hEdit,WM_COPY,0,0

          Case 1105
            invoke SendMessage,hEdit,EM_PASTESPECIAL,CF_TEXT,NULL

          Case 1106
            invoke SendMessage,hEdit,WM_CLEAR,0,0


This is the code to make the control text only.


        invoke SendMessage,hEdit,EM_SETTEXTMODE,TM_PLAINTEXT or \
                                                TM_MULTILEVELUNDO or \
                                                TM_MULTICODEPAGE, 0
Title: Re: rich edit and 'paste' operation
Post by: ossama on January 26, 2008, 12:33:50 PM
thank you hutch--,it works  :U
Title: Re: rich edit and 'paste' operation
Post by: ossama on January 26, 2008, 12:34:44 PM
and i dont forgot the others who helped me.
thank you all.