PUBLIC UserControl ( )
|
USING System.Windows.Forms.* FROM ASSEMBLY.
CLASS DemoUserControl INHERITS Progress.Windows.UserControl: /* Variable for text box and button in control container */ DEFINE PRIVATE VARIABLE TextBox AS TextBox. DEFINE PRIVATE VARIABLE OkBtn AS Button. CONSTRUCTOR DemoUserControl ( ): InitializeComponents( ). END CONSTRUCTOR. METHOD PRIVATE VOID InitializeComponents( ): /* Instantiate text box and button classes */ TextBox = NEW TextBox ( ). OkBtn = NEW Button ( ). /* Set the text of the button, and text box */ TextBox:Text = "Enter text here". OkBtn:Text = "OK". /* Set the size and location of the container and controls */ THIS-OBJECT:Size = NEW System.Drawing.Size(200, 200). TextBox:Location = NEW System.Drawing.Point(15, 20). OkBtn:Size = NEW System.Drawing.Size(30, 20). OkBtn:Location = NEW System.Drawing.Point(125, 20). /* Add the text box and button controls to the container */ THIS-OBJECT:Controls:Add(TextBox). THIS-OBJECT:Controls:Add(OkBtn). END METHOD. END CLASS. |
USING System.Windows.Forms.* FROM ASSEMBLY.
CLASS DemoUserControlForm INHERITS Progress.Windows.Form: /* Variable for text box and button in control container */ DEFINE PRIVATE VARIABLE rUserControl AS DemoUserControl. CONSTRUCTOR DemoUserControlForm ( ): InitializeComponents( ). END CONSTRUCTOR. /* Display and wait for this modal form to close. The caller blocks at a call to this method */ METHOD PUBLIC VOID Wait ( ): WAIT-FOR Application:Run (THIS-OBJECT). END METHOD. METHOD PRIVATE VOID InitializeComponents( ): /* Instantiate user control */ rUserControl = NEW DemoUserControl ( ). /* Set the text of the form title, button, and text box */ THIS-OBJECT:Text = "This is my form". /* Set the location of the user control */ rUserControl:Location = NEW System.Drawing.Point(15, 20). /* Add the user control to the form */ THIS-OBJECT:Controls:Add (rUserControl). END METHOD. END CLASS. |
DEFINE VARIABLE rMyUIForm AS CLASS DemoUserControlForm.
rMyUIForm = NEW DemoUserControlForm(). rMyUIForm:Wait(). |