WindowProc in a class - function and pointer problem

evilrat evilrat666 at gmail.com
Thu May 23 00:28:17 PDT 2013


On Thursday, 23 May 2013 at 06:31:02 UTC, Sean Cavanaugh wrote:
>
> I had a partial port of WTL over to D which worked well enough 
> for what I needed, the core of the WndProc handling is down 
> below.   Each HWND is owned by the thread it was created on, so 
> assigning it into D associative array (which is thread local) 
> can do the trick.  It involved a hack, before any call to the 
> Win32 CreateWindow/CreateWindowEx APIs, to capture the 
> association with the new HWND and to remove them when they get 
> cleaned up.  There is probably a better way but this worked 
> enough to get started, and should work with multiple windows 
> reasonably well.
>

sure this is doable but it breaks the entire idea of oop. this is 
also can be put as static member, still it would break oop.

that link i put here is show what is really needed, and it's 
clean and simple.

simply there is only 2 required methods, one for creating(and 
binding) hwnd with class instance and another to retrieve that 
instance and do its own message handling, no other code necessary 
and everything incapsulated. but i don't remember if it works 
without gc messed up that instance while not falling to such 
tricks like arrays(because it is may be possible that gc collect 
instance while window is alive).


More information about the Digitalmars-d-learn mailing list