Jump to content

Embedded activeX component - RichText


kjactive
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • 3 months later...

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
Link to comment
Share on other sites

Link to comment
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 ;)

Link to comment
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

Link to comment
Share on other sites

  • 2 months later...

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...

Link to comment
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?

Link to comment
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
Link to comment
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

Link to comment
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?

Link to comment
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.

Link to comment
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:

Link to comment
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).

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...