When my program calls my dll, does my dll have to create a windows hook to subclass my dialog? Or can I just SetWindowLong since my .exe called it.
Posted on 2003-07-05 14:19:15 by ESP
SetWindowLong will work because the dll is loaded into the same process as the dialog. You would only need to use a hook if the dll was loaded into another process.
Posted on 2003-07-05 14:50:54 by BubbaFate
I can't get it to work. I'm using FindWindow to get the HWND of my dialog. I know that part works.

invoke SetWindowLong,eax,GWL_WNDPROC,addr MyWndProc ; eax is the window handle.
mov hOldProc,eax
test eax,eax
jnz swlpass
<error code>
return TRUE ;If error at startup, return 0
MyWndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
mov uMsg,eax
szText ztxt,"GOOD"
invoke MessageBox,hWnd,addr ztxt,addr ztxt,0
invoke CallWindowProc, hOldProc, hWnd, uMsg, wParam, lParam
MyWndProc endp

My error message box pops up...
Posted on 2003-07-05 19:21:34 by ESP
Has the window been created when you call the dll? That is the only thing I can see that would result in a zero return from SetWindowLong. Try GetLastError to see what the problem is:
invoke GetLastError

invoke FormatMessage, FORMAT_MESSAGE_FROM_SYSTEM, NULL, eax, NULL, pTempBuffer, 128, NULL
invoke MessageBox, NULL, pTempBuffer, NULL, MB_OK
Posted on 2003-07-05 19:29:09 by donkey
You are right, it's calling the dll before the window is created.
Posted on 2003-07-05 20:02:00 by ESP
This is so weird... I coded a timer to detect when window is open; works. Then it does setwindowlong and returns 0! Why would it return 0? The window is there... The .exe is calling the dll...


Ok I fixed the problem above, but now my program freezes? Could you show me an example of how you would setup a PROC for the window when using SetWindowLong?


lol now I fixed the problem above... Posted before I actually checked myself.

Posted on 2003-07-05 23:47:52 by ESP