473,606 Members | 2,444 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 9155
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
11919
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
6774
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
12181
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
7993
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
3340
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
7767
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
3798
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
8449
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...
0
8432
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8310
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...
0
6781
agi2029
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...
1
5968
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
5466
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
3942
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...
1
2451
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
1561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.