detect windows messages to bp window
BlitzPlus Forums/BlitzPlus Programming/detect windows messages to bp window
| ||
greetings all :) i am looking to see if i can detect a custom windows message sent to a bp window. the goal is to send a pb window a custom message from a different EXE. i have successfully retrieved the window handle, but when i postmessage or sendmessage to it, i cant figure out how to accept those messages in bp. i tried detecting them using WaitEvent() but that doesnt seem to work. any direction would be much appreciated :) |
| ||
I would try PeekEvent() first and if it doesn't work you could move on to the user32 PeekMessage function. You'll need to make a MSG and POINTAPI struct for the first param so decent userlib knowledge is nessecary. Structs are Types in BB so it would go like this VB Code Private Type POINTAPI x As Long y As Long End Type Private Type Msg hWnd As Long Message As Long wParam As Long lParam As Long time As Long pt As POINTAPI End TypeBB type Type POINTAPI Field x%,y% End TypeTo use a type for a param you would declare it as MSG* in the userlib. .lib "user32.dll" PeekMessage%(MSG*, hwnd%, wMsgFilterMin%, wMsgFilterMax%, wRemoveMsg%):"PeekMessageA"The line pt As POINTAPI might give you trouble in the MSG type declare, maybe someone knows how to get around that. |
| ||
I wanted to do the same thing once upon a time, but found that PeekEvent tended to be unreliable at best. For this reason I wrote BLESS (the BLitz EventS System). It's a Blitz3D or BlitzPlus add-on that gives you access to any Windows notification or message (i.e. event) that you want. I'm getting close to releasing version 1.0, but you can check out the BLESS beta at www.mintysoftware.com, and sign up for the newsletter so you'll be in the know when I do release 1.0. |
| ||
thank you for the answers. i have been able to successfully read the message. is there a way to kick an event such that the waitevent() will fire without using a timeout on it? i think the timeout will simply have to be good enough, but if i can kick it programatically from another app somehow (was hoping i could do it using postmessage or sendmessage) that would be ideal. thank you. |
| ||
You can, but it's kind of a hack. Send a WM_CHAR message with the character code in the unused unicode utf-16 range ($d800-$dfff I think). Then just detect event $103 in Blitz. You'll have a harder time getting your lparam and wparam data, though (if you need it at all). This is akin to what BLESS does and it works pretty well. |