converting API call

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi, i have this API call in VB6

Public Declare Function SetWindowLong Lib "user32.dll" Alias
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong
As Long) As Long

in sub

SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf WindowProc)



how can i convert this to 2003? thanks
 
Public Declare Function SetWindowLong Lib "user32.dll" Alias
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong
As Long) As Long

in sub

SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf WindowProc)



how can i convert this to 2003? thanks

from www.pinvoke.net:

Private Declare Auto Function SetWindowLong Lib "User32.Dll" _
(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, _
ByVal dwNewLong As Integer) As Integer

You can add alias "SetWindowLongA".
 
thanks, i got that now, but what about the function call?

SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf WindowProc)

you cant exactly pass in "AddressOf WindowProc" as an integer value....i
tried delegate, object...etc but nothing works, any idea?
 
Hello iwdu15,

You're trying to subclass your window procedure here. In the .NET world
you can simply override the window proc. I'd prolly use the NativeWindow
class for this.

-Boo
 
thanks, that works! ive been programming .net for three years now but i
havent really gone into APIs yet, so this is all new for me, thanks for your
help
 
IWDU15
thanks, that works! ive been programming .net for three years now but i
havent really gone into APIs yet, so this is all new for me, thanks for
your
help

We know your age, don't think it is better to use API's in a Net program, is
shows a kind of VB classic programming where was missing a lot to do it
without that.

Using an API is doing a direct call to your OS and therefore depenend from
the version of that Win32, WinFX etc.

Therefore as advice: use it only if there are no Net alternatives.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/win32map.asp

Cor
 
Back
Top