Hi there, this is probably really dumb, but I am using a dialog as my main
form and my startup form is my splash screen - which implements some
progress bars to load up some relevant data. When that is done, loading
form does this:
Me.Visible = False
mainform.ShowDialog()
Application.Exit()
So far so good (is this a dumb way of doing that???). Now, I am
implementing a notification icon in mainform. Here is some relevant stuff:
(class variable shown as boolean = true and notify icon set up correctly)
Private Sub Open_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles NotifyIcon1.DoubleClick
Me.WindowState = FormWindowState.Normal
Me.ShowInTaskbar = True
shown = True
NotifyIcon1.Visible = False
End Sub
Private Sub MainFormSizeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.SizeChanged
If shown And Me.WindowState = FormWindowState.Minimized Then
shown = False
Me.ShowInTaskbar = False
NotifyIcon1.Visible = True
End If
End Sub
Here is the problem: When I hit the ol minimize button on mainform, the
application control is passed back to loading and the application exits
since that is the next line. What am I doing wrong/what can I adjust so
that control doesn't go back to loading when the form is minimized??
Plus, any tips on making that better are certainly welcome!
Thanks! 18 1674
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb Hi there, this is probably really dumb, but I am using a dialog as my main form and my startup form is my splash screen - which implements some progress bars to load up some relevant data. When that is done, loading form does this:
Me.Visible = False mainform.ShowDialog() Application.Exit()
So far so good (is this a dumb way of doing that???).
IMO not a good idea. You should only use a Form as the startup object if the
Form will always be visible from the start til the end of the application.
[...] Here is the problem: When I hit the ol minimize button on mainform, the application control is passed back to loading and the application exits since that is the next line. What am I doing wrong/what can I adjust so that control doesn't go back to loading when the form is minimized??
ShowDialog probably exits when the Form is minimized. If you change what
I've written above, this problem should have been solved also.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
I can live with that :-)
Any suggestions then on how to accomplish a splash screen in the main
form????
Thanks!
Derek
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb Hi there, this is probably really dumb, but I am using a dialog as my main form and my startup form is my splash screen - which implements some progress bars to load up some relevant data. When that is done, loading form does this:
Me.Visible = False mainform.ShowDialog() Application.Exit()
So far so good (is this a dumb way of doing that???). IMO not a good idea. You should only use a Form as the startup object if
the Form will always be visible from the start til the end of the application.
[...] Here is the problem: When I hit the ol minimize button on mainform, the application control is passed back to loading and the application exits since that is the next line. What am I doing wrong/what can I adjust so that control doesn't go back to loading when the form is minimized??
ShowDialog probably exits when the Form is minimized. If you change what I've written above, this problem should have been solved also.
-- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb I can live with that :-) Any suggestions then on how to accomplish a splash screen in the main form????
/In/ the main form or before showing the main form? I assume the latter:
shared sub main
dim splash as new splashform
dim main as mainform
splash.show
splash.refresh
main = new mainform
main.show
splash.close
application.run(main)
end sub
I only answered the question above - not the one with the NotifyIcon. ;-)
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
This is the way I did my splash screen. It seems to work great.
This is the code in the main, startup form:
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
frmSplash = New frmSplash() ' my name for the form
frmSplash.ShowSplash()
' Apparently this method is available for a reason,
' so it may be better than the .ShowDialog method, etc.
' This is my own stuff for controling the splashscreen
' activity from this main form...
frmSplash.lstSplash.Items.Add("Loading...")
' This is so above changes are displayed...
frmSplash.Refresh()
' When you're done with the splashscreen...
frmSplash.Close()
End Sub
Hope that helps.
Derek Martin wrote: Hi there, this is probably really dumb, but I am using a dialog as my main form and my startup form is my splash screen - which implements some progress bars to load up some relevant data. When that is done, loading form does this:
Me.Visible = False mainform.ShowDialog() Application.Exit()
So far so good (is this a dumb way of doing that???). Now, I am implementing a notification icon in mainform. Here is some relevant stuff:
(class variable shown as boolean = true and notify icon set up correctly)
Private Sub Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick Me.WindowState = FormWindowState.Normal Me.ShowInTaskbar = True shown = True NotifyIcon1.Visible = False End Sub
Private Sub MainFormSizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged If shown And Me.WindowState = FormWindowState.Minimized Then shown = False Me.ShowInTaskbar = False NotifyIcon1.Visible = True End If End Sub
Here is the problem: When I hit the ol minimize button on mainform, the application control is passed back to loading and the application exits since that is the next line. What am I doing wrong/what can I adjust so that control doesn't go back to loading when the form is minimized??
Plus, any tips on making that better are certainly welcome!
Thanks!
Thank you to both for your assistance. They have aided me in learning more
about the splashes, however, my particular case seems to be a bit different.
My splash screen uses a progress bar to actually show things as they are
being done on the mainform, loading up some objects, etc. I followed some
patterns from these posts and I get to a certain part that works well, but
it doesn't lend itself to threading very easily. For instance, in the
loading code, if I am referencing the mainform by an object instead of
creating it in the loading code (here I create it in the main method), I
cannot start up a thread on that object, I'd have to recreate it which beats
the purpose. I have attached my code if anyone can assist.
Thanks!
Derek
Public Class loading
Inherits System.Windows.Forms.Form
Dim elapsed As Short = 0
Dim t As Thread
Dim mainform As main
Private Sub StartTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles StartTimer.Tick
elapsed += 1
Me.Opacity = 1
If elapsed >= 10 Then
Me.StartTimer.Enabled = False
Me.beginLoadingComponents()
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Me.ProgressBar1.Value += Me.ProgressBar1.Maximum / 10
If Me.ProgressBar1.Value >= Me.ProgressBar1.Maximum Then
Timer1.Enabled = False
t.Join()
Me.Hide()
Me.Cursor = Cursors.Arrow
mainform.ShowDialog(Me) 'INSTEAD OF DOING THIS, I need to pass
control to this form and dispose of this one...that way I can minimize to a
tray icon without exiting the app! Help!!!!
Application.Exit()
End If
End Sub
Private Sub beginLoadingComponents()
Me.Timer1.Enabled = True
mainform = New main
t = New Thread(AddressOf mainform.gettingstarted)
t.Start()
'mainform.gettingstarted()
End Sub
Private Overloads Sub loading_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Cursor = Cursors.AppStarting
Me.StartTimer.Enabled = True
End Sub
End Class
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb Thank you to both for your assistance. They have aided me in learning more about the splashes, however, my particular case seems to be a bit different.
My splash screen uses a progress bar to actually show things as they are being done on the mainform, loading up some objects, etc. I followed some patterns from these posts and I get to a certain part that works well, but it doesn't lend itself to threading very easily. For instance, in the loading code, if I am referencing the mainform by an object instead of creating it in the loading code (here I create it in the main method), I cannot start up a thread on that object, I'd have to recreate it which beats the purpose. I have attached my code if anyone can assist.
If you want an independent splash screen showing the progress, you need to
create it in it's own thread. I wouldn't create the Mainform in a different
thread.
Within Class Loading (example only):
public shared sub showInstance
dim t as thread
t = new thread(addressof threadstart)
t.start
end sub
private sub threadstart
application.run(new loading)
end sub
Sub main would look like in my first example. If anything happens within the
Mainform that is to be displayed in the Splash Form, I'd raise an event in
the Mainform, handle it in the class/module containing sub main and update
the Splash Form in the event handler. But, when updating the splash Form,
you must use Begininvoke to do it because the event handler handling the
event from the Mainform is executed in the main thread, not in the thread
that created the Splash Form.
--
Armin
Thanks Armin, that went a little over my head, but I will investigate this
procedure, it sounds pretty good.
Quick question:
If the sub main() looks like your previous example, then where are you
executing showInstance in the loading class? In formload?
:-)
Derek
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb Thank you to both for your assistance. They have aided me in learning more about the splashes, however, my particular case seems to be a bit different.
My splash screen uses a progress bar to actually show things as they are being done on the mainform, loading up some objects, etc. I followed some patterns from these posts and I get to a certain part that works well, but it doesn't lend itself to threading very easily. For instance, in the loading code, if I am referencing the mainform by an object instead of creating it in the loading code (here I create it in the main method), I cannot start up a thread on that object, I'd have to recreate it which beats the purpose. I have attached my code if anyone can assist. If you want an independent splash screen showing the progress, you need to create it in it's own thread. I wouldn't create the Mainform in a
different thread.
Within Class Loading (example only):
public shared sub showInstance dim t as thread t = new thread(addressof threadstart) t.start end sub
private sub threadstart application.run(new loading) end sub
Sub main would look like in my first example. If anything happens within
the Mainform that is to be displayed in the Splash Form, I'd raise an event in the Mainform, handle it in the class/module containing sub main and update the Splash Form in the event handler. But, when updating the splash Form, you must use Begininvoke to do it because the event handler handling the event from the Mainform is executed in the main thread, not in the thread that created the Splash Form.
-- Armin
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb Thanks Armin, that went a little over my head, but I will investigate this procedure, it sounds pretty good. Quick question:
If the sub main() looks like your previous example, then where are you executing showInstance in the loading class? In formload?
:-)
Yes, like the previous example, the only difference is the call to
showInstance instead of Show. I renamed it afterwards.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Armin Zingler" <az*******@freenet.de> schrieb I uploaded a project to demonstrate a multithreaded splash screen:
http://people.freenet.de/armin.zingl...adedSplash.zip
(anybody knows why the main form looses focus?)
...because it never gets the focus. Problem solved, project updated.
--
Armin
I just completed mine. Thanks so much for your help! Works great,
Derek
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40*********************@news.freenet.de... "Armin Zingler" <az*******@freenet.de> schrieb I uploaded a project to demonstrate a multithreaded splash screen:
http://people.freenet.de/armin.zingl...adedSplash.zip
(anybody knows why the main form looses focus?)
..because it never gets the focus. Problem solved, project updated.
-- Armin
Hi Armin,
I think I do not understand you.
I changed it to this and I thought the mainform keeps the focus.
I want to change the one I have from you with the progres bar for this as
sample, however I want to use not the application start but the form load
and change that. Do you have a problem with that (Your name will always be
told however with a little addition that I made small but not major
changes).
Public Sub Start()
Me.Show()
RaiseEvent Progress(1, 3)
'Thread.Sleep simulates action without blocking
' the thread showing the Splashform
For i As Integer = 100 To 1000 Step 1000
Threading.Thread.Sleep(i)
Application.DoEvents()
Next
RaiseEvent Progress(2, 3)
For i As Integer = 100 To 2000 Step 100
Threading.Thread.Sleep(i)
Application.DoEvents()
Next
RaiseEvent Progress(3, 3)
End Sub
Private Sub Button1_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
MessageBox.Show("hello")
End Sub
Cor
"Cor Ligthert" <no**********@planet.nl> schrieb Hi Armin,
I think I do not understand you.
I changed it to this and I thought the mainform keeps the focus.
I want to change the one I have from you with the progres bar for this as sample, however I want to use not the application start but the form load and change that. Do you have a problem with that (Your name will always be told however with a little addition that I made small but not major changes).
Public Sub Start() Me.Show() RaiseEvent Progress(1, 3) 'Thread.Sleep simulates action without blocking ' the thread showing the Splashform For i As Integer = 100 To 1000 Step 1000 Threading.Thread.Sleep(i) Application.DoEvents() Next RaiseEvent Progress(2, 3) For i As Integer = 100 To 2000 Step 100 Threading.Thread.Sleep(i) Application.DoEvents() Next RaiseEvent Progress(3, 3) End Sub Private Sub Button1_Click(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles Button1.Click MessageBox.Show("hello") End Sub
I don't understand what's your intention. Of course you can create different
situations. I also thought about it but it would have been more work to
handle them all. In the uploaded project, the work (in Sub Start) is done
before the main Form is shown. In you example, the Form is shown before, so
you can make other examples of course.
--
Armin
You had a question about the focus, that I do not understand, only one
sentence in your code gives it the focus in my idea that first me.show that
I added.
Cor
"Cor Ligthert" <no**********@planet.nl> schrieb You had a question about the focus, that I do not understand, only one sentence in your code gives it the focus in my idea that first me.show that I added.
The Show was already in my code. The main form was shown /after/ the splash
form. Despite it didn't get the focus. That's what I did not understand.
After adding the MainForm.Activate() in the current version of the code, the
problem is solved, so I don't know which problem you are after.
I don't know why Show should be called 2 times. In addition, I don't want to
show the form before the initialization is completely done (in sub start),
that's why there is a splash screen.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Hi Armin,
did I wrote this uploaded a project to demonstrate a multithreaded splash screen:
http://people.freenet.de/armin.zingl...adedSplash.zip
(anybody knows why the main form looses focus?)
I thought it is Armin, quick start with checking however did not understand
what you mean because I was nothing, the form was hidden because the wait of
the thread, so I added a lot of code but did found nothing that let me
understand the problem.
Cor
"Cor Ligthert" <no**********@planet.nl> schrieb Hi Armin,
did I wrote this
Is this a question?? uploaded a project to demonstrate a multithreaded splash screen:
http://people.freenet.de/armin.zingl...adedSplash.zip
(anybody knows why the main form looses focus?)
I thought it is Armin, quick start with checking however did not understand what you mean because I was nothing, the form was hidden because the wait of the thread, so I added a lot of code but did found nothing that let me understand the problem.
The Form was not only hidden (visible =false). Even after the Form was
shown, it did not have the focus. It was hidden behind all other
applications, but it was visible in the taskbar and I could click on it to
bring it to front. I did (and don't) understand why.
In other words:
1. I start the exe in the explorer
2. Splash form is shown and has the focus
3. After some seconds, the Splash form disappears and the Main Form is
shown, BUT it does not have the focus. The Explorer has the focus. I have to
minimize the explorer to see the Main form behind.
After I added
MainForm.Activate()
after
MainForm.Show()
The problem was solved.
--
Armin
Hi Armin, Is this a question??
You know where I did come from so you too now we are not that Strict as
German
Yes it was a question without a question mark.
:-)
Now I understand what you mean, in the way I did it I got the same problem,
I changed it all back to the same way you intended it, however without the
applications.start.
Than you get this code.
Private Sub MainForm_Load(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
spsFrm = New SplashForm
spsFrm.AsyncShow()
AddHandler MainForm.Progress, AddressOf MainformProgress
RaiseEvent Progress(1, 3)
'Thread.Sleep simulates action without blocking
' the thread showing the Splashform
Threading.Thread.Sleep(1000)
RaiseEvent Progress(2, 3)
Threading.Thread.Sleep(3000)
RaiseEvent Progress(3, 3)
spsFrm.AsyncClose()
Me.Activate()
End Sub
I had also to add that Me.Activate to let the form get the focus.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bruce Davis |
last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded
tkinter gui application. The problem appears to be a deadlock condition
when a child thread pops up a
Pmw dialog window in...
|
by: calan |
last post by:
I need a dialog box with Yes, No, and Cancel buttons that pops up when a
link is clicked.
I'm using asp on the server side, and basically, if the user clicks yes, I
want to go to a certain page...
|
by: Marian Heddesheimer |
last post by:
Hi,
I have a C# main form which creates a new non-modal Dialog. From the
modal Dialog I can update data via a public attribute from the Dialog,
but how do I notify the main window that data has...
|
by: Dennis C. Drumm |
last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am
building a custom MessageBox dialog that has, among other things, a few new
button options (yes to all, no to all, etc.)...
|
by: Zeljko |
last post by:
Hi,
I have a form with a tray icon. However, when I minimize the form, it
stays visible - not in the task bar (I have showintaskbar property set
to false), but in a form of a rectangle sitting...
|
by: jm |
last post by:
Hi,
I have a C# program that changes the notifyIcon during the program.
What I have noticed is that sometimes when the program is over the old
icon will still be in the system tray. But when i...
|
by: Opa |
last post by:
I have tried for two days to solve this problem with no luck.
I have a singleton class which has some events declared. When I inherit
from this class the events don't seem to come along with it....
|
by: james |
last post by:
My app has a notify Icon, but after the app exits, the Icon is still
visible, and then when I runthe app multiple times I get multiple icons so
that my status bas keeps accumulating them to the...
|
by: Vittorio Pavesi |
last post by:
Hello,
I'm using a notify icon and I'm trying to add icons on my menu, I took a
look on
http://msdn.microsoft.com/msdnmag/issues/04/02/CuttingEdge/default.aspx but
on the bottom of the page there...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| |