Jump to content

rich edit control (another?) - text format, color, links ...


grham
 Share

Recommended Posts

Hello,

this is another way to have a rich text box

with text formating: colors, size, .... of font,

links, etc.

I spent a lot of time on it lately. It begann with

arcker's project "AutoitPad" - I don't know if he

still works on it. I never wanted make a realy text editor, I only

wanted to have small edit controls with formated

text. That's also why I put it here.

I adapted it so that now it doesn't need "old" a3l,

added some functions. I don't say it's perfect or

that it doesn't need more work. I must give special thanks

to: Gary, arcker, Valery...., MSDN. If I forget someone tell me.

I learn much from them.

-To "this" rich edit.:

The example I posted in the AutoitPad thread had a bug (my fault!) that

you couldn't strem in and out any larger text. That's also why you couldn't

paste a tavle with 6 columns and 5 rows for example. Now it's correct.

a rich edit contro has a limit (by default) some 36 kBytes. But you can enlarge it

(see example) to your needs.

There's to say, that a major part of edit functions (edit control udfs

by autoit 3.2.10) work in rich edit too!

Tables: an incipient project. The exemple shows only how to paste a

"simple" table with few options (line color, cell color, line width ...)

There are some differences between "this" rich edit and Open Office for example.

Just copy and paste some tables. If you want to see the code relative to

a table, save it as selection (only the table - button "save sel.") and

open it with notepad. You can make some things "directly" like add a new row (cursor

at the and of a row and "enter", align a row or whole table horizontaly, format

and/or align text horizontaly, change the background color of a text but not so the background

color of a cell, align it verticaly. You have to set these values before pasting the table

or parse the code relative to a table created and, "extract" all the values and substituate

them with new values or add new values. For example by adding a column.

You can select a whole row but not one whole column. That's why there is much to do on it.

Well, I hope it's usefull to someone and good holidays to everybody.

Important: this is not an end product!

Oops: a confusing name

no problem: rich_edit.zip

Note: In earlier versions of Windows (ex: 98) the Msftedit.dll is not there and the rich edit

is created with riched20.dll. with Msftedit.dll you can make some more things than with riched20.dll.

for example align a text horizontaly in a table cell, ... for text only I don't see many differences.

For ex.: Windows XP has both of them. It checks first if there's Msftedit.dll.

Edited by grham
Link to comment
Share on other sites

One note more: when you save a richtext with links in it, the information

relative to the links is not saved. You have to save it in another way.

(for example an through an array of ranges).

By opening set the links again.

Edited by grham
Link to comment
Share on other sites

Do you use v 3.2.10? This structure should be in the includes.

If you don't have it just :

Global Const $tagNMHDR = "hwnd hWndFrom;int IDFrom;int Code"

before the first line that use it.

3.2.9.12 should be OK too

What an ......., I didn't put it:

tested with from 3.2.9.12

Some funcs are renamed and some constants, weren't there so

BTW: added some info to the first post!

Edited by grham
Link to comment
Share on other sites

Ok so I updated my autoIt(Thank you for notifying me of that)

However, I still receive errors.

CODE
E:\AUTOIT3 STUFF\Include\_RichEdit_912.au3(213,31) : WARNING: $tagNMHDR: possibly used before declaration.

Global $tagENLINK = $tagNMHDR &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\Include\_RichEdit_912.au3(530,45) : WARNING: $EM_LIMITTEXT: possibly used before declaration.

Return _SendMessage($hWnd, $EM_LIMITTEXT,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\RichEdit - exemple_912.au3(44,57) : WARNING: $EC_LEFTMARGIN: possibly used before declaration.

_GUICtrlEdit_SetMargins ($RichEdit, BitOR($EC_LEFTMARGIN,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\RichEdit - exemple_912.au3(44,74) : WARNING: $EC_RIGHTMARGIN: possibly used before declaration.

_GUICtrlEdit_SetMargins ($RichEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\RichEdit - exemple_912.au3(90,26) : WARNING: $WM_NOTIFY: possibly used before declaration.

GUIRegisterMsg($WM_NOTIFY,

~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\Include\_RichEdit_912.au3(530,45) : ERROR: $EM_LIMITTEXT: undeclared global variable.

Return _SendMessage($hWnd, $EM_LIMITTEXT,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\Include\_RichEdit_912.au3(282,104) : ERROR: _WinAPI_CreateWindowEx(): undefined function.

Return _WinAPI_CreateWindowEx($dwExStyle, $sRTFClassName, "", $dwStyle, $x, $y, $width, $height, $hWnd)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~^

E:\AUTOIT3 STUFF\RichEdit - exemple_912.au3(44,83) : ERROR: _GUICtrlEdit_SetMargins(): undefined function.

_GUICtrlEdit_SetMargins ($RichEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\RichEdit - exemple_912.au3(52,51) : ERROR: _GUICtrlEdit_AppendText(): undefined function.

_GUICtrlEdit_AppendText($RichEdit, "Title" & @CRLF)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\AUTOIT3 STUFF\RichEdit - exemple_912.au3 - 4 error(s), 5 warning(s)

I have a feeling that I am having trouble now due to my lack of experience with this new error console. =/

I am used to the builtin console.

Edited by MaudKip
Link to comment
Share on other sites

This is exactly what I get with 3.2.4.9 (The version I used up to now),

but not with 3.2.10 nor 3.2.9.12

If you give me some time, I could provide you the constants and the names of

the funcs.

1. _GUICtrlEdit_SetMargins() is in edit.au3 (v 3.2.10) (just don't use it by now)

2. _WinAPI_CreateWindowEx (name changed - look in your includes)

3. _GUICtrlEdit_AppendText (change it all to: _RichEdit_AddText)

Global Const $EM_LIMITTEXT = 0xC5

Global Const $EC_LEFTMARGIN = 0x1

Global Const $EC_RIGHTMARGIN = 0x2

Global Const $WM_NOTIFY = 0x4E

Edited by grham
Link to comment
Share on other sites

This is exactly what I get with 3.2.4.9 (The version I used up to now),

but not with 3.2.10 nor 3.2.9.12

If you give me some time, I could provide you the constants and the names of

the funcs.

Blah, I had some trouble finding the appropriate download.

They aren't labeled very well.

Yes though, those constants would be very helpful.

I would download the beta myself but I am on a school laptop and do not wish to install autoit for a third time on my flash drive.

Link to comment
Share on other sites

The replacements (file _RichEdit_912.au3):

Line #11:

$pEditStreamCallback = _DllCallBack("_EditStreamCallback", "ptr;ptr;long;ptr")

to

$pEditStreamCallback = DllCallbackRegister ("_EditStreamCallback", "dword", "ptr;ptr;long;ptr")

and (file RichEdit - exemple_912.au3)

Line #94:

_DllCallBack_Free($pEditStreamCallback)

to

DllCallBackFree($pEditStreamCallback)

allow to skip using of DllCallBack.au3 at all.

The point of world view

Link to comment
Share on other sites

To LazyCat: I'm glad that it works for you. :)

To JamesB: I had once your Betapad. I liked it, but I only got it once to work

with MS Word intalled (wanted to try it). I don't have MS Word normaly.

It was a realy editor, no?

The replacements (file _RichEdit_912.au3):

Line #11:

$pEditStreamCallback = _DllCallBack("_EditStreamCallback", "ptr;ptr;long;ptr")

to

$pEditStreamCallback = DllCallbackRegister ("_EditStreamCallback", "dword", "ptr;ptr;long;ptr")

and (file RichEdit - exemple_912.au3)

Line #94:

_DllCallBack_Free($pEditStreamCallback)

to

DllCallBackFree($pEditStreamCallback)

allow to skip using of DllCallBack.au3 at all.

This is what I thought too, only with an output "int", but have you tried it? Maybe for you it's OK

Edited by grham
Link to comment
Share on other sites

Excellent work. I don't continue to support this project until i'm using scintilla control.

I've tested to replace callback with implemented ones too but no way for EM_STREAMIN.

I don't have the time to go more on this proof of concept, but i'm happy to see that my work is used.

Continue.

BTW :

_RichEdit_InsertTable($hWnd)

YEAHHH ! excellent ! was dreaming of it :)

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

Fine! Thank you to all of you! :)

Valery, thank you for your apport.

To everybody: substituate the two things as Valery sais (post 11)

and you don't need the dllcallback.au3 include.

It just does'nt work for me (opening a file or saving to a file ....):

!>AutoIT3.exe ended.rc:-1073741819

If you don't get this, it's only on my pc reproducible and therefore No bug!

And don't forget to tell the resultat.

Edited by grham
Link to comment
Share on other sites

Fine! Thank you to all of you! :)

Valery, thank you for your apport.

To everybody: substituate the two things as Valery sais (post 11)

and you don't need the dllcallback.au3 include.

It just does'nt work for me (opening a file or saving to a file ....):

!>AutoIT3.exe ended.rc:-1073741819

If you don't get this, it's only on my pc reproducible and therefore No bug!

And don't forget to tell the resultat.

If I make either of the changes then the example crashes for me using Beta 3.2.9.14 when I try to insert a table. So I'm keeping it as your original post.

Excellent UDF grham, thanks.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

To everybody: substituate the two things as Valery sais (post 11)

and you don't need the dllcallback.au3 include.

There is a third thing, too. It's more important than first ones.

I forgot about pointer for struct EDITSTREAM. It uses pointer to callback procedure.

If you replace line #12 in file _RichEdit_912.au3

DllStructSetData($EDITSTREAM, "pfnCallback", $pEditStreamCallback)

to

DllStructSetData($EDITSTREAM, "pfnCallback", DllCallbackGetPtr($pEditStreamCallback))

then Table insert will works.

I'm sorry.

The point of world view

Link to comment
Share on other sites

There is a third thing, too. It's more important than first ones.

I forgot about pointer for struct EDITSTREAM. It uses pointer to callback procedure.

If you replace line #12 in file _RichEdit_912.au3

DllStructSetData($EDITSTREAM, "pfnCallback", $pEditStreamCallback)

to

DllStructSetData($EDITSTREAM, "pfnCallback", DllCallbackGetPtr($pEditStreamCallback))

then Table insert will works.

I'm sorry.

Thanks Valery, it works again now. :)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...