Home All Groups Group Topic Archive Search About
Author
24 Jul 2006 3:27 PM
iwdu15
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
--
-iwdu15

Author
24 Jul 2006 5:43 PM
AMercer
> 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".
Author
24 Jul 2006 5:51 PM
iwdu15
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?
--
-iwdu15
Author
24 Jul 2006 6:27 PM
GhostInAK
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

Show quoteHide quote
> 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
>
Author
24 Jul 2006 6:50 PM
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
--
-iwdu15
Author
25 Jul 2006 6:10 AM
Cor Ligthert [MVP]
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