access a form a class that the form has called

  • Thread starter Thread starter Cath Victor
  • Start date Start date
C

Cath Victor

Hi...

I have a windows form that calls/uses a class to do some processing. I
want this class to return values or append text to the form's textbox as
it processes data. Any of you guys know how I could do this?

I was already able to do this before but unfortunately, my code has been
deleted and I can't reconstruct it.

Thank you very very much... :D

Cath
 
Cath Victor said:
I have a windows form that calls/uses a class to do some processing.
I want this class to return values or append text to the form's
textbox as it processes data. Any of you guys know how I could do
this?

I was already able to do this before but unfortunately, my code has
been deleted and I can't reconstruct it.

In the class, raise an event. In the Form, handle the event and update the
display. It you don't need to use the Form during the process, it is
sufficient to call the Refresh method of the controls that need to be
refreshed.

ATTENTION: Using WinXP, calling the Refresh method does not refresh the
control after a couple of seconds. Reason: (3rd paragraph)
http://msdn.microsoft.com/library/e...ssagequeues/aboutmessagesandmessagequeues.asp

This annoying "feature" can not be turned off (AFAIK)! There is no way to
update the display only. Either you have to use Application.Doevents (which
also enables the user to interact with the Form - what you might not want),
or you have to do the job in a new thread.
 
Hi Cath,

You are a very lucky guy (or girl)

The group had some fun and Armin got a challenge, he did contribute it about an hour ago, it is in this group. It even goes with a picture, you have to make it yourself with text.

I did copy it for you (and tested it) it is only a sample

\\\q&d needs a panel on a form
Private m_StartTicks As Integer = Environment.TickCount
Private m_Bmp As New Bitmap( _
"G:\enterthepathwherethebitmapcanbefound\Bitmap1.bmp" _
)

Private Sub Timer1_Tick( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Timer1.Tick

UpdatePanel()
End Sub

Private Sub UpdatePanel()
Dim Diff As Integer
Dim g As Graphics
Diff = Environment.TickCount - m_StartTicks
g = Me.Panel1.CreateGraphics
g.DrawImage( _
m_Bmp, 0, 0, _
New Rectangle( _
0, Diff \ 20, Me.Panel1.Width, Me.Panel1.Height _
), GraphicsUnit.Pixel _
)
g.Dispose
'TODO: watch exceeding the bitmap's height and
'implement a loop
End Sub

Private Sub Panel1_Paint( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Panel1.Paint

UpdatePanel()
End Sub

and: timer1.interval=100


If you want it *really* smooth it occupies some more cpu power: (also q&d)

Shared Sub main()
'I never use "Call", but "(New Form1).ShowDialog"
'does not work
Call (New Form1).ShowDialog()
End Sub

Public Shadows Sub ShowDialog()

Dim rect As Rectangle
Dim StartTicks As Integer

Me.Show()
Me.Refresh()

rect.Width = Me.Panel1.Width
rect.Height = Me.Panel1.Height

StartTicks = Environment.TickCount

Do
Dim Diff, Y As Integer
Dim g As Graphics
Diff = Environment.TickCount - StartTicks
rect.Y = Diff \ 20
'TODO: same todo as above...
g = Panel1.CreateGraphics
g.DrawImage(m_Bmp, 0, 0, rect, GraphicsUnit.Pixel)
g.Dispose()
Application.DoEvents()
Loop While Me.Created

End Sub


I hope this helps a little bit?

(compliments to Armin)

Cor
 
* Cath Victor said:
I have a windows form that calls/uses a class to do some processing. I
want this class to return values or append text to the form's textbox as
it processes data. Any of you guys know how I could do this?

I was already able to do this before but unfortunately, my code has been
deleted and I can't reconstruct it.

See:

<http://groups.google.com/[email protected]>
 
Back
Top