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.