Click here to Skip to main content
16,005,121 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: comma delimited text file Pin
_AK_19-Sep-06 21:47
_AK_19-Sep-06 21:47 
Questionstop refresh of drawing Pin
amilapradeep19-Sep-06 17:41
amilapradeep19-Sep-06 17:41 
AnswerRe: stop refresh of drawing Pin
Christian Graus19-Sep-06 17:44
protectorChristian Graus19-Sep-06 17:44 
GeneralRe: stop refresh of drawing Pin
Dave Kreskowiak20-Sep-06 2:11
mveDave Kreskowiak20-Sep-06 2:11 
GeneralRe: stop refresh of drawing Pin
Christian Graus20-Sep-06 10:46
protectorChristian Graus20-Sep-06 10:46 
AnswerRe: stop refresh of drawing Pin
Dave Kreskowiak20-Sep-06 2:10
mveDave Kreskowiak20-Sep-06 2:10 
AnswerRe: stop refresh of drawing Pin
Uber126-Sep-06 10:28
Uber126-Sep-06 10:28 
QuestionProblems accessing form from module Pin
projecthiphop19-Sep-06 17:22
projecthiphop19-Sep-06 17:22 
I am using VS 2002. I have put the code down below. I have a module that creates a systray application. Ideally I would like to hit the Form123_load on the class from the module so it will execute a listener for a hotkey.



I have a sub called staticmethod that does execute my messagebox but only if the login button is pressed (so the module must require an action). How can I have it access the form123_load sub from the module automitically when the program runs without an action placed upon the module?

Thank you!


Module Imports systray1.vbAccelerator.Components.HotKey


Public Class Form123
Inherits vbAccelerator.Components.HotKey.HotKeyForm

Shared Sub staticmethod()
MessageBox.Show("hello")

End Sub
Public Sub Form123_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' add an event handler for hot key pressed (or could just use Handles)
AddHandler Me.HotKeyPressed, AddressOf hotKey_Pressed

' set the hotkey:
Dim htk As HotKey = New HotKey("My HotKey", Keys.Up, HotKey.HotKeyModifiers.MOD_CONTROL Or HotKey.HotKeyModifiers.MOD_SHIFT)
Me.HotKeys.Add(htk)

'this is a test
'show a messagebox:

End Sub

Private Sub Form123_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Closed
' remove the dynamic event handler
RemoveHandler Me.HotKeyPressed, AddressOf hotKey_Pressed
End Sub

Private Sub hotKey_Pressed(ByVal sender As System.Object, ByVal e As HotKeyPressedEventArgs)
' ensure form is shown:
Me.RestoreAndActivate()

'show a messagebox:
MessageBox.Show(Me, _
String.Format("HotKey Pressed:" + vbCrLf + "Name: {0} " + vbCrLf + "KeyCode: {1}" + vbCrLf + "Modifiers: {2}", _
e.HotKey.Name, _
e.HotKey.KeyCode.ToString(), _
e.HotKey.Modifiers.ToString()), _
".NET Hot Key Demonstration", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Sub

End Class

Module systray
Private systray As New NotifyIcon()

Public Sub Main()

Dim mnu As New ContextMenu()
Dim mnuitem As New MenuItem()
Dim mnuitem2 As New MenuItem()

'First
mnuitem.Text = "Exit"
AddHandler mnuitem.Click, AddressOf EndApp
mnu.MenuItems.Add(mnuitem)
'second
mnuitem2.Text = "Login"
AddHandler mnuitem2.Click, AddressOf LoginApp
mnu.MenuItems.Add(mnuitem2)

systray.ContextMenu = mnu
systray.Icon = New Icon(Application.StartupPath & "\systray.ico")
systray.Visible = True

Application.Run()

'try to access the form
Form123.staticmethod()

End Sub


Private Sub LoginApp(ByVal sender As Object, ByVal e As EventArgs)
systray.Visible = True
Dim frmchklogininstance As New frmLogin()

frmchklogininstance.Show()
'try to access the form
Form123.staticmethod()
End Sub
End Module



Public Sub Main()



'try to access the form
Form123.staticmethod()

End Sub


End Module

Public Class Form123
Inherits vbAccelerator.Components.HotKey.HotKeyForm


Shared Sub staticmethod()
MessageBox.Show("hello")

End Sub
Public Sub Form123_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'ideally i would like to hit this sub
' MessageBox.Show("hello")
End Sub


End Class


Questionurgent~~~~please help!!!! Pin
JackieWill19-Sep-06 16:11
JackieWill19-Sep-06 16:11 
AnswerRe: urgent~~~~please help!!!! Pin
Christian Graus19-Sep-06 16:43
protectorChristian Graus19-Sep-06 16:43 
GeneralRe: urgent~~~~please help!!!! Pin
JackieWill19-Sep-06 18:16
JackieWill19-Sep-06 18:16 
GeneralRe: urgent~~~~please help!!!! Pin
Christian Graus19-Sep-06 18:57
protectorChristian Graus19-Sep-06 18:57 
GeneralRe: urgent~~~~please help!!!! Pin
nlindley720-Sep-06 3:07
nlindley720-Sep-06 3:07 
Questionchange data grid background color?? Pin
campbells19-Sep-06 15:45
campbells19-Sep-06 15:45 
Questionadvanced questions about usercontrols Pin
schachmat19-Sep-06 10:41
schachmat19-Sep-06 10:41 
AnswerRe: advanced questions about usercontrols Pin
Christian Graus19-Sep-06 11:27
protectorChristian Graus19-Sep-06 11:27 
GeneralRe: advanced questions about usercontrols Pin
schachmat19-Sep-06 11:43
schachmat19-Sep-06 11:43 
GeneralRe: advanced questions about usercontrols Pin
Christian Graus19-Sep-06 11:48
protectorChristian Graus19-Sep-06 11:48 
GeneralRe: advanced questions about usercontrols Pin
schachmat19-Sep-06 12:22
schachmat19-Sep-06 12:22 
GeneralRe: advanced questions about usercontrols Pin
darkelv19-Sep-06 14:32
darkelv19-Sep-06 14:32 
NewsRe: advanced questions about usercontrols Pin
schachmat20-Sep-06 0:47
schachmat20-Sep-06 0:47 
GeneralRe: advanced questions about usercontrols Pin
darkelv20-Sep-06 6:45
darkelv20-Sep-06 6:45 
GeneralRe: advanced questions about usercontrols Pin
schachmat20-Sep-06 7:02
schachmat20-Sep-06 7:02 
GeneralRe: advanced questions about usercontrols Pin
darkelv20-Sep-06 7:50
darkelv20-Sep-06 7:50 
QuestionVB.Net 2005 How do I delete a project? Pin
cj433119-Sep-06 10:02
cj433119-Sep-06 10:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.