Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

WndProc in DLL for scripting?

Name: Anonymous 2006-10-08 14:04

I use a couple convenient scripting languages that can utilize DLLs. From these scripting languages, I can call many of the Win32 API functions, which has been very useful. But obviously any that require some callback function pointer will never work (unless I want to throw some machine code into a string and give it that pointer, but I'd rather not).

The one thing I would like to do is create some native windows (I'm not interested in tk-like emulation), but that requires a WndProc. So I was wondering if it's possible to put the WndProc into a DLL of my own, and do some thread syncing like shown below.

--Scripting language pseudo code --
Do
{
    WaitForMessage(&msg, &wParam, &lParam)
    // Do something with the message
}

--DLL code (a little pseudo)----
HANDLE g_hWaiter;
UINT g_msg;
WPARAM g_wParam;
LPARAM g_lParam;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    g_msg = msg;
    g_wParam = wParam;
    g_lParam = lParam;
    SetEvent(g_hWaiter);
    // Need to block here until WaitForMessage is called again by the script
}

WaitForMessage(UINT * msg, WPARAM * wParam, LPARAM * lParam)
{
    WaitForSingleObject(g_hWaiter, INFINITE);
    *msg = g_msg;
    *wParam = g_wParam;
    *lParam = g_wParam;
)
--------------------------------

I have had no luck finding this kind of concept on Google, which makes me think
1) this approach is fundamentally flawed in some way so no one has done it, or
2) no one is interested in doing something like this, or
3) I'm not searching with the right terms
4) ???
5) Profit!

What does Anonymous think?

Name: Anonymous 2006-10-08 23:35

>>3

Java can totally do native callbacks, and really easily at that

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List