I have been hunting around and have gotten bits and pieces of information regarding windows messaging. I am trying to create a service that captures messages coming in from windows and depending on the message it is supposed to call the function/subs in the main program.

I have found this bit of code that I want to modify:
VB Code:
  1. Protected Overloads Sub WndProc(ByRef m As Message)
  2.         Select Case m.Msg
  3.             'If from Meny Close Is Selected then
  4.             Case Is = WM_SYSCOMMAND
  5.                 Select Case m.WParam.ToInt32
  6.                     Case Is = SC_CLOSE
  7.                         MsgBox("Closing")
  8.                     Case Is = SC_MAXIMIZE
  9.                         MsgBox("Maximize")
  10.                     Case Is = SC_RESTORE
  11.                         MsgBox("Restore")
  12.                 End Select
  13.  
  14.             Case Is = WM_DESTROY
  15.                 MsgBox("Destroy")
  16.             Case Is = WM_CLOSE
  17.                 MsgBox("Close")
  18.  
  19.             Case Is = WM_KEYDOWN
  20.                 MsgBox(m.HWnd.ToString)
  21.                 'MsgBox("Key Down : Virtual Code : " & m.HWnd.ToInt32 & vbCrLf & "Key Data : " & m.LParam.ToInt32)
  22.         End Select
  23.  
  24.         MyBase.WndProc(m)
  25.  
  26.     End Sub

However, I am not sure how to get the messages from windows in the first place. Also, I am getting a msg that wndproc is not part of system.serviceprocess.ServiceBase. Can anybody pls point me in the right direction?

Thank you,

D