flat assembler
Message board for the users of flat assembler.

Index > Windows > RichEdit 6.0 and Math Zones:

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 27 May 2008, 15:23
Disclaimer #1:

I'm not a lawyer, but I'm fairly certain version 6.0 RICHED20.DLL and the Cambria fonts cannot be distributed without permission from Microsoft. If your clients have Office 2007, or Microsoft Math then it's installed.

Getting RichEdit version 6.0 and Cambria fonts:
  • install the trial version of Microsoft Math, http://www.microsoft.com/math/
  • copy RICHED20.DLL from the install directory
  • uninstall Microsoft Math (optional)
Note: the Cambria fonts will remain after uninstall - which is good Wink

Disclaimer #2:

RICHED20.DLL 6.0 will break other software if installed over the windows directory version. Just put it in the application directory or load from some obscure location.

Translation from Murray Sargent's (long time RichEdit developer) blog:
(Read link above because you'll need the constants and execution environment specifics if you intend to use this code, and the blog is very informative in general.)

Code:
ToggleMathZone:
       sub esp,sizeof.CHARFORMAT2W - 4
     pushd sizeof.CHARFORMAT2W

       ; return address and three arguments to SendMessage, plus structure on stack
        label .hWndRE dword at esp+16+sizeof.CHARFORMAT2W

       invoke SendMessage,[.hWndRE],EM_GETCHARFORMAT,SCF_SELECTION or SCF_ONLYCFEFFECTS,esp
        btc [esp+CHARFORMAT2W.dwEffects+3],4 ; CFE_MATH ; test & Toggle math zone flag
  jc .off
     ; Turn on LineServices
      invoke SendMessage,[.hWndRE],EM_SETTYPOGRAPHYOPTIONS,TO_ADVANCEDTYPOGRAPHY,TO_ADVANCEDTYPOGRAPHY
    ; Enable built-in math autocorrect
  invoke SendMessage,[.hWndRE],EM_SETADJUSTTEXTPROC,1,0

   virtual at 0
                du "Cambria Math"
         du LF_FACESIZE dup (0)
              ; create set of data constants
              rept 16 i:0 { load ___data#i dword from 4*i }
         macro SETFACE dest { rept 16 i:0 \{ mov dword[(dest)+4*i],___data\#i \} }
        end virtual
 SETFACE esp+CHARFORMAT2W.szFaceName

     mov [esp+CHARFORMAT2W.lcid],MATH_LCID
       mov [esp+CHARFORMAT2W.dwMask],CFM_MATH or CFM_FACE or CFM_LCID
      invoke SendMessage,[.hWndRE],EM_SETCHARFORMAT,SCF_SELECTION or SCF_ONLYCFEFFECTS,esp
        add esp,sizeof.CHARFORMAT2W
 retn 4

.off: mov [esp+CHARFORMAT2W.dwMask],CFM_MATH
      invoke SendMessage,[.hWndRE],EM_SETCHARFORMAT,SCF_SELECTION or SCF_ONLYCFEFFECTS,esp
        add esp,sizeof.CHARFORMAT2W
 retn 4    

Just "stdcall ToggleMathZone,[hRE]" to create a Math Zone.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup


Last edited by bitRAKE on 27 May 2008, 16:43; edited 1 time in total
Post 27 May 2008, 15:23
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 27 May 2008, 15:41
Erm, what is a math zone?

Your code seems to just set/unset the font of a selection, but where is this code supposed to be inserted? Where is .hWndRE defined?
Post 27 May 2008, 15:41
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 27 May 2008, 16:07
http://research.microsoft.com/workshops/fs2006/presentations/17_Sargent_071706.ppt

You should learn how to use your home page. Smile

.hWndRE is a local label - the first argument on the stack. Might want to read the blog entry linked to in the first post. Not only does it set the font (special font, btw), but it enables some advanced typography features and autocorrection. Basically, you need a RichEdit control handle.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 27 May 2008, 16:07
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 27 May 2008, 16:27
bitRAKE wrote:
http://research.microsoft.com/workshops/fs2006/presentations/17_Sargent_071706.ppt

You should learn how to use your home page. Smile
Hehe, good retort!
bitRAKE wrote:
.hWndRE is a local label - the first argument on the stack.
Oh yeah, I didn't see that on my initial scan.
bitRAKE wrote:
Might want to read the blog entry linked to in the first post. Not only does it set the font (special font, btw), but it enables some advanced typography features and autocorrection. Basically, you need a RichEdit control handle.
Oh, I also missed the link, I thought it was just underlined.

Shucks, I need to take a break, been working too hard. Embarassed
Post 27 May 2008, 16:27
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 28 May 2008, 02:54
The version of RICHED20.DLL with Microsoft Math is actually 12.0.16.1019 -- it's the control within the DLL which is version 6.0, class name "RICHEDIT60W". Unfortunately, I cannot post the DLL or needed fonts, but I can attach an example program for those who'd like to try it out.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 28 May 2008, 02:54
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 01 Jun 2008, 05:11
Math Zone syntax is fairly easy, imho. Auto-correction will convert symbol names to the symbol (e.g. \alpha, \theta), and automatically create syntax groups based on function names or start/end synbols (e.g. matching (), {}, [], etc.). Also, there are built-in macros (\binomial, \integral, \limit, \quadratic, ...), but I haven't figured out how to create custom macros. No doubt there is some official documentation somewhere.


Description: Built-in macros showing multi-scope dynamic highlighting during edit.
Filesize: 9.46 KB
Viewed: 5463 Time(s)

mzmac.png



_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 01 Jun 2008, 05:11
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 27 Jun 2008, 02:13
Found some good instruction on using Math Zones:
http://ist.uwaterloo.ca/ec/equations/equation2007.html

The best guide as is really:
http://unicode.org/notes/tn28/UTN28-PlainTextMath-v2.pdf

All the keyboard entry I've tried so far seems to work.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 27 Jun 2008, 02:13
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.