Add subform to a form?

G

Guest

Can a vb.net form contain a subform? If yes, how is this done?

Maybe I am going about my issue the wrong way. I start an asynchronous
procedure from my main form - invoke a routine on a mainframe computer. Then
I am polling every 10 seconds (timer1) to see if the external program has
generated a data result set for my form to retrieve. In the meantime, on the
same main form I have a series a little labels that blink on/off in a series
for visual status that the program is polling (using a separate timer -
timer2). Well, everytime the program polls - the labels halt their blinking
for a few seconds. I want the labels to keep blinking during the polling. I
tried running timer2 in a separate thread object but that did not work - as I
could not turn timer2 on in the separate thread. So I am thinking to place
the labels in a subform with its own timer that is always running and I can
set a boolean var to turn the labels on and off when the polling stops. So,
is there a way to place a subform on a main form? Or -- how can I set
timer2.Enabled = True in a separate thread on the same form? I thought
timers were on their own threads.

Thanks
 
T

Tom Edelbrok

Why not turn the blink ON (ie: load an embedded resource bitmap or such the
like into a Picturebox control) at the moment you are about to poll. This
blink image will stay on-screen while polling. In fact, it can't disappear,
because it was there prior to the polling, and the polling function has no
way of knowing how to eradicate it from the screen. As soon as the polling
function is complete load a different embedded resource bitmap to indicate
that the polling function is now complete. Voila! Works perfectly. Isn't
this what you're trying to do anyway? (ie: let the user know that polling is
taking place?). If you really want to show the user that the poll is in
progress then your status light should stay ON (ie: visible on the screen)
for the entire time that polling occurs. I do this kind of thing all the
time, but then maybe I'm not understanding exactly what you're doing.

Caution: When you load an embedded resource into a bitmap object via a
stream, and then plunk it into a Picturebox control, the PictureBox control
will reflect the change on-screen almost all the time. But it will not
reflect the change when your application is in the midst of creating a new
form. Therefore, to ensure that the PictureBox control always shows the
correct status light image use "MyPictureBox.Refresh()" immediately after
setting the image.

Also, I've developed clsStatusLight as an object that represents a blinking
status light (RED, GREEN, or YELLOW, with WHITE for "off"). For example, RED
usually denotes a write-access, GREEN usually denotes a read-access, and
yellow usually denotes an error of some kind. This object creates a state
timer on the fly to accomplish nice blinking. Furthermore, you can try to
blink as rapidly as you want but clsStatusLight ensures that a blink-request
during a blink-in-progress is deemed to be the same blink, and therefore
generates no additional load on the system. If you want a copy let me know.

Also, explain in a little more detail if I'm not understanding your
situation.

Thanks,

Tom Edelbrok
 
G

Guest

Thanks for your reply. Actually, what I have is 20 little label squares
(rectangles)

‮█ ‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█‮█

They are all light yellow when polling starts then lbl0 turns blue for 100ms
then lbl1 turns blue while the rest go back to light yellow, then lbl2 turns
blue, lbl3 turns blue, etc from timer2. Maybe this is a little bit too cute,
but it keeps the end users from thinking that the program is not working or
is locked up or something. When polling is finished and the file is
retrieved, these labels disappear. My problem is that every 10 seconds (on
timer1) the labels halt the color changing. Each poll takes about 5 seconds.
This gives the illusion that a file is being picked up, when in fact, this
is not the case. The mainframe proc takes about 5-10 minutes to run. Thus,
I am thinking a subform. Any ideas appreciated how to make my visual status
indicator function correctly.

Thanks
‮‮
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top