Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Dear All

I created chat application with vb.net but I have a problem with hide form and restore form back. I mean my application ran already but it hide with notify icon
and when user run it again, it want to restore form chat application back.

I tried it with this code:
VB
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As SHOW_WINDOW) As Boolean
Dim p() As Process = Process.GetProcessesByName("mChat")
If p.Length > 1 Then
    ShowWindow(p(0).MainWindowHandle, SHOW_WINDOW.SW_RESTORE)
End If

But it can not restore.

any idea to do that?

Thanks
Posted
Updated 23-May-12 21:15pm
v2

1 solution

it is very easy, first implement a notifyicon now

to make it visible use following code
VB
if (!me.Visible)
	{
		me.Visible = true;
		me.Show();
		me.WindowState = FormWindowState.Normal;
	}


to hide the form

VB
me.Windowstate=Formwindowstate.Minimized
me.hide
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900