473,466 Members | 3,167 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Starting A form hidden

Can anyone tell me why this doesn't start hidden?

Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Private Sub InitializeComponent()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
Public Shared Sub Main()
Dim myForm As New Form1
myForm.Visible = False
System.Windows.Forms.Application.Run(myForm)
Return
End Sub
End Class

Dec 5 '05 #1
16 2127
What is the windowstate on the form itself. Why would you want to start
with it hidden?
"AJPlonka" <AJ******@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
Can anyone tell me why this doesn't start hidden?

Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Private Sub InitializeComponent()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
Public Shared Sub Main()
Dim myForm As New Form1
myForm.Visible = False
System.Windows.Forms.Application.Run(myForm)
Return
End Sub
End Class

Dec 5 '05 #2
"AJPlonka" <AJ******@discussions.microsoft.com> schrieb
Can anyone tell me why this doesn't start hidden?
[...]
System.Windows.Forms.Application.Run(myForm)
Run shows the Form. It wouldn't make sense not to show it because this
overloaded version of Run returns as soon as the Form is closed, therefore
it would return immediatelly. If you don't want to start with a startup
form, use Application.Run(). But when do you intend to show the form? There
is no user interface enabling the user to show it. The app would run in the
background without doing anything. Unless you've got a NotifyIcon or a
Timer.
Return
This return is not necessary
End Sub

Armin

Dec 5 '05 #3
You could always set the forms opacity to 0.

Dim Form1 As New Form1
Form1.opacity = 0
Form1.Show()

I use this in a biometric timeclock app I wrote.

When you show the form all you have to do is bring the opacity back to
100, you can even use a loop to make it fade-in.

Dec 6 '05 #4
You can add one line in sub New()
See below

AJPlonka wrote:
Can anyone tell me why this doesn't start hidden?

Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()

me.hide
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Private Sub InitializeComponent()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
Public Shared Sub Main()
Dim myForm As New Form1
myForm.Visible = False
System.Windows.Forms.Application.Run(myForm)
Return
End Sub
End Class

Dec 6 '05 #5
>>Unless you've got a NotifyIcon or a Timer.

Those are just two reasons someone would want to start a form hidden. I can
think of a few more... In my case it is a form that loads directly into the
minimized to the tray. How else would you suggest I use application.run? I
tried it in seperate module with the same results. I want single stand-alone
executable- no dlls.
This return is not necessary

It's useful for setting breakpoints. I forgot to clean it out of the post.
Dec 6 '05 #6
That's a functional workaround. I simply start the form minimized with
showintaskbar false. But that's not what I want to know. I'd like to be able
to simply toggle visible on and off, since opacity and windowstate have other
uses, but I don't see a way of starting a form with visible=false!

Dec 6 '05 #7
> You can add one line in sub New()
me. hide


That's a reasonable assumption. Are you using 2005? I haven't had time to
install it yet. It doesn't hide anything on my installation of 2003.
Dec 6 '05 #8
> That's a functional workaround.

Though as I think about it, wouldn't a transparent (as opposed to hidden)
form still respond to mouseclicks and keystrokes? But I suppose it would
suffice for loading purposes.

Dec 6 '05 #9
"AJPlonka" <AJ******@discussions.microsoft.com> schrieb
Unless you've got a NotifyIcon or a Timer.

Those are just two reasons someone would want to start a form
hidden. I can think of a few more... In my case it is a form that
loads directly into the minimized to the tray. How else would you
suggest I use application.run? I tried it in seperate module with
the same results.


Post some code.
I want single stand-alone executable- no dlls.


Then you have to write your own just-in-time compiler, your own managed
execution environment, your own memory management - and do not even declare
an Integer variable because the type is located in mscorlib.dll which is
part of the Framework that is, for the reasons mentioned, the minimum
requirement for every .Net application.
Back to your question... I copied some parts of a real-world app. Does this
help?
Private Shared WithEvents NI As NotifyIcon
Private Shared MainForm As Form1

Shared Sub main()

NI = New NotifyIcon

Try
NI.Visible = True

Try
MainForm = New Form1
Application.Run()
Finally
NI.Visible = False
End Try
Finally
NI.Dispose()
End Try

End Sub

Private Shared Sub NI_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NI.DoubleClick
ShowOrActivateForm()
End Sub

Private Shared Sub ShowOrActivateForm()
If MainForm.Visible Then
MainForm.Activate()
Else
MainForm.Show()
End If
End Sub

Armin

Dec 7 '05 #10
> > I want single stand-alone executable- no dlls.

Then you have to write your own just-in-time compiler, your own managed
execution environment, your own memory management - and do not even declare
an Integer variable because the type is located in mscorlib.dll which is
part of the Framework that is, for the reasons mentioned, the minimum
requirement for every .Net application.
That's just silliness. By that reasoning, you made assumptions about my
operating system. And what about the bootstrap loader? Heck, if JAVA apps can
be referred to as standalone outside of a browser I think it's perfectly
reasonable to call a .NET executable without distributed DLLs "standalone."

If you run an application, you assume it to be in context, be it framework,
VM, or OS. But, to be clear: I meant a single executable file for
distribution to clients with .Net installed.


Back to your question... I copied some parts of a real-world app. Does this
help?

I already have a real-world solution: I delegated the task. What I am
interested in is the underlying theory.

Maybe I should have titled the thread "Loading a form hidden." I want the
form to load and be active. Invisibly. There are timer events and message
monitors, etc, that I want to be up and processing.

Try statements are kludgy at best. This code was helpful, though because it
helped me see my stupid mistake (I included the object as a parameter to the
run statement)

Private Shared WithEvents NI As NotifyIcon
Private Shared MainForm As Form1

Shared Sub main()

NI = New NotifyIcon

Try
NI.Visible = True

Try
MainForm = New Form1
Application.Run()
Finally
NI.Visible = False
End Try
Finally
NI.Dispose()
End Try

End Sub

Dec 7 '05 #11
AJ,
> I want single stand-alone executable- no dlls.


Then you have to write your own just-in-time compiler, your own managed
execution environment, your own memory management - and do not even
declare
an Integer variable because the type is located in mscorlib.dll which is
part of the Framework that is, for the reasons mentioned, the minimum
requirement for every .Net application.


That's just silliness. By that reasoning, you made assumptions about my
operating system. And what about the bootstrap loader? Heck, if JAVA apps
can
be referred to as standalone outside of a browser I think it's perfectly
reasonable to call a .NET executable without distributed DLLs
"standalone."

No Armin gave you the exact answer if you want to use the Net development
enviroment, withouth completely all parts of the framework.

If you want to do it in another development way, you have even much more
posibilities than you wrote, however not always with the same results as you
have with the Net development environment.

Just my thought,

Cor.
Dec 7 '05 #12
"AJPlonka" <AJ******@discussions.microsoft.com> schrieb
I want single stand-alone executable- no dlls.
Then you have to write your own just-in-time compiler, your own
managed execution environment, your own memory management - and do
not even declare an Integer variable because the type is located
in mscorlib.dll which is part of the Framework that is, for the
reasons mentioned, the minimum requirement for every .Net
application.


That's just silliness. By that reasoning, you made assumptions about
my operating system. And what about the bootstrap loader? Heck, if
JAVA apps can be referred to as standalone outside of a browser I
think it's perfectly reasonable to call a .NET executable without
distributed DLLs "standalone."

If you run an application, you assume it to be in context, be it
framework, VM, or OS. But, to be clear: I meant a single executable
file for
distribution to clients with .Net installed.


Sorry guy, I didn't know your skills before. Some people really think "no
dlls" means "no dlls". If you follow dotnet groups, this is not a rare
question. Otherwise I wouldn't have mentioned this, therefore it's not
silliness. Apart from this, I don't see the relation to your actual problem,
but never mind.
Back to your question... I copied some parts of a real-world app.
Does this help?

I already have a real-world solution: I delegated the task. What I
am interested in is the underlying theory.

Maybe I should have titled the thread "Loading a form hidden." I
want the form to load and be active. Invisibly.


"That's just silliness". An invisible Form can never be active. "Active" is
a term concerning the focus of a window. I've had a hard time trying to
focus an invisible window...
There are timer
events and message monitors, etc, that I want to be up and
processing.
Only a hint, if it's permitted: You do not necessarily need Form to use a
(Windows.Forms.)Timer
Try statements are kludgy at best. This code was helpful, though
because it helped me see my stupid mistake (I included the object as
a parameter to the run statement)


Glad to have helped you.
Armin

Dec 7 '05 #13
> silliness. Apart from this, I don't see the relation to your actual problem,
but never mind. I was thinking that perhaps embedding the form in a dll and then calling it
might work. You're right, it was an off-track comment.
Maybe I should have titled the thread "Loading a form hidden." I
want the form to load and be active. Invisibly.


"That's just silliness". An invisible Form can never be active. "Active" is
a term concerning the focus of a window. I've had a hard time trying to
focus an invisible window...

I realize I'm tripping up on my own semantics. For me, "standalone" means
compiling with bcom instead of brun. And I still call an audio CD is an
"album." Oh well. I should have said "load and processing events." But your
comment surprised me. I checked and, sure enough, take a form below 2%
opacity and it simply stops responding to the interface. So how to build
hotspot overlays? Sorry, I'm digressing...
Only a hint, if it's permitted: You do not necessarily need Form to use a
(Windows.Forms.)Timer I may follow up on that. I just find using the designer an easier way of
keeping track of my code.
Glad to have helped you.

It helped to confirm that there's no straigtforward up-front way of
configuring a form to do what I was asking. It seems like simple enough
requirement: Load invisibly and process events. Thanks, I do appreciate your
time given to this.

Dec 7 '05 #14
And I would be using vb to do this because...

"Cor Ligthert [MVP]" wrote:
AJ,
> I want single stand-alone executable- no dlls.

Then you have to write your own just-in-time compiler, your own managed
execution environment, your own memory management - and do not even
declare
an Integer variable because the type is located in mscorlib.dll which is
part of the Framework that is, for the reasons mentioned, the minimum
requirement for every .Net application.


That's just silliness. By that reasoning, you made assumptions about my
operating system. And what about the bootstrap loader? Heck, if JAVA apps
can
be referred to as standalone outside of a browser I think it's perfectly
reasonable to call a .NET executable without distributed DLLs
"standalone."

No Armin gave you the exact answer if you want to use the Net development
enviroment, withouth completely all parts of the framework.

If you want to do it in another development way, you have even much more
posibilities than you wrote, however not always with the same results as you
have with the Net development environment.

Just my thought,

Cor.

Dec 7 '05 #15
It doesn't! That suprised me. Your workaround is better than mine because
sometimes the app loads before the taskbar fully initializes on bootup,
leaving an ungainly minimized form. Thanks.

"AJPlonka" wrote:
That's a functional workaround.


Though as I think about it, wouldn't a transparent (as opposed to hidden)
form still respond to mouseclicks and keystrokes? But I suppose it would
suffice for loading purposes.

Dec 7 '05 #16
"AJPlonka" <AJ******@discussions.microsoft.com> schrieb
silliness. Apart from this, I don't see the relation to your
actual problem, but never mind.

I was thinking that perhaps embedding the form in a dll and then
calling it might work. You're right, it was an off-track comment.
Maybe I should have titled the thread "Loading a form hidden." I
want the form to load and be active. Invisibly.


"That's just silliness". An invisible Form can never be active.
"Active" is a term concerning the focus of a window. I've had a
hard time trying to focus an invisible window...

I realize I'm tripping up on my own semantics. For me, "standalone"
means compiling with bcom instead of brun.


You mean D:\DOS\Qb4\BCOM41.LIB? ;-)
Glad to have helped you.

It helped to confirm that there's no straigtforward up-front way of
configuring a form to do what I was asking. It seems like simple
enough requirement: Load invisibly and process events. Thanks, I do
appreciate your time given to this.


Sorry, I still don't see the problem. If you create the Form, the contained
timer will run even if you don't show the Form. Therefore you do have an
invisible Form and events are processed (that's what application.run is
for). Why is this not straightforward?
Armin

Dec 7 '05 #17

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

Similar topics

0
by: Terence Parker | last post by:
I am trying to connect an e-commerce system to a payment gateway (located in Hong Kong). The gateway takes values in the form of a simple form submit - however, the results (i.e. authorisation...
5
by: Yang Li Ke | last post by:
Hi I know that there is a meta tag function to get all meta tags from a url. I am searching for a similar function that would get all values of a form. something like : <form> <input...
7
by: Randell D. | last post by:
Folks, I am working on a contact db using PHP and MySQL. My results so far outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can...
1
by: Don Stefani | last post by:
Hello, I have a form that I want to submit "onchange", OK I've got that working, but when the form submits, I want to pass along a value to a CGI script, as if that value was in a hidden form...
1
by: TopherB | last post by:
Hi, First let me say that my knowledge of HTML and Javascript is fairly limited. But I am stuck in a situation of trying to adapt a website's shopping cart to a new one. Here's the problem, the...
0
tolkienarda
by: tolkienarda | last post by:
hi all most of you have seen this form, mostly it has hidden attributes some of which can be changed to select boxes. the part that seems to be a security flaw is that people can edit live html...
11
by: newbie | last post by:
i have a form in which a hidden field (initial value as '0', and my javascript set it to '1' when an event is trigged). In the same form, i have a reset field. But I realized that the hidden field...
3
by: msg2ajay | last post by:
hi, I am not able to align the textfield to the top of the frame one bye one. The problem is it is showing where it is hiding..... so is it possible to allign the text field to the top of...
1
by: chas2007 | last post by:
I need to pass a variable from a php function to a form. Does anyone have an example of code that would do this? Below is the code. I need to pass the "return value" from the php function mem_cost...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
1
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...
0
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...
0
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...
0
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...

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.