The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: mineiro on August 06, 2010, 01:41:17 AM

Title: how to expand/collapse text in richedit
Post by: mineiro on August 06, 2010, 01:41:17 AM
Hello,
how can I do expand/collapse text in a multiline richedit?
I know how to hide the selected text, but, and after?
regards, thank very much in advance.

Title: Re: how to expand/collapse text in richedit
Post by: Twister on August 06, 2010, 03:26:05 AM
I don't think you can expand or close text in a multi-textbox. I think that is only for listboxes. Could you give me a program example (some program that does this), or take a picture of yours?
Title: Re: how to expand/collapse text in richedit
Post by: hutch-- on August 06, 2010, 03:37:45 AM
mineiro,

I have seen it done with custom edit controls but its not a normal feature of any of the richedit family of controls. Its possible if you designed a notation for a "folded" block of text but it would be messy to add to a rich edit control.
Title: Re: how to expand/collapse text in richedit
Post by: mineiro on August 06, 2010, 04:12:57 AM
thanks for the answer Sr hutch--, now I understand why I cannot find in radasm/asmedit source.
so my idea is now, create a bar in the left of edit box, draw a button that changes to '+' or '-', and store the line number of selected hidden text in some file, and after some changes in the text reconfigure it, well, it will give some work. (Is this a best option? or it can be done more easy using listbox or another control?)
Sr Devil Pixels, I refer to programs like above.
To hide or show the selected text, I'm using the code below:
.data?
FORMATAR   CHARFORMAT2 <?>
.code
;select some text before hit this
   .elseif WParam == VK_F4
   mov FORMATAR.cbSize, sizeof FORMATAR
   invoke SendMessage,Manipulador_edit,EM_GETCHARFORMAT,SCF_SELECTION,addr FORMATAR      ;get selected text
   mov FORMATAR.dwMask,CFM_HIDDEN
   mov FORMATAR.dwEffects,CFE_HIDDEN
   invoke SendMessage,Manipulador_edit,EM_SETCHARFORMAT,SCF_SELECTION,addr FORMATAR      ;hide it
;but if it is saved in plain text, I lose where it is hided(and I like to save in plain text), so, for a while I save it in rtf format to don't lose where it is.

        .elseif WParam == VK_F6   ;show hidden text, need more work here
   mov FORMATAR.cbSize, sizeof FORMATAR
   invoke SendMessage,Manipulador_edit,EM_GETCHARFORMAT,SCF_ALL,addr FORMATAR
   mov   FORMATAR.dwMask,CFM_HIDDEN
   invoke SendMessage,Manipulador_edit,EM_SETCHARFORMAT,SCF_SELECTION,addr FORMATAR

regards, thanks and peace.
Title: Re: how to expand/collapse text in richedit
Post by: jj2007 on August 06, 2010, 06:48:09 AM
Quote from: mineiro on August 06, 2010, 04:12:57 AMif it is saved in plain text, I lose where it is hided(and I like to save in plain text

When streaming out plain text, RichEdit 3.0 includes hidden text while 4.1 writes only the visible text.
Title: Re: how to expand/collapse text in richedit
Post by: mineiro on August 06, 2010, 03:59:44 PM
thank Sr jj2007, I'm learning about richedit and don't know about different versions, only comments of a old tutorial.
I play with your edit program, it's fine, really thanks.
Title: Re: how to expand/collapse text in richedit
Post by: Twister on August 07, 2010, 03:22:09 AM
Oh okay! I finally understood what you were talking about! Give me some time to make an example for you. :bg
Title: Re: how to expand/collapse text in richedit
Post by: jj2007 on August 07, 2010, 06:53:36 AM
The versions are a tricky story indeed ;-)
Here is what I use to get the best version:
mov esi, offset LibNameOffice
invoke LoadLibrary, esi ; user-copied \masm32\RichMasm\Dll\RichEditOffice.DLL
.if !eax
mov esi, RichEditV$ ; esi is a MAX_PATH buffer
invoke ExpandEnvironmentStrings, chr$("%CommonProgramFiles%"), esi, MAX_PATH
mov ebx, eax
invoke lstrcat, esi, chr$("\Microsoft Shared\OFFICE11\RichEd20.DLL")
invoke LoadLibrary, esi ; RichEd20.dll, Office 11 version
.if !eax
mov byte ptr [esi+ebx+24], "2" ; convert Office11 to Office12
invoke LoadLibrary, esi ; RichEd20.dll, Office 12 version
.if !eax
mov esi, offset LibName
invoke LoadLibrary, esi ; "RichEd20.dll" for poor people
.endif
.endif
.endif
Title: Re: how to expand/collapse text in richedit
Post by: mineiro on August 07, 2010, 02:12:59 PM
appreciate this snipplet Sr jj2007.
grazie.