473,883 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Dialog Boxes and Notify Icons

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.ShowDi alog()
Application.Exi t()

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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles NotifyIcon1.Dou bleClick
Me.WindowState = FormWindowState .Normal
Me.ShowInTaskba r = True
shown = True
NotifyIcon1.Vis ible = False
End Sub

Private Sub MainFormSizeCha nged(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.SizeChan ged
If shown And Me.WindowState = FormWindowState .Minimized Then
shown = False
Me.ShowInTaskba r = False
NotifyIcon1.Vis ible = 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!
Nov 20 '05 #1
18 1807
"Derek Martin" <dm*****@DONTSP AMMEokstate.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.ShowDi alog()
Application.Exi t()

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

Nov 20 '05 #2
I can live with that :-)
Any suggestions then on how to accomplish a splash screen in the main
form????
Thanks!
Derek

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************** @news.freenet.d e...
"Derek Martin" <dm*****@DONTSP AMMEokstate.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.ShowDi alog()
Application.Exi t()

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

Nov 20 '05 #3
"Derek Martin" <dm*****@DONTSP AMMEokstate.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

Nov 20 '05 #4
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.EventArg s) Handles MyBase.Load

frmSplash = New frmSplash() ' my name for the form
frmSplash.ShowS plash()
' 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.lstSp lash.Items.Add( "Loading... ")
' This is so above changes are displayed...
frmSplash.Refre sh()

' 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.ShowDi alog()
Application.Exi t()

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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles NotifyIcon1.Dou bleClick
Me.WindowState = FormWindowState .Normal
Me.ShowInTaskba r = True
shown = True
NotifyIcon1.Vis ible = False
End Sub

Private Sub MainFormSizeCha nged(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.SizeChan ged
If shown And Me.WindowState = FormWindowState .Minimized Then
shown = False
Me.ShowInTaskba r = False
NotifyIcon1.Vis ible = 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!

Nov 20 '05 #5
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.EventArg s) Handles StartTimer.Tick
elapsed += 1
Me.Opacity = 1
If elapsed >= 10 Then
Me.StartTimer.E nabled = False
Me.beginLoading Components()
End If
End Sub

Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal e As
System.EventArg s) 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.ShowDi alog(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.Exi t()
End If
End Sub

Private Sub beginLoadingCom ponents()
Me.Timer1.Enabl ed = True
mainform = New main
t = New Thread(AddressO f mainform.gettin gstarted)
t.Start()
'mainform.getti ngstarted()
End Sub

Private Overloads Sub loading_Load(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.Cursor = Cursors.AppStar ting
Me.StartTimer.E nabled = True
End Sub
End Class
Nov 20 '05 #6
"Derek Martin" <dm*****@DONTSP AMMEokstate.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(addresso f 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

Nov 20 '05 #7
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*******@free net.de> wrote in message
news:40******** *************** @news.freenet.d e...
"Derek Martin" <dm*****@DONTSP AMMEokstate.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(addresso f 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


Nov 20 '05 #8
"Derek Martin" <dm*****@DONTSP AMMEokstate.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

Nov 20 '05 #9
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?)

--
Armin

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3083
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 the context of a main window. The problem does not occur on HPUX or Linux. The following simple example code illustrates the problem and the work around I've come up with; However, I'd like, very much, to get rid of the kludgy work around....
7
2037
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 and pass a certain variable value. For example: href="my_page.asp?answer=yes" If they click no, I would call :
2
4278
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 changed? In MFC I just used SendMessage to send a WM_NOTIFY. Is there an equivalent in plain c# or can I use another method to notify the main window about changes?
2
30171
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.) and would like to make the dialog look and act like the standard MessageBox. Therefore, I would like to put in the message section the same type of icons found in the MessageBox dialog, such as MessageBoxIcon.Exclamation. In another post here I had...
10
2589
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 above the task bar. Can't figure out why that happens - it looks very ugly... Any ideas ? Zeljko
3
6944
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 move over the icons in the taskbar the taskbar will immediately update itself and clear the old icon away. I was just wondering if this is normal or if I am supposed to "force" an update of the taskbar system tray icons somehow?
10
2237
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. The event in the singleton class always evaluates to null even when I cleary subscribe to it. Does anyone have some sample code of how to do this, or is this not possible.
10
4845
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 point it becomes un-usable. The only fix I have found is to re-boot. Not a godd solution. How do I get this to stop happening? Environment C#, VS.Net 2003, XP Pro Thanks,
0
776
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 is a bug http://support.microsoft.com/?id=827043 saying that it doesn't work with notify icon. Anybody has got a workaround ? Vittorio
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9787
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9568
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7964
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5794
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.