Hey guys

I have a little problem. I've written a simple openGL renderer from scratch, including a Window class, which is just a WinAPI wrapper. Now, I'm looking for an elegant way to let every window-object handle it's own messages.

The problem is that all the windows messages dispatched by DispatchMessage() end up in the WndProc function which doesn't belong to any class. At this point, we must find the window object that is associated with the HWND and call it's methods to handle the message. To do this search, a global list of window objects is neccesary. I don't think this is an elegant approach because of the use of globals. I'd rather use an elegant OOP way of dealing with this.

Can someone help me find a more elegant sollution? Does someone know how the VCL is doing this?

Thanks alot.