Hi,
I'm trying to have a MSN Messenger like form/app closing behavior. When I
click on the X button, I only want the form to disappear and when I
double-click on the notify icon or right-click on it and choose Open from
the context menu, I want the form to reappear. For that, I got the point
covered. Even when the form is minimize, the behavior is like MSN Messenger.
But one problem arose. When I close the form (the first time), it disappears
(that is ok), but after that, when I open it again, it appears, then if I
try to close it (for the second time), it disappears then reappears
immediately, if I close it again (for a third time), then, it disappears...
In fact, except for the first time I close it, I have to close it twice...
I supplied the the code I use (maybe there's a more efficient way to code
it) at the end of this post. I hope that's all the code you need. I only
handle the Closing and Load events for the form, so I don't this this would
be a problem.
Thanks
ThunderMusic
Private Sub FRMMain_Closing (ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
If Not m_ClosingApp Then
e.Cancel = True
Me.Visible = False
Me.ShowInTaskba r = False
End If
End Sub
Private Sub NIMS_DoubleClic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles NIMS.DoubleClic k
Me.Visible = True
Me.ShowInTaskba r = True
If Me.WindowState = FormWindowState .Minimized Then
Me.WindowState = FormWindowState .Normal
End If
End Sub
Private Sub MNUOpen_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles MNUOpen.Click
Me.Visible = True
Me.ShowInTaskba r = True
If Me.WindowState = FormWindowState .Minimized Then
Me.WindowState = FormWindowState .Normal
End If
End Sub
Private Sub MNUExit_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles MNUExit.Click
m_ClosingApp = True
Me.Close()
End Sub
private m_ClosingApp as boolean 3 2322
I don't get it at all... I solved the problem and I know which instruction
produced the problem... but I don't know why it causes the problem, maybe
someone could explain it to me?
The instruction causing the problem is "me.ShowInTaskB ar = True (or False,
does the same problem)" In fact, I just removed those instructions from my
code and now it works fine (the app doesn't even show in task bar when it is
not visible, so everything is alright). But I don't know why the
ShowInTaskBar property, when toggled, was doing something causing my
TreeView to raise an AfterSelect Event, which seems to get in the way of the
window closing process (in any way). I just don't get why this event is
raised, because when going step-by-step, the call stack shows this (I've cut
some details out for each line, but you have all the lines in the call
stack): FRMMain.TVAll_A fterSelect(Obje ct sender = {System.Windows .Forms.TreeView },
....)
[<Non-user Code>]
FRMMain.FRMMain _Closing(Object sender = {JMSFE.FRMMain} , ...)
So if I understand well, the toggling of this property runs some non-user
code, and this non-user code fires the AfterSelect on my TreeView. Does
somebody understand all this? Can somebody explain what is happening?
Thanks
ThunderMusic
"ThunderMus ic" <NO*******@symp atico.caSPAMATA LL> a écrit dans le message de
news:eS******** ******@TK2MSFTN GP14.phx.gbl... Hi,
I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click on it and choose Open from the context menu, I want the form to reappear. For that, I got the point covered. Even when the form is minimize, the behavior is like MSN
Messenger. But one problem arose. When I close the form (the first time), it
disappears (that is ok), but after that, when I open it again, it appears, then if I try to close it (for the second time), it disappears then reappears immediately, if I close it again (for a third time), then, it
disappears... In fact, except for the first time I close it, I have to close it twice...
I supplied the the code I use (maybe there's a more efficient way to code it) at the end of this post. I hope that's all the code you need. I only handle the Closing and Load events for the form, so I don't this this
would be a problem.
Thanks
ThunderMusic
Private Sub FRMMain_Closing (ByVal sender As Object, ByVal e As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing If Not m_ClosingApp Then e.Cancel = True Me.Visible = False Me.ShowInTaskba r = False End If End Sub
Private Sub NIMS_DoubleClic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles NIMS.DoubleClic k Me.Visible = True Me.ShowInTaskba r = True
If Me.WindowState = FormWindowState .Minimized Then Me.WindowState = FormWindowState .Normal End If End Sub
Private Sub MNUOpen_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles MNUOpen.Click Me.Visible = True Me.ShowInTaskba r = True
If Me.WindowState = FormWindowState .Minimized Then Me.WindowState = FormWindowState .Normal End If End Sub
Private Sub MNUExit_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles MNUExit.Click m_ClosingApp = True Me.Close() End Sub
private m_ClosingApp as boolean
"ThunderMus ic" <NO*******@symp atico.caSPAMATA LL> schrieb im Newsbeitrag
news:eS******** ******@TK2MSFTN GP14.phx.gbl... Hi,
I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click on it and choose Open from the context menu, I want the form to reappear. For that, I got the point covered. Even when the form is minimize, the behavior is like MSN Messenger.
But one problem arose. When I close the form (the first time), it disappears (that is ok), but after that, when I open it again, it appears, then if I try to close it (for the second time), it disappears then reappears immediately, if I close it again (for a third time), then, it disappears... In fact, except for the first time I close it, I have to close it twice...
I supplied the the code I use (maybe there's a more efficient way to code it) at the end of this post. I hope that's all the code you need. I only handle the Closing and Load events for the form, so I don't this this would be a problem. [code]
First, I can reproduce the problem. I see your 2nd posting also but let me
first answer this one:
If you set a breakpoint @ the form.visiblecha nged event, you'll see that the
ShowInTaskbar property procedure indeed shows the Form again. Here's the
callstack:
WindowsApplicat ion.Form1.Form1 _VisibleChanged (sender, e) Zeile 119 Basic
System.Windows. Forms.Control.O nVisibleChanged (e)
System.Windows. Forms.Scrollabl eControl.OnVisi bleChanged(e)
System.Windows. Forms.Form.OnVi sibleChanged(e)
System.Windows. Forms.Control.S etVisibleCore(v alue)
System.Windows. Forms.Form.SetV isibleCore(valu e)
System.Windows. Forms.Control.s et_Visible(valu e)
System.Windows. Forms.Form.Crea teHandle()
System.Windows. Forms.Control.R ecreateHandleCo re()
System.Windows. Forms.Form.Recr eateHandleCore( )
System.Windows. Forms.Control.R ecreateHandle()
System.Windows. Forms.Form.set_ ShowInTaskbar(v alue)
WindowsApplicat ion.Form1.Form1 _Closing(sender , e) Zeile 100 Basic
If you needed to set this property - you don't as you've already written - I
would have recommended to set it before the visible property. This does
work.
Armin
"ThunderMus ic" <NO*******@symp atico.caSPAMATA LL> schrieb I don't get it at all... I solved the problem and I know which instruction produced the problem... but I don't know why it causes the problem, maybe someone could explain it to me?
The instruction causing the problem is "me.ShowInTaskB ar = True (or False, does the same problem)" In fact, I just removed those instructions from my code and now it works fine (the app doesn't even show in task bar when it is not visible, so everything is alright). But I don't know why the ShowInTaskBar property, when toggled, was doing something causing my TreeView to raise an AfterSelect Event, which seems to get in the way of the window closing process (in any way). I just don't get why this event is raised, because when going step-by-step, the call stack shows this (I've cut some details out for each line, but you have all the lines in the call stack):
FRMMain.TVAll_A fterSelect(Obje ct sender = {System.Windows .Forms.TreeView }, ...) [<Non-user Code>] FRMMain.FRMMain _Closing(Object sender = {JMSFE.FRMMain} , ...)
So if I understand well, the toggling of this property runs some non-user code, and this non-user code fires the AfterSelect on my TreeView. Does somebody understand all this? Can somebody explain what is happening?
In the call stack window's context menu, enable "show non-user code" and
post the call stack again.
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rob Mayo |
last post by:
OK, maybe this is my opinion, maybe these are bugs.
Given the folowing:
I have a NotifyIcon on my Form, a Context menu associated with the
NotifyIcon, and a MenuItem on the ContextMenu set as default. When the
default MenuItem is clicked, there is code to no longer show the NotifyIcon.
What I feel should happen is when I double-click the NotifyIcon in the
system tray, it should perform the default menu item's Click event.
|
by: Zanthor |
last post by:
Ok, I've got a small App I'm trying to make minimize to the system
tray...
The behavior I'm after is that while the forms FormWindowState is
Normal I want the form visible in the taskbar, when it's not normal
(I've disabled maximize, so the only other state is minimized) I want
it to be not visible on the taskbar but visible in the system tray.
My notifyIcon has a menu setup to restore the window, and the whole
thing works just peachy...
|
by: Me |
last post by:
I'm getting a NullReferenceException in Unknown Module when I follow
the below steps to create a simple NotifyIcon app that creates the
context menu on the fly(see a little analysis after the steps).
1. Create a new Windows Forms C# solution (I called mine DBChanger).
2. Replace Form1.cs code with this:
--------------------
using System;
|
by: Eric |
last post by:
I implemented owner drawing on the main and context menus of my main form.
It works fine.
There is also a notify icon control that has a context menu. When the icon
is in the status bar, it works perfectly fine when it is double-clicked.
However, when I try to initialize the notify icon's context menu as an
owner-drawn menu, all the text in that menu disappears.
Is owner drawing a notify icon's context menu possible? I saw someone...
|
by: David |
last post by:
Hi,
I am developing a NotifyIcon app with C#. I want to show the context menu
when user left-clicks on the icon, the same as he/she right-clicks on it. In
that event handler, myNotifyIcon_Click(), I call
myNotifyIcon.ContextMenu.Show method. But I am not sure what these two
parameters I should feed.
Thanks in advance.
| |
by: Charles Law |
last post by:
For some reason, when I click the X to close my MDI parent form, the action
appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the application.
What should happen, is that the main MDI form should close, taking the child
forms with it. There is code to loop through the child forms, remove the
controls on each of them, and then close the form, but this code should
execute only...
|
by: Phuff |
last post by:
I have an application that should run in the system tray while open.
It is supposed to be open at all times and I need it to dissapear when
the "X" button is pushed on the form...but without closing the app.
I've tried overriding the closing event
> Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As
> System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
> 'Don't close this form
> e.Cancel = True
|
by: ThunderMusic |
last post by:
Hi,
I'm trying to have a MSN Messenger like form/app closing behavior. When I
click on the X button, I only want the form to disappear and when I
double-click on the notify icon or right-click on it and choose Open from
the context menu, I want the form to reappear. For that, I got the point
covered. Even when the form is minimize, the behavior is like MSN Messenger.
But one problem arose. When I close the form (the first time), it...
|
by: SteveMac |
last post by:
I am using VS2003 VC++ .NET.
I want to make a tray icon with a popup menu (like a context menu) that
pops up for a left click.
I can make the notifyicon with a context menu and that works fine, but
I really want it to show the menu for a left click, exactly as it would
for a right click.
SteveMac
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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...
|
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
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |