Sign in to follow this  
Followers 0
kjactive

Embedded activeX component - RichText

24 posts in this topic

#1 ·  Posted (edited)

Here is a embedded activeX script to include the nice RichText component, needs

RICHTX32.OCX in system32 but it's probably already there and activated else

activate it in run with this command 'regsvr32 MSCOMCT2.OCX'

RichText format is one of the formats that Office WinWord/Word can use but this control can also drop icons into it and save the contence as graphics - well a lot of options. A information page link is provided some information...

; Author:    Kåre Johansson
; AutoIt Version: 3.1.1.55
; Description: Very Simple example: Embedding RICHTEXT object
; Needs: MSCOMCT2.OCX in system32 but it's probably already there
; Date:    3 jul 2005

#include <GUIConstants.au3>
$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

GUICreate ( "Embedded RICHTEXT control Test", 320, 200, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 180, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$AboutC = GUICtrlCreateButton('About',105,177,70,20)
$PrefsC = GUICtrlCreateButton('FontSize',175,177,70,20)
$StatC = GUICtrlCreateButton('Plain Style',245,177,70,20)

$GUIActiveX    = GUICtrlCreateObj( $oRP, 10, 10 , 400 , 260 )
GUICtrlSetPos($GUIActiveX,10,10,300,160)
$LinkoRP = ObjEvent($oRP,"IEEvent_","FolderView"); this is a dummy event handle

With $oRP; Object tag pool
    .OLEDrag()
    .SelBullet = True
    .text = "hello - Au3 supports ActiveX components like the RICHTEXT thanks to SvenP" & @CRLF & 'Try write some text and quit to reload'
    If FileExists("C:\RichText.rtf") Then .LoadFile("C:\RichText.rtf", 0) 
    .Enabled = True
    .HideSelection = False
    .SaveFile("C:\RichText.rtf", 0 )
    .SelStart = 0
    .SelLength = StringLen(.Text)
    .SelFontSize = 14
    .SelBold = True
    .SelItalic = True
    .SelUnderline = True
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            $oRP.SaveFile("C:\RichText.rtf", 0 )
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.officecomputertraining.com/vbtutorial/tutpages/page36.asp','', @SW_HIDE)
        Case $msg = $AboutC
            $oRP.AboutBox() 
        Case $msg = $PrefsC
            $oRP.SelFontSize = 12
        Case $msg = $StatC
            $oRP.SelBold = False
            $oRP.SelItalic = False
            $oRP.SelUnderline = False 
    EndSelect
WEnd

$oRP = 0
GUIDelete ()
Exit

I do like Autoit3 activeX support - there is that many strange controls or options to be included as one almost can't emagine...

Application save contence as C:\RichText.rtf at every quit and reload at startup...

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites



Too bad it crashes...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It works... But the "font size" button didn't work for me.

When I exited out, AutoIt crashed.

Edited by layer

FootbaG

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Fontsize do only change a selected text area and works alright. Regarded the Crash at exit I can see that I forgot to free the com obj at exit - Sorry, please change code...

$oRP = 0
GUIDelete ()
Exit

kjactive ;)

Edited by kjactive

Share this post


Link to post
Share on other sites

Fontsize do only change a selected text area and works alright. Regarded the Crash at exit I can see that I forgot to free the com obj at exit - Sorry, please change code...

$oRP = 0
GUIDelete ()
Exit

kjactive ;)

crash

Share this post


Link to post
Share on other sites

You should post a bug report, kjactive.

GUICtrlDelete also does not work.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Well I do not get any crashes with this code, using the latest beta updates and you don't need to free the control ID $GUIActiveX...

There could also be a conflick somewhere with the com object on your computer...

kjactive ;)

Share this post


Link to post
Share on other sites

Me again.

I'm just trying to add some more options to your script but it seems as i'm having some problems.

how can you add something like color or the font (e.g. times new roman)? i don't get it!

1 more question: does someone see a possibility of storing the richtext in an inifile? maybe converting to something like that:

original: this is my text

stored in ini: this is /u/my/u/ text

any ideas? i could use some help

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Me again.

I'm just trying to add some more options to your script but it seems as i'm having some problems.

how can you add something like color or the font (e.g. times new roman)? i don't get it!

1 more question: does someone see a possibility of storing the richtext in an inifile? maybe converting to something like that:

original: this is my text

stored in ini: this is /u/my/u/ text

any ideas? i could use some help

@Nuffilein805

First, create a document in WordPad using all the features you wish to have in the text you want to display using AutoIt and the mentioned .OCX file.

Next, save it as an RTF file.

Next, open that file in a text editor like Scite, Crimson, ore even Notepad if you are running Win2K or later.In the opened file you will see all the internal code required to display the file as you designed it. Give that example of the RTF file structure you should be able to assemble any message you wish to display in your GUI using the .OCX file and Kjactive's example.

You should also view the file created by Kjactive's script and note any internal differences.

@kjactive Please give a different URL for reference, the one in the original script and its base URL appear to go nowhere.

Gene

Edited a typos...

Edited by Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

I have the same problem as Randall. I have regsvr32'd both MSCOMCT2.OCX and RICHTX32.OCX, which has succeeded every time, and both are in my system32 directory. When I run the script, the ObjCreate statement fails (returns a zero), causing everything after it to crash and burn. Any ideas?

Share this post


Link to post
Share on other sites

Hi,

I found a "Quickbooks" forum where people were having trouble on WinXP Pro [not Home edition] and getting permissions right; , complicated registry entry solution which I won't be trying?...

Best, Randall

Share this post


Link to post
Share on other sites

kjactive,

It is advisable always to place a if @error then .... after a ObjCreate() function. Objects are not always available on all computers/Operating Systems.

@randallc & Sokko : To see a more descriptive error message about why ObjCreate() failed, you can add a COM ErrorHandler to the script. If you don't know how to do this, kjactive can show you. :-)

I don't think the solution in that "Quickbooks" forum applies, because you did not get any error message while 'registering' the OCX with regsvr32.

-Sven

Share this post


Link to post
Share on other sites

Okay, I figured out how to do the error-thing through the help file. On the line that does the ObjCreate, these values come up:

$err.number = -2147221230

Hex($err.number,8) = 80040112

$err.windescription = "Class is not licensed for use"

All other values are 0 except for $err.scriptline. I included the Hex'd value because that's what the help file did to it, so maybe it's more useful than the "raw" form. Otherwise I really have no idea what any of that stuff means. Help?

Share this post


Link to post
Share on other sites

Okay, I just had a thought after searching around for some time. Brief request for anyone that has actually gotten this control working: Could you look in the registry under HKCR\Licenses and see if there's a folder name that starts with 3B7C8860-D78F? If so, please post the data contained in it. This is just a guess at a solution, so any actual concrete fixes for this problem would still be appreciated.

Share this post


Link to post
Share on other sites

I did a search and came up with this result..

HKEY_CLASSES_ROOT\CLSID\{3B7C8860-D78F-101B-B9B5-04021C009402}

standard: Microsoft Rich Textbox Control 6.0 (SP6)

MiscStatus: 0

InprocServer32: Treading model: Apartment

Progid: RICHTEXT.RichtextCtrl.1

typeLib: {3B7C8863-D78F-101B-B9B5-04021C009402}

Version: 1.2

VersionIndependentProgID: RICHTEXT.RichtextCtrl

kjactive :lmao:

Share this post


Link to post
Share on other sites

I did a search and came up with this result..

{3B7C8860-D78F-101B-B9B5-04021C009402}

So when you look under HKCR\Licenses, is there a key there that matches this ID? It's the contents of that key that I would be interested in, if they exist (if not, this solution is going nowhere).

Share this post


Link to post
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
Sign in to follow this  
Followers 0