Question Using Ocx Microsoft richtextbox

Abbashatim

New Member
I would like to use Microsoft tichtextbox ocx.
But I do not know how to use it.
Can anyone guide me.
I need to create .rtf file. Show it on the text box. Update it within the program with different font size and type.
I am writing a POS application where user chooses an item to sell . The invoice (or receipt) is displayed in the richtextbox showing the items being bought and the total amount. This gets updated every time an item is purchased . At the end I need to print this rtf file.
How to send rtf to printer directly.

are there any samples or documents that I can follow.
Any type of help is welcomed.
Thanks
 

RealHeavyDude

Well-Known Member
Using OCX always works the same way in the Progress ABL.

Basically you drop it onto a frame and then you access the properties of the OCX control via the handle the AppBuilder created for you. The properties differ from OCX to OCX, therefore I can't give you anything on the richtextbox OCX from Microsoft.

Although this for the Crystal Reports Viewer OCX, nevertheless it should get you started:
http://knowledgebase.progress.com/articles/Article/P55350

Heavy Regards, RealHeavyDude.
 

Abbashatim

New Member
Thanks RealHeavyDude.

I have used ocx before. but not richtextbox. if someone has used before it would be helpful.
thank you.
 

RealHeavyDude

Well-Known Member
The Pro*Tools in the AppBuilder contain a COM Object View which allows you to open the OCX file. In the past I've used this handy tool to inspect OCXs - although I have to admit that it didn't work for each OCX that I tried to use it for. I said in the past because I've not done anything with OCX controls for about 10 years or so. Nowadays I use the .NET objects accessible with the bridge to the .NET common language runtime that came into the ABL ( I think ) with OE10.2.

Heavy Regards, RealHeavyDude.
 

Osborne

Active Member
I have done some simple work with a rich text box but it was for .NET not OCX. If as RealHeavyDude points out you are on OE10.2 or later that may be the better option. If you can use .NET the following example should get you started. Run it, enter some text, select some of the text using the mouse and click a button to set different font styles:
Code:
DEFINE VARIABLE hWin AS HANDLE NO-UNDO.
DEFINE VARIABLE MainForm AS Progress.Windows.Form NO-UNDO.
DEFINE VARIABLE RichTextBox AS System.Windows.Forms.RichTextBox NO-UNDO.
DEFINE VARIABLE WinContainer AS Progress.Windows.WindowContainer NO-UNDO.

DEFINE BUTTON btnBold LABEL "Bold Selected Text" SIZE 27 BY 1.14.
DEFINE BUTTON btnColor LABEL "Color Selected Text" SIZE 27 BY 1.14.
DEFINE BUTTON btnExit LABEL "Exit" SIZE 20 BY 1.14.
DEFINE BUTTON btnUnderline LABEL "Underline Selected Text" SIZE 27 BY 1.14.

DEFINE FRAME f1
  btnBold AT ROW 18.14 COL 4
  btnUnderline AT ROW 18.14 COL 32
  btnColor AT ROW 18.14 COL 60
  btnExit AT ROW 19.57 COL 79
  WITH NO-BOX SIDE-LABELS THREE-D AT COL 1 ROW 1 SIZE 100 BY 20.

CREATE WINDOW hWin ASSIGN
  HEIGHT = 20
  WIDTH  = 100.
FRAME f1:PARENT = hWin.

ON CHOOSE OF btnBold IN FRAME f1 DO:
   RichTextBox:SelectionColor = System.Drawing.Color:Black.
   RichTextBox:SelectionFont = new System.Drawing.Font("Arial", 18.25, System.Drawing.FontStyle:Bold, System.Drawing.GraphicsUnit:Point, Progress.Util.CastUtil:ToByte(0)).
END.

ON CHOOSE OF btnColor IN FRAME f1 DO:
   RichTextBox:SelectionColor = System.Drawing.Color:Blue.
END.

ON CHOOSE OF btnExit IN FRAME f1 DO:
   MainForm:Close().
END.

ON CHOOSE OF btnUnderline IN FRAME f1 DO:
   RichTextBox:SelectionFont = NEW System.Drawing.Font("Microsoft Sans Serif", 8.25, System.Drawing.FontStyle:Underline, System.Drawing.GraphicsUnit:Point, Progress.Util.CastUtil:ToByte(0)).
END.

/* Create the .NET rich text box. */
RichTextBox = NEW System.Windows.Forms.RichTextBox().
RichTextBox:Location = NEW System.Drawing.Point(10, 10).
RichTextBox:Name = "RichTextBox".
RichTextBox:Size = NEW System.Drawing.Size(480, 340).

/* Create the .NET form. */
MainForm = NEW Progress.Windows.Form().
MainForm:Text = "Rich Text Box Example".
MainForm:ClientSize = NEW System.Drawing.Size(hwin:WIDTH-PIXELS, hwin:HEIGHT-PIXELS).
MainForm:Controls:Add(RichTextBox).
MainForm:FormClosed:Subscribe("Window_FormClosed").
MainForm:Show().

/* Create the WindowContainer, embedding the window into it. */
WinContainer = NEW Progress.Windows.WindowContainer().
WinContainer:Size = NEW System.Drawing.Size(hWin:WIDTH-PIXELS, hWin:HEIGHT-PIXELS).
WinContainer:EmbeddedWindow = hWin.
WinContainer:Parent = MainForm.
WinContainer:Show().

ENABLE ALL WITH FRAME f1.
VIEW hWin.

WAIT-FOR System.Windows.Forms.Application:Run(MainForm).

PROCEDURE Window_FormClosed:
   DEFINE INPUT PARAMETER sender AS System.Object NO-UNDO.
   DEFINE INPUT PARAMETER e AS System.EventArgs NO-UNDO.

   DELETE WIDGET hWin.
END PROCEDURE.
 

RealHeavyDude

Well-Known Member
Almost all Progress products are commercial products which you can't just download somewhere. All development products of Progress are commercial.

In order to be able to download the products you've purchased you need a corresponding account in the download center ( https://secure.progress.com/oam/UI/Login?goto=https://secure.progress.com/profile/sec/auth/esd ). Initially this account gets set up for you and your account manager @ Progress is responsible for the media and license addendums for the products you've purchased are showing up there. Usually you then setup different people from your company to access the download center with their Progress ID.

As Osborne already laid out, depending on the version of Progress OpenEdge you are using the product you need is either called the OpenEdge Architect ( I guess pre-OE11.3 ) or the Progress Developer Studio. It's the same product - an Eclipse plug-in - just rebranded.

If you have an OpenEdge Studio license - the infamous AppBuilder - then most likely you can switch to the Progress Developer Studio at no extra cost as Progress most likely will grant you a trade-in for the existing OpenEdge Studio license.


Heavy Regards, RealHeavyDude.
 
Top