Richedit justify and numbering style bugs and fixes

Moderator: Rathinagiri

Post Reply
User avatar
kcarmody
Posts: 122
Joined: Tue Oct 07, 2014 11:13 am
Has thanked: 6 times
Been thanked: 16 times
Contact:

Richedit justify and numbering style bugs and fixes

Post by kcarmody » Wed Oct 22, 2014 12:16 pm

I have been using HMG rich edit controls heavily for the past few months and have discovered two bugs and fixes for them.

The first bug is that the justify alignment does not work, e.g.

Win.RichEditBox.ParaAlignment := RTF_JUSTIFY

has no effect and does not actually justify the text. After some searching, I found out that you must turn on "advanced typography" to get this to work. The following should be added to InitRichEditBox() in c_richeditbox.c:

SendMessage( hWndControl, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY );

"Advanced typography" sounds like it should be enable a big set of advanced features, but in fact the feature set it enables is quite small, and justification is the main one.

The second bug is that paragraph numbering styles that you get and set with the ParaNumberingStyle property do not match the constants in i_richeditbox.ch, e.g.

Win.RichEditBox.ParaNumberingStyle := RTF_PERIOD

actually sets the numbering style to two parentheses instead of a period. This is due to a mismatch between c_richeditbox.c lines 837-845 and 940-953, and i_richeditbox.ch lines 151-157. In the C code, numbering style 0 and PFNS_PAREN have the same effect, a right parenthesis after the number. So the first case is unnecessary, and the cases should start with PFNS_PAREN, which should be mapped to case 1.

However, I do not think the C code should be modified, as this would break existing applications that use it. Instead, I suggest adding some additional constants to i_richeditbox.ch that reflect the actual values in the C code, e.g.

#define RTF_PAREN_2 3 // Follows the number with a right parenthesis.

I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;

Kevin

User avatar
serge_girard
Posts: 2332
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 574 times
Been thanked: 124 times
Contact:

Post by serge_girard » Wed Oct 22, 2014 12:35 pm

Thanks Kevin !

Serge

EduardoLuis
Posts: 651
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Has thanked: 1 time
Been thanked: 61 times

Post by EduardoLuis » Wed Oct 22, 2014 1:27 pm

Hi Kevin:

My first words are: EXCELLENT job.-
I've download and apply new libraries, and it works absolutely fine.-
A suggestion to all users:
1) First rename both original files to individualitate as OLD
2) Copy both libraries each on it's root (INCLUDE and SOURCES)
3) Re Build libraries twice: one choosing ANSI option, and when it finish choose UNICODE
After that, chances take place and you'll enjoy both improvements.

Again Kevin, Excellent Job, and thanks to share with us.-
With regards.
Eduardo

User avatar
esgici
Posts: 4513
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Wed Oct 22, 2014 2:06 pm

kcarmody wrote:I have been using HMG rich edit controls heavily for the past few months ...

I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg
...
Hello Mr. Carmody

You are welcome aboard of HMG_Forum :)

Thanks a lot for your valuable participation.

And surely we will benefit by your huge experience and knowledge :arrow:

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D

User avatar
danielmaximiliano
Posts: 2137
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 154 times
Been thanked: 23 times
Contact:

Post by danielmaximiliano » Wed Oct 22, 2014 2:37 pm

Gracias / Thanks Kevin....
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Wed Oct 22, 2014 3:14 pm

Wow ! Thank you Kevin for you fix of it and sharing with us.

Have you are welcome to our community ! :D

Nice work in AksharaPad !

Image
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
kcarmody
Posts: 122
Joined: Tue Oct 07, 2014 11:13 am
Has thanked: 6 times
Been thanked: 16 times
Contact:

Post by kcarmody » Wed Oct 22, 2014 6:00 pm

Thank you everyone for your kind words -- including Pablo for noticing my HMG project AksharaPad -- but it looks now like I was wrong about the second bug. There is no mismatch between the constants in i_richeditbox.ch lines 151-157 and the code in c_richeditbox.c lines 837-845 and 940-953. So the second bug I reported does not exist.

However it is still true that RTF_NONE and RTF_PAREN (style numbers 1 and 2) produce the same effect, a right parenthesis. So RTF_NONE is not necessary and is misnamed. The numbering style which eliminates punctuation is RTF_NONUMBER.

I've posted a new version of i_richeditbox.ch, with the proposed additions of RTF_PAREN_2 etc. removed, to my site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;

Kevin

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Wed Oct 22, 2014 6:33 pm

kcarmody wrote:I have been using HMG rich edit controls heavily for the past few months and have discovered two bugs and fixes for them.

The first bug is that the justify alignment does not work, e.g.

Win.RichEditBox.ParaAlignment := RTF_JUSTIFY

has no effect and does not actually justify the text. After some searching, I found out that you must turn on "advanced typography" to get this to work. The following should be added to InitRichEditBox() in c_richeditbox.c:

SendMessage( hWndControl, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY );

"Advanced typography" sounds like it should be enable a big set of advanced features, but in fact the feature set it enables is quite small, and justification is the main one.

The second bug is that paragraph numbering styles that you get and set with the ParaNumberingStyle property do not match the constants in i_richeditbox.ch, e.g.

Win.RichEditBox.ParaNumberingStyle := RTF_PERIOD

actually sets the numbering style to two parentheses instead of a period. This is due to a mismatch between c_richeditbox.c lines 837-845 and 940-953, and i_richeditbox.ch lines 151-157. In the C code, numbering style 0 and PFNS_PAREN have the same effect, a right parenthesis after the number. So the first case is unnecessary, and the cases should start with PFNS_PAREN, which should be mapped to case 1.

However, I do not think the C code should be modified, as this would break existing applications that use it. Instead, I suggest adding some additional constants to i_richeditbox.ch that reflect the actual values in the C code, e.g.

#define RTF_PAREN_2 3 // Follows the number with a right parenthesis.

I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;" onclick="window.open(this.href);return false;

Kevin
Thanks Kevin for report the bug and fix.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México
Has thanked: 1 time
Been thanked: 2 times

Post by Javier Tovar » Thu Oct 23, 2014 3:26 am

Muy bien Kevin, Gracias por ver los errores y contribuir en su corrección.
Bienvenido a HMG.
Saludos desde México.

User avatar
bpd2000
Posts: 1077
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 197 times
Been thanked: 96 times

Post by bpd2000 » Tue Oct 28, 2014 12:05 pm

Hi Mr. Kevin
Welcome from India
Than you for your contribution
BPD
Convert Dream into Reality through HMG

Post Reply