|
-
Apr 13th, 2004, 04:05 AM
#1
Thread Starter
Junior Member
Accessing objects from another form
Hello again all,
I'm trying to figure the following:
My application has an invisible form that shows a system tray icon. This icon (as most will know) doesn't always work properly in regards of exitting the application. (It can linger in the tray)
Now, to make this work, I wanted to create a sub in a module that will take care of shutting down the application and then, if I want to - say - shutdown the program from another form (Of the same program) I would call that procedure and it will first make the icon invisible (ntiMain.Visible = False)
The problem is, I don't know how to access objects from a form (any form) in a module. Is this possible?
I tried it with the following sub:
VB Code:
Sub ShutDown()
Dim frm As Form
frm = frmMain
frm.ntiMain.Visible = False
frm.Close
End Sub
needless to say this doesn't work.
Thanks if you can help me...
-
Apr 13th, 2004, 09:28 AM
#2
PowerPoster
Hi,
There are several ways of accessing a sub in another form or module. Try searching this forum, it has been discussed indetail many times this year.
One way is to declare the Sub as Public, e.g. for your purpose put this sub in the module
VB Code:
Public Sub CloseDown()
Application.Exit
End Sub
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Apr 14th, 2004, 01:36 AM
#3
Thread Starter
Junior Member
Hi, thanks for your reply.
I know how to access a shared/public Sub, I just want to be able to control my inactive form from the active form. I.e. an event happens on the active form, which should cause the inactive form to reload. How do I do this?
Thanks again!
-
Apr 14th, 2004, 10:39 AM
#4
PowerPoster
Hi,
"I know how to access a shared/public Sub, I just want to be able to control my inactive form from the active form. I.e. an event happens on the active form, which should cause the inactive form to reload. How do I do this?"
This is totally different from what you first posted. Please clarify the following;
1. You are referring to VB.NET
2. What do you mean by " reload the inactive form"? - You do not "reload" anything in VB.NET. You create an instance, which you can:
a. Make Visible or Invisible
b. Make the form infocus or not.
c. Destroy the instance.
d. Hold a reference to the form in another object variable, which can be manipulated independently of the original.
You can do all the above from another form or module. There should be no problem.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Apr 15th, 2004, 01:35 AM
#5
Thread Starter
Junior Member
hi, thanks for the reply...
1) I am referring to VB.Net 2003 Enterprise edition
2) I mean, I want to close down the form, show it again and then close the active form... So here is a little more detail (sorry if I wan't too clear earlier)
I have a form hidden, that has a system tray icon. From the system tray icon, you can activate another (not hidden) form where you can set a few things up, such as an alarm. This alarm resides on the form which is hidden and holds the system tray icon.
So, Interval and Enabled/Disabled properties should be sent from one form to another. If the user enables the timer, the timer should start right away. If the user disables the timer, the timer should stop right away.
If the timer is set to a certain interval (i.e. 6000) from its default value, the interval should be changed immediately...
I thought the easiest way to do this, (since I'm pretty new to all this) was to save the settings to a file, then close down the system tray icon-form, then show it again and use the event Form_Load to pull in the information for the timer... I know this is probably not the easiest way, but it was the only way I could think of since I don't know how to send information across forms...
I'm sorry once again if I wasn't clear enough earlier! Thanks for your help!
-
Apr 15th, 2004, 02:10 AM
#6
Thread Starter
Junior Member
Hmmm I found the answer to my questions!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|