|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
AddressOf from VB6 to .Net VB(ByVal hw As Integer, _ ByVal uMsg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer) As Integer Private Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" _ (ByVal hwnd As Integer, _ ByVal nIndex As Integer, _ ByVal dwNewLong As WndCallback) As WndCallback Private PrevWndPRoc As WndCallback Public Sub RegisterFormForOrientationDetection(ByRef f As System.Windows.Forms.Form) PrevWndPRoc = SetWindowLong(f.Handle.ToInt32(), _ GWL_WNDPROC, _ BBB-> AddressOf WndProcWithRotationDetection) End Sub Hi, I have converted the VB6 code to .NET according to microsoft. The compilation is okey, but i get an exception in runtime on line BBB that says: Invalid function pointer 0xffff0557 was passed into the runtime to be converted to a delegate. Passing in invalid function pointers to be converted to delegates can cause crashes, corruption or data loss. What i did wrong ? Thanks, Pavel. Sorry, i forgit the function itself.
Public Function WndProcWithRotationDetection(ByVal hw As Integer, _ ByVal uMsg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer) As Integer ' Do the job End Functon Hello Pavel,
If your WndProcWithRotationDetection function is not in a module, you must declare it Shared. With Windows API functions that admit ANSI and Unicode versions, you should declare them Auto to avoid trouble when passing strings (it's only my opinion): Declare Auto Function SetWindowLong Lib "USER32.DLL" (ByVal hwnd ... Anyway, if you are processing Windows messages sent to your form, you don't need to do Platform Invoke: You can override the functions PreProcessMessage and WndProc. If you only want to send messages, you can override DefWndProc. You can also create a class that implements IMessageFilter and use Application.AddMessageFilter to activate it. This only let you see the messages and to stop them from reaching WndProc. Regards. Show quoteHide quote <pavel.ore***@gmail.com> escribió en el mensaje news:1143021942.238057.85900@g10g2000cwb.googlegroups.com... | Private Delegate Function WndCallback _ | (ByVal hw As Integer, _ | ByVal uMsg As Integer, _ | ByVal wParam As Integer, _ | ByVal lParam As Integer) As Integer | | Private Declare Function SetWindowLong Lib "USER32.DLL" Alias | "SetWindowLongA" _ | (ByVal hwnd As Integer, _ | ByVal nIndex As Integer, _ | ByVal dwNewLong As WndCallback) As WndCallback | | Private PrevWndPRoc As WndCallback | | Public Sub RegisterFormForOrientationDetection(ByRef f As | System.Windows.Forms.Form) | PrevWndPRoc = SetWindowLong(f.Handle.ToInt32(), _ | GWL_WNDPROC, _ | BBB-> AddressOf WndProcWithRotationDetection) | End Sub | | Hi, | | I have converted the VB6 code to .NET according to microsoft. | The compilation is okey, but i get an exception in runtime on line BBB | that says: | | Invalid function pointer 0xffff0557 was passed into the runtime to be | converted to a delegate. Passing in invalid function pointers to be | converted to delegates can cause crashes, corruption or data loss. | | What i did wrong ? | | Thanks, | Pavel. Check out the NativeWindow class for a better way to do window
subclassing in maanged code. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Decimal/Single/...: which Numeric-type to use?
Sorting a System.Collections.ObjectModel.Collection Object variable or With block variable not set Converting vb.net book examples Process.Start() throws an error saying "Setup error: failed to load resources from resource file Ple ot: mvps, how do you propse one? Creating a CSV from query results Sending emails to multiple recipients ADO RowState problem Destroying objects |
|||||||||||||||||||||||