Why doesn't this code work in Visual Studio 12 RC .Net 4.5

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
The code is from the link below. When I try to use this code in a program - for "Protected Overrides Function HookProc" I am told that "function HookProc can not be declared overrides because it does not override a function in a base class". Can anybody
help me? Or is this a Microsoft issue?
Using Visual Studion 12 RC, .Net 4.5, Win 7 Laptop
http://msdn.microsoft.com/en-us/library/system.windows.forms.commondialog.hookproc(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.commondialog.hookproc(v=vs.110).aspx
<pre class="prettyprint Defines the constants for Windows messages.

Const WM_SETFOCUS = &H7
Const WM_INITDIALOG = &H110
Const WM_LBUTTONDOWN = &H201
Const WM_RBUTTONDOWN = &H204
Const WM_MOVE = &H3
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Function HookProc(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr


Evaluates the message parameter to determine the user action.

Select Case msg

Case WM_INITDIALOG
System.Diagnostics.Trace.Write("The WM_INITDIALOG message was received.")
Case WM_SETFOCUS
System.Diagnostics.Trace.Write("The WM_SETFOCUS message was received.")
Case WM_LBUTTONDOWN
System.Diagnostics.Trace.Write("The WM_LBUTTONDOWN message was received.")
Case WM_RBUTTONDOWN
System.Diagnostics.Trace.Write("The WM_RBUTTONDOWN message was received.")
Case WM_MOVE
System.Diagnostics.Trace.Write("The WM_MOVE message was received.")

End Select

Always call the base class hook procedure.

Return MyBase.HookProc(hWnd, msg, wParam, lParam)

End Function

[/code]
<br/>



<span style="color:green Defines the constants for Windows messages.<br/>
<br/>
<span style="color:blue Const WM_SETFOCUS = &H7<br/>
<span style="color:blue Const WM_INITDIALOG = &H110<br/>
<span style="color:blue Const WM_LBUTTONDOWN = &H201<br/>
<span style="color:blue Const WM_RBUTTONDOWN = &H204<br/>
<span style="color:blue Const WM_MOVE = &H3<br/>
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:=<span style="color:#a31515 "FullTrust")> _<br/>
<span style="color:blue Protected<span style="color:blue Overrides<span style="color:blue Function HookProc(<span style="color:blue ByVal hWnd
<span style="color:blue As IntPtr, <span style="color:blue ByVal msg
<span style="color:blue As<span style="color:blue Integer, <span style="color:blue
ByVal wParam <span style="color:blue As IntPtr, <span style="color:blue
ByVal lParam <span style="color:blue As IntPtr) <span style="color:blue
As IntPtr<br/>
<br/>
<br/>
<span style="color:green Evaluates the message parameter to determine the user action.<br/>
<br/>
<span style="color:blue Select<span style="color:blue Case msg<br/>
<br/>
<span style="color:blue Case WM_INITDIALOG<br/>
System.Diagnostics.Trace.Write(<span style="color:#a31515 "The WM_INITDIALOG message was received.")<br/>
<span style="color:blue Case WM_SETFOCUS<br/>
System.Diagnostics.Trace.Write(<span style="color:#a31515 "The WM_SETFOCUS message was received.")<br/>
<span style="color:blue Case WM_LBUTTONDOWN<br/>
System.Diagnostics.Trace.Write(<span style="color:#a31515 "The WM_LBUTTONDOWN message was received.")<br/>
<span style="color:blue Case WM_RBUTTONDOWN<br/>
System.Diagnostics.Trace.Write(<span style="color:#a31515 "The WM_RBUTTONDOWN message was received.")<br/>
<span style="color:blue Case WM_MOVE<br/>
System.Diagnostics.Trace.Write(<span style="color:#a31515 "The WM_MOVE message was received.")<br/>
<br/>
<span style="color:blue End<span style="color:blue Select<br/>
<br/>
<span style="color:green Always call the base class hook procedure.<br/>
<br/>
<span style="color:blue Return<span style="color:blue MyBase.HookProc(hWnd, msg, wParam, lParam)<br/>
<br/>
<span style="color:blue End<span style="color:blue Function<br/>
<hr class="sig Youve taught me everything I know but not everything you know.

View the full article
 
Back
Top