Resolved Show value when loading progressbar, in richTextBox1

Rafeda Malki

New Member
Hi,

I have cretaed a progressbar and it loading with diffrent value in diffrent status.
i need to add text message when the progressbar is loading.
If i added pause in the Method setrichTextBox1value, i get the text and its pause for each time
I want to get this text in the box

any help with this?
-----------------------------------------

code in class
DEFINE PRIVATE VARIABLE components AS System.ComponentModel.IContainer NO-UNDO.
DEFINE PRIVATE VARIABLE progressb1 AS System.Windows.Forms.ProgressBar NO-UNDO.
DEFINE PUBLIC VARIABLE richTextBox1 AS System.Windows.Forms.RichTextBox NO-UNDO.

METHOD PRIVATE VOID InitializeComponent( ):

THIS-OBJECT: progressb1 = NEW System.Windows.Forms.ProgressBar().
THIS-OBJECT:richTextBox1 = NEW System.Windows.Forms.RichTextBox().
THIS-OBJECT:SuspendLayout().
/* richTextBox1 */
/* */
THIS-OBJECT:richTextBox1:Location = NEW System.Drawing.Point(12, 2).
THIS-OBJECT:richTextBox1:Name = "richTextBox1".
THIS-OBJECT:richTextBox1:Size = NEW System.Drawing.Size(267, 105).
THIS-OBJECT:richTextBox1:TabIndex = 1.
THIS-OBJECT:richTextBox1:Text = "".


METHOD PUBLIC VOID setprogressbarvalue(INPUT ipvalue AS INTEGER ):
THIS-OBJECT:Killtimer().
THIS-OBJECT: Progressb1:Value = ipvalue.
RETURN.

END METHOD.

METHOD PUBLIC VOID ShowModalDialog( ):
THIS-OBJECT:Show().
//THIS-OBJECT:richTextBox1:Show().

END METHOD.
METHOD PUBLIC VOID Killtimer( ):
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
DEFINE VARIABLE k AS INTEGER NO-UNDO.
DEFINE VARIABLE icount AS INTEGER NO-UNDO INIT 200.
DO i = 1 TO icount:
DO j = 1 TO icount:
DO k = 1 TO icount:
END.
END.
END.
END METHOD.

METHOD PUBLIC VOID setrichTextBox1value(INPUT ipvalue AS CHARACTER ):
THIS-OBJECT:Killtimer().
THIS-OBJECT:richTextBox1:Text = ipvalue.
//THIS-OBJECT:richTextBox1:Focused = TRUE.
// PAUSE.

RETURN.

END METHOD.


code in .p
DEFINE VARIABLE DisplayFormDemo AS CLASS class.progressb NO-UNDO.

DisplayFormDemo = NEW class.progressb( ).
DisplayFormDemo:ShowModalDialog().

displayFormDemo:setprogressbarvalue(10).
displayFormDemo:setrichTextBox1value("Started").

displayFormDemo:setprogressbarvalue(30).
displayFormDemo:setrichTextBox1value("In Progress").

displayFormDemo:setprogressbarvalue(50).
displayFormDemo:setrichTextBox1value("In Progress").

displayFormDemo:setprogressbarvalue(70).
displayFormDemo:setrichTextBox1value("In Progress").

displayFormDemo:setprogressbarvalue(90).
displayFormDemo:setrichTextBox1value("finsished almost").

displayFormDemo:setprogressbarvalue(100).
displayFormDemo:setrichTextBox1value("finsished").

DisplayFormDemo:Success().
 
I am not sure of the actual problem as it appears you are showing the value in the rich text box:-

Code:
THIS-OBJECT:richTextBox1:Text = ipvalue.

Is the problem that you want to show all the previous values because currently it is only showing the previous value passed? If so, then does something like this solve?:

Code:
METHOD PUBLIC VOID setrichTextBox1value(INPUT ipvalue AS CHARACTER ):
   // Add a carriage return.
   IF THIS-OBJECT:richTextBox1:Text <> "" THEN
      THIS-OBJECT:richTextBox1:Text = THIS-OBJECT:richTextBox1:Text + CHR(13).

   THIS-OBJECT:richTextBox1:Text = THIS-OBJECT:richTextBox1:Text + ipvalue.
END METHOD.
 
it show like this empty in the message box.

1715595729725.png

But if i add Pause to the method
METHOD PUBLIC VOID setrichTextBox1value(INPUT ipvalue AS CHARACTER ):
THIS-OBJECT:richTextBox1:Text = ipvalue.
PAUSE.
so it it show the value, but with click with every value
1715596016744.png
 
That seems to suggest that something extra is happening that is clearing the rich text box. It could be the components are being reinitialized or the setrichTextBox1value method is being called again by something else which is passing a blank value. From what you have posted neither of these seem to be happening.

If as a first try you add a label component and also update that at the same time the rich text box gets updated does that get cleared as well? Depending on what happens it will hopefully help track down the problem.
 
This is the hole Class,
i can not see that Method setrichTextBox1value calls again.
------------

/*------------------------------------------------------------------------
File : progressb
Purpose :
Syntax :
Description :
Author(s) : rafmal01
Created : Tue Apr 02 12:22:54 CEST 2024
Notes :
----------------------------------------------------------------------*/

USING Progress.Lang.*.
USING Progress.Windows.Form.

BLOCK-LEVEL ON ERROR UNDO, THROW.

CLASS 2Guru.Helpers.progressb INHERITS Form:

DEFINE PRIVATE VARIABLE components AS System.ComponentModel.IContainer NO-UNDO.
DEFINE PRIVATE VARIABLE progressb1 AS System.Windows.Forms.ProgressBar NO-UNDO.
DEFINE PRIVATE VARIABLE richTextBox1 AS System.Windows.Forms.RichTextBox NO-UNDO.

CONSTRUCTOR PUBLIC progressb ( ):

SUPER().
InitializeComponent().
THIS-OBJECT:ComponentsCollection:ADD(THIS-OBJECT:components).
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.

END CONSTRUCTOR.

/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/

METHOD PUBLIC VOID Failed( ):
THIS-OBJECT:DialogResult = System.Windows.Forms.DialogResult:Cancel.
THIS-OBJECT:Close ( ).
END METHOD.

METHOD PRIVATE VOID InitializeComponent( ):

THIS-OBJECT:progressb1 = NEW System.Windows.Forms.ProgressBar().
THIS-OBJECT:richTextBox1 = NEW System.Windows.Forms.RichTextBox().
THIS-OBJECT:SuspendLayout().
/* */
/* progressb1 */
/* */
THIS-OBJECT:progressb1:BackColor = System.Drawing.SystemColors:Control.
THIS-OBJECT:progressb1:ForeColor = System.Drawing.Color:LightSkyBlue.
THIS-OBJECT:progressb1:Location = NEW System.Drawing.Point(12, 113).
THIS-OBJECT:progressb1:Name = "progressb1".
THIS-OBJECT:progressb1:Size = NEW System.Drawing.Size(267, 22).
THIS-OBJECT:progressb1:TabIndex = 0.
THIS-OBJECT:progressb1:Value = 10.
/* */
/* richTextBox1 */
/* */
THIS-OBJECT:richTextBox1:Location = NEW System.Drawing.Point(12, 2).
THIS-OBJECT:richTextBox1:Name = "richTextBox1".
THIS-OBJECT:richTextBox1:ReadOnly = TRUE.
THIS-OBJECT:richTextBox1:Size = NEW System.Drawing.Size(267, 105).
THIS-OBJECT:richTextBox1:TabIndex = 1.
THIS-OBJECT:richTextBox1:Text = "".
/* */
/* progressb */
/* */
THIS-OBJECT:ClientSize = NEW System.Drawing.Size(302, 147).
THIS-OBJECT:Controls:Add(THIS-OBJECT:richTextBox1).
THIS-OBJECT:Controls:Add(THIS-OBJECT:progressb1).
THIS-OBJECT:Name = "progressb".
THIS-OBJECT:Text = "Progressbar".
THIS-OBJECT:ResumeLayout(FALSE).
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END METHOD.



METHOD PUBLIC VOID setrichTextBox1value(INPUT ipvalue AS CHARACTER ):
THIS-OBJECT:richTextBox1:Text = ipvalue.
//PAUSE.


END METHOD.

/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/

METHOD PUBLIC VOID setprogressbarvalue(INPUT ipvalue AS INTEGER ):
THIS-OBJECT:Killtimer().
THIS-OBJECT:progressb1:Value = ipvalue.


RETURN.

END METHOD.

METHOD PUBLIC VOID ShowModalDialog( ):
THIS-OBJECT:Show().
THIS-OBJECT:richTextBox1:Show().

END METHOD.



METHOD PUBLIC VOID Killtimer( ):
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
DEFINE VARIABLE k AS INTEGER NO-UNDO.
DEFINE VARIABLE icount AS INTEGER NO-UNDO INIT 200.
DO i = 1 TO icount:
DO j = 1 TO icount:
DO k = 1 TO icount:
END.
END.
END.
END METHOD.
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/

METHOD PUBLIC VOID Success( ):

THIS-OBJECT:DialogResult = System.Windows.Forms.DialogResult:Ok.
THIS-OBJECT:Close ( ).

RETURN.

END METHOD.


DESTRUCTOR PUBLIC progressb ( ):

END DESTRUCTOR.

END CLASS.
 
Can duplicate the problem and think I know what you require. Put this extra line in the setrichTextBox1value method:

Code:
THIS-OBJECT:Refresh().
.
 
Back
Top