473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Show a Hidden Form?

I have an application. When a user minimizes it it hides itselfs but stays activate in the system tray. Since it is hidden the user may think that they have exited the application and now may attempt to create a new instance by launching the program again. The problem that I am running into is being able to restore the previous application. I am able to end the multiple instance application but since the previous application is hidden I cannot find a way to 'show' previous application
Any suggestions? I need an answer fast.
Nov 16 '05 #1
5 13284
Maybe I am missing the point, however, in Properties you have the option
"showIn Taskbar". The user will be able to maximize the screen from there.
Second, you are worried that the form is still active, so why not close one
form when the other is opened. Then when the user needs it again he'll just
open it again.
Patrick.

*************** **********
"Susan" <an*******@disc ussions.microso ft.com> wrote in message
news:FB******** *************** ***********@mic rosoft.com...
I have an application. <skipped>

Nov 16 '05 #2
The form in the first instance of the application is hidden, and runs in the background. I do not want two instances running, so when a user tries to open a second instance, I want to bring up the hidden form from the first instance, and close the second. I just have no idea how to show that form from the code in the second instance (the application runs the mulitple instance code on startup). The other option that I have is to close the first instance, and bring up the second, but I don't know how to do that either. I am currently researching how to kill a process, hoping that will do the trick.
Nov 16 '05 #3
Hi Susan

There are two separated issues in your post, how to detect that a previous
instance is running and how to send a message to another windows to make it
the foremost window.

1- Detect a previous instance:
You can use several techniques, basically ALL of them involve the creation
of a unique object, you can use a Mutex for example, or search by process
name. if you do a search in the archives of this NG you will find several
suggestions as this is an issue that is constantly asked.

2- All you need is the handle of the main windows of the other isntance, you
get it using Process.MainWin dowHandle

Here is some code I have used

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

//yyou need this namespace
using System.Runtime. InteropServices ;
// P/invoke declarations
public class Form1 : System.Windows. Forms.Form
{
//I search by process name
static public Process FindParallelPro cess()
{

string currentprocname = Process.GetCurr entProcess().Pr ocessName;
foreach( Process process in Process.GetProc essesByName(
currentprocname ) )
{
if ( process.Id != Process.GetCurr entProcess().Id )
return process;
}
return null;

}
[DllImport("user 32.dll",EntryPo int="SetForegro undWindow")]
public static extern bool SetForegroundWi ndow(IntPtr hWnd);

//Detection
static void Main()
{

Process previous = Form1.FindParal lelProcess();
if ( previous == null )
Application.Run (new Form1());
else
{
//Give the focus to the other instance
SetForegroundWi ndow( previous.MainWi ndowHandle);
}
}

"Susan" <an*******@disc ussions.microso ft.com> wrote in message
news:FB******** *************** ***********@mic rosoft.com...
I have an application. When a user minimizes it it hides itselfs but stays activate in the system tray. Since it is hidden the user may think
that they have exited the application and now may attempt to create a new
instance by launching the program again. The problem that I am running into
is being able to restore the previous application. I am able to end the
multiple instance application but since the previous application is hidden I
cannot find a way to 'show' previous application. Any suggestions? I need an answer fast.

Nov 16 '05 #4
Thanks. But the SetForegroundWi ndow will not work, because the form is hidden. I can make it work all day long, if the UI is visible, but after it is hidden, SetForegroundWi ndow doesn't work. That is why I need to know first how to make that form visible again, before I call the SetForegroundWi ndow. I am so confused with this right now. Do you know anything about Killing a process? If I can't make the first instance visible, I can close it, and let the second instance come up. All the examples I find declare variables as process, and that will not compile for me. I am beginning to think that I am just an idiot, lol.
Nov 16 '05 #5
Hi Susan,
How are you hidding the form?

Now that I think about it I have never use SetForegroundWi ndow from another
application to show a form I had call hidden on.

Now , I do know that if you call Show from the same application it does
show again.

IF that is the case then what you can do is send a message to the hidden
application, the target application get the message and call the Show method
as needed.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Susan" <an*******@disc ussions.microso ft.com> wrote in message
news:88******** *************** ***********@mic rosoft.com...
Thanks. But the SetForegroundWi ndow will not work, because the form is

hidden. I can make it work all day long, if the UI is visible, but after it
is hidden, SetForegroundWi ndow doesn't work. That is why I need to know
first how to make that form visible again, before I call the
SetForegroundWi ndow. I am so confused with this right now. Do you know
anything about Killing a process? If I can't make the first instance
visible, I can close it, and let the second instance come up. All the
examples I find declare variables as process, and that will not compile for
me. I am beginning to think that I am just an idiot, lol.
Nov 16 '05 #6

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

Similar topics

11
2301
by: Jack | last post by:
I want to display a table on a page based on whether a button is pressed or not. I'm new at php so I'm sure I'm making a basic mistake. Here's what I am trying. My thought was that $show_summary would switch states with each click but it is coming up always true. So I'm guessing that is the default setting when the page loads. Can someone...
13
74012
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide Form1.Visible = False Load (Form1)
9
2745
by: sergio | last post by:
Hi all, I have created the following script that will show/hide a menu based on checkboxes. It works fine in Opera but not on IE6! Does anybody knows a workaround this problem? Thanks for your response. Sergio ------------------------------------------------ <script language="JavaScript" type="text/javascript">
5
2168
by: Zambien | last post by:
Hi all, Here's my problem. I have tables that are using the menu/submenu idea for hiding rows. This works fine in IE (of course) and does show/hide correctly in netscape, but as soon as the shown method is called, the table gets skewed and the presentation of the data on the page goes horribly wrong. I don't think this is a table issue...
3
10185
by: veganeater | last post by:
Hi, I'm wondering if there's a way that I can select which <div> to show based on the user's selection from a dropdown/listbox form. <form name="form1" method="post" action=""> <select name="internet"> <optgroup label="Network"> <option label="option1">Internet</option> </optgroup>
4
7990
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers) document.layers.visibility = 'visible'; else if (document.all) { document.all.style.visibility = 'visible';
1
1901
by: Richard | last post by:
Hello there, I have a form that is called from a Sub Main procedure using application.run(Form1). On my main form there is a button to open an instance of Form2 and then at the same time hide Form1. So far so good.
3
6378
by: Merlin | last post by:
Hi there, I am trying to create a form with an dynamic field that can be shown or hidden. As I saw for example on google it is possible with JS to show a layer and move the content underneath that layer further down uppon showing this layer. When a person closes that layer the content underneath the layer moves up again and closes the empty...
0
2062
by: BcNexus | last post by:
Hello all, The search function of this forum isn't working although I found a similar question on the forum using Google, but the replies don't help me. So, forgive me please if this has been answered before. I have a cgi program in Python that genereates an HTML page with a form with hidden fields whose values are set via the following: ...
0
7697
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...
0
7924
Oralloy
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. ...
0
8120
jinu1996
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...
1
7672
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...
0
7968
tracyyun
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...
1
5512
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...
0
3653
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
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 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.