473,573 Members | 2,814 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide form onload

The following code does not hide the form. Any ideas why? Also, is there a
workaround?
I have VB.NET 2003.

I have a system tray icon, and want to have that be the only thing showing
when the program starts.

Matthew
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
me.hide()
End Sub
Nov 21 '05 #1
4 9152
Hi,

Me.opacity=0

Ken
-----------------------
"Matthew" <tu************ *@alltel.net> wrote in message
news:e4******** *******@TK2MSFT NGP14.phx.gbl.. .
The following code does not hide the form. Any ideas why? Also, is there a
workaround?
I have VB.NET 2003.

I have a system tray icon, and want to have that be the only thing showing
when the program starts.

Matthew
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
me.hide()
End Sub

Nov 21 '05 #2
"Matthew" <tu************ *@alltel.net> schrieb:
The following code does not hide the form. Any ideas why?
Also, is there a workaround?
I have VB.NET 2003.


Never call the 'Show' method of the form, and set the application's startup
object to a 'Sub Main' that contains the code for loading the form and
showing the icon.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3
Matthew,
In addition to the other comments.

It sounds like you used a Form as the startup object of your project, which
you hide, to allow having a NotifyIcon in the system tray. Correct?

Matthew MacDonald's book "Microsoft Visual Basic .NET Programmer's Cookbook"
has a topic on creating a system tray program.

Basically: Rather than using a Form as the startup object, use a Component
instead.

Create a new Component class (use Project - Add Component). Add a NotifyIcon
to the component designer. Also add a ContextMenu object for the
NotifyIcon. When you click the menu, create and show the form. Remember to
put an Exit option on the menu.

Make the Component the startup object, adding a Shared Sub Main to the
component.

Public Class Component1
Inherits System.Componen tModel.Componen t

' Component designer generated code omitted.

Public Shared Sub Main
Dim app as New Component1
Application.Run ()
End Sub

Private Sub menuOptions_Cli ck(...) Handles menuOptions.Cli ck
' this would be your settings dialog.
Dim dialog as New OptionsDialog
dialog.ShowDial og()
dialog.Dispose( )
End Sub

Private Sub menuExit_Click( ...) Handles menuExit.Click
Me.Dispose()
Application.Exi t()
End Sub

End Sub

The problem is you cannot edit the menu from the Component Designer. What I
do is use cut & paste from a Form Designer onto the Component Designer to
get the menu to the component...

The call to Me.Dispose enables the icon to be removed from the system tray
right away rather then waiting.

Hope this helps
Jay
"Matthew" <tu************ *@alltel.net> wrote in message
news:e4******** *******@TK2MSFT NGP14.phx.gbl.. .
The following code does not hide the form. Any ideas why? Also, is there
a workaround?
I have VB.NET 2003.

I have a system tray icon, and want to have that be the only thing showing
when the program starts.

Matthew
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
me.hide()
End Sub

Nov 21 '05 #4
Thanks for all of your comments.
For a temporary solution, I am starting a timer that calles a me.hide()
function.

Jay, I like the looks of your idea. I'll look into it further when I have
time.

Thanks to all for your comments!

Matthew
Nov 21 '05 #5

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

Similar topics

1
11913
by: Don Grover | last post by:
I have a table thats wrapped in a div tag, that when user selects 1 of 2 radio buttons it hides or shows table, this works ok. But I want to set the table show hide on what the existing state of radio buttons are on page load aswell, so if one button is allready selected then the table is hidden else it is shown, can some help me with this,...
5
6772
by: Wouter | last post by:
Hi, I had a javscript what does the follow. When a checkbox is yes then i will see a form field. When a checkbox is no i dont see the form field. Can somehelp me for that script ? Greets Wouter
2
12180
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow { display: none; }
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';
7
3339
chunk1978
by: chunk1978 | last post by:
hello, i would like to know if it's possible to hide PHP values that come back empty (text fields) or have a specific value (select menus)... on my form, there are input fields that are optional, so when the PHP processes the form, i'd like not to see a blank field with nothing written... i'm trying to combine JavaScript with DIV...
2
9595
by: mqudsi | last post by:
I'm making a system tray application, and I just can't figure out how to make it hide on execution just like it used to in C++. If I have a button the form and in the button's Click method i have {this.Hide();} The entire form will disappear. But if I put "this.Hide()" in the from's onLoad code, it *doesn't* get hidden. Can anyone...
3
7764
by: safiratec | last post by:
Hi, I want to show a div depending of the value of a <select> option, using 2 functions hidediv() and showdiv() - it is working fine in firefox, but not in IE (tested with IE 6 and 7). <body onload="javascript:hidediv()"> DOES work in IE, but the rest does not. Any ideas? Thanks a lot Tim here is the code ----------------------------
15
3791
by: worked | last post by:
I have a script that hides / shows form elements, and wrapped in a tab script (tab navigation). When the code is duplicated (per tab content), the hide / show function works for the first tab but breaks in each subsequent tab. Why? Help appreciated! Example: http://geocities.com/edmurphy21/ hide / show script: <script...
0
7704
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...
0
8204
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...
0
8073
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
5600
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
5294
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3734
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...
1
2223
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
1
1309
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1044
bsmnconsultancy
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...

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.