Connecting Tech Pros Worldwide Help | Site Map

Reference form from one project in another?

Thief_
Guest
 
Posts: n/a
#1: Nov 21 '05
I have two projects in one solution:

a.. Outlook Monitor
b.. Tray Notification
Both contain a form called "Form1.vb". How do I reference "Outlook
Monitor"'s Form1 from "Tray Notification"'s form1? Here's my code example
taken from "Tray Notification"'s form1:

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'--- Create ContextMenu
'Dim TrayContextMenu As ContextMenu = New ContextMenu

'Add itens on ContextMenu
TrayContextMenu.MenuItems.Add("&Restore", New
System.EventHandler(AddressOf Me.mnuRestore_click))
TrayContextMenu.MenuItems.Add("-")
TrayContextMenu.MenuItems.Add("&Exit", New
System.EventHandler(AddressOf Me.mnuExit_click))

'--- Create NotifyIcon
'Dim TrayNotifyIcon As BalloonTip = New BalloonTip

' Show Notify Icon
TrayNotifyIcon.Text = Me.Text ' Help text for MouseLeave on Icon
TrayNotifyIcon.Icon = Me.Icon ' Icon for NotifyIcon
TrayNotifyIcon.Form = Me ' Form to restore when DoubleClick on Icon
TrayNotifyIcon.ContextMenu = TrayContextMenu ' ContextMenu for
RightClick on Icon
TrayNotifyIcon.Visible = True ' Show icon in TaskBar

' Show Balloon Tip
TrayNotifyIcon.ShowBalloon(Me.Text, "Line 1" + vbLf + "Line 2",
BalloonTip.NotifyInfoFlags.Info, 1000)
End Sub


I want to change the three lines of code under the line "' Show Notify Icon"
to reference the other project's form.

--
|
+-- Thief_
|


Dennis
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Reference form from one project in another?


Use an imports statement then a qualifier for form1, i.e., in your
Traynotification project module where you want to call Outlook Monitor's
Form1,

Imports OutlookMonitor (or whatever the project is labeled in the solution
explorer)


Then to show the form;

OutlookMonitor.Form1.Show

I think this is what you need. Good Luck
--
Dennis in Houston


"Thief_" wrote:
[color=blue]
> I have two projects in one solution:
>
> a.. Outlook Monitor
> b.. Tray Notification
> Both contain a form called "Form1.vb". How do I reference "Outlook
> Monitor"'s Form1 from "Tray Notification"'s form1? Here's my code example
> taken from "Tray Notification"'s form1:
>
> Code:
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> '--- Create ContextMenu
> 'Dim TrayContextMenu As ContextMenu = New ContextMenu
>
> 'Add itens on ContextMenu
> TrayContextMenu.MenuItems.Add("&Restore", New
> System.EventHandler(AddressOf Me.mnuRestore_click))
> TrayContextMenu.MenuItems.Add("-")
> TrayContextMenu.MenuItems.Add("&Exit", New
> System.EventHandler(AddressOf Me.mnuExit_click))
>
> '--- Create NotifyIcon
> 'Dim TrayNotifyIcon As BalloonTip = New BalloonTip
>
> ' Show Notify Icon
> TrayNotifyIcon.Text = Me.Text ' Help text for MouseLeave on Icon
> TrayNotifyIcon.Icon = Me.Icon ' Icon for NotifyIcon
> TrayNotifyIcon.Form = Me ' Form to restore when DoubleClick on Icon
> TrayNotifyIcon.ContextMenu = TrayContextMenu ' ContextMenu for
> RightClick on Icon
> TrayNotifyIcon.Visible = True ' Show icon in TaskBar
>
> ' Show Balloon Tip
> TrayNotifyIcon.ShowBalloon(Me.Text, "Line 1" + vbLf + "Line 2",
> BalloonTip.NotifyInfoFlags.Info, 1000)
> End Sub
>
>
> I want to change the three lines of code under the line "' Show Notify Icon"
> to reference the other project's form.
>
> --
> |
> +-- Thief_
> |
>
>
>[/color]
Closed Thread