Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - VB - Subclassing weirdness
  
User name:
Password:
Reply:
 

UserPost
HyperLamer
Posts: 461/8210
Something ain't right here. I added a hidden window to my app with a fixed title to allow other processes to find it with FindWindow(). I've subclassed the window as such:
ProcOld = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WindowProc)
So this should have the WindowProc() function in my program (which is in a module, not the window's code) run whenever the window recieves a message. The function is designed to respond to message ID 0xBEEF and return version info, variables, etc. I also have another program send such a message with wParam and lParam=0. The message is recieved alright, but the source hWnd is my own message window and lParam is some random garbage (it's not the source hWnd, I checked).
Here's the function BTW:


Public Function WindowProc(ByVal hWnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim ReturnwParam As Long, ReturnlParam As Long, bReturn As Boolean

If iMsg = WM_MEMREQUEST Then
bReturn = True 'Most will return something
'Here would be the case select that determines what to reply with, left out because it's big and unnecessary

'Send a message back if need be
If bReturn Then SendMessage hWnd, WM_MEMREQUEST, ReturnwParam, ReturnlParam
Else
'Call the original window proc
WindowProc = CallWindowProc(ProcOld, hWnd, iMsg, wParam, lParam)
End If
If LogDbg And hWnd <> frmMessageWindow.hWnd Then WriteDebugLog "Window message 0x" + hex$(iMsg) + " recieved from 0x" + hex$(hWnd) + ": 0x" + hex$(wParam) + ", 0x" + hex$(lParam)
End Function

(WM_MEMREQUEST is a constant defined within my app equal to 0xBEEF.)
So... any ideas?

[edit] I figured out WTF's up with lParam... almost. Here's the log from the other app sending a message:

Window message 0xBEEF recieved from 0x6004FE: 0x0, 0x12FC2C
Window message 0xBEEF recieved from 0x6004FE: 0xB16B00B5, 0xB00B1E5

The second message is entirely accurate, but the first is entirely non-existant. Also I still have to way to get the source hWnd.
Whoo, big lightning. *unplugs cable and watches*
Acmlm's Board - I2 Archive - Programming - VB - Subclassing weirdness


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.004 seconds.