News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

how to expand/collapse text in richedit

Started by mineiro, August 06, 2010, 01:41:17 AM

Previous topic - Next topic

mineiro

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.


Twister

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?

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

mineiro

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.

jj2007

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.

mineiro

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.

Twister

Oh okay! I finally understood what you were talking about! Give me some time to make an example for you. :bg

jj2007

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

mineiro

appreciate this snipplet Sr jj2007.
grazie.