473,699 Members | 3,134 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 9161
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
11932
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, Existing code below Regards Don. '**************** <html>
5
6778
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
12185
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
8004
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
3343
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 displays to make this happen, but of-course, it doesn't work... i'm just a novice afterall... this is...
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 advise me as to what I'm doing wrong? Why would the same
3
7769
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
3803
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 type="text/javascript"> function showHide() { var idx = this.id.split('-'); var sp =...
0
9199
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8947
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
8902
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6552
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
5891
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
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
4642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.