News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

RichEdit MDI example

Started by Buek, September 04, 2016, 01:23:04 AM

Previous topic - Next topic

Buek

I have written a small sample application of an MDI editor program (win32) which uses standard edit controls as child windows. I would like to write a similar program using RichEdit but I am having difficulties because streaming does not work properly. I always get a blank child window. I suspect that there is something wrong with the registration of the RichEdit class. Does anyone know where I can get the masm or C source code of a small RichEdit MDI sample program that could help me solve the problem?

Thanks a lot for any hints.

Best regards, Buek

HSE

\masm32\examples\exampl06\riched
Equations in Assembly: SmplMath

Buek

Many thanks. A lot to learn from that RichEdit example, eventhough it seems to be an SDI application.

jj2007

Another example...

include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl RichEd, "richedit", w750
  GuiControl Listbox, "listbox", x750, w250
  GetFiles *.rc|*.as?|*.inc               ; fill Files$() array with assembler sources
  SortFiles                               ; most recent on top
  SetListbox "** select a file **"        ; set a title in the listbox
  SetListbox Files$()                     ; fill the listbox
Event Command
  .if NotifyCode==LBN_SELCHANGE && LbSel>0   ; if user selects a file from the list...
      SetWin$ hRichEd=FileRead$(LbSel$)      ; ... get its content and display it
  .endif
GuiEnd                  ; OPT_Icon Smiley ; tell RichMasm to add an icon


Some people here, inter alia Hutch and myself, have a lot of experience with the RichEdit control. It's quite buggy, but we are here to help :icon14:

HSE

Yes, it's SDI (and first step).
MDI examples are a little more complex:
      - WinAsm ( http://www.winasm.net/)
      - RadAsm (https://svn.code.sf.net/p/fbedit/code/RadASM30/)
Equations in Assembly: SmplMath


HSE

#6
Hi JJ!

(in theory) You can use assembler option /Fo changing /project/properties/release/assemble. Perhaps there is another solution.

I used WinAsm for a short time, like editor and assembling from a batch. The problem was RadAsm release have some fixed colors in menus, and with my color settings I don't see nothing. When I found RadAsm source I recompiled it with better colors.

I think WinAsm work very nice, the main reason to use RadAsm is ObjAsm32 projects.  :biggrin:   

Later: calender is assembled well without any setting modification. I just create the project in the same folder with an empty file cal.asm, that I erase later, and I added all the files to the project.
Equations in Assembly: SmplMath

jj2007

Thanks, HSE - moving the .wap file to the source folder fixed the problem :t

Buek

At long last I managed to solve the problem. I mixed up the class names of the RichEdit control and the child window.

I encountered some major problem with the streaming process for file reading in RichEdit though. As soon as the EBX register is changed in the handler procedure (est.pfnCallback), the streaming process crashes. Saving the EBX register before any additional stuff is done in the pfnCallback routine and restoring EBX afterwards has solved the issue in my case. I am sure that this is a well known "property" of RichEdit but I just wanted to mention it here.

Many thanks for your comments which have helped a lot.

Best regards, Buek

jj2007

Quote from: Buek on September 07, 2016, 08:16:56 PMSaving the EBX register before any additional stuff is done in the pfnCallback routine and restoring EBX afterwards has solved the issue in my case.

esi edi ebx MUST be restored in EVERY callback proc.

Buek

That explains all the problems which I had with that callback function. It however seems that such issues are not documented in any of Microsoft's RichEdit pages.

jj2007

M$ won't give you that info because they use compilers, not assemblers. See:
- Preservation of esi, edi, ebx in general code
- Register usage in PROCs
- Is EBP a protected register?
- Windows API does not preserve esi, edi, ebx (treats EM_STREAMOUT explicitly)
- Preserving Registers (Hutch, f0dder, Ultrano, drizz & others)