Defining a custom *constructor* (not initializer!)

Mehrdad wfunction at hotmail.com
Fri May 11 08:36:35 PDT 2012


On Friday, 11 May 2012 at 15:23:10 UTC, Steven Schveighoffer 
wrote:
> Yes I did mean that.
>
> I'm thinking about it, one thing you did not mention, but 
> almost certainly is the case (it usually is with GUI toolkits) 
> is that the WndProc is called in a different thread or context 
> than the constructor.

It's in the same exact thread as the caller of CreateWindow in 
Win32 (not sure what you mean by "context" here, but AFAIK 
nothing is changed about the thread... nothing fiber-like or 
anything like that going on).
I'm not familiar with other OSes though.

> This means, there may be functions that you can call in WndProc 
> that you cannot call in the ctor.

> So even though CreateWindow returning means WM_CREATE must have 
> been received, the context you need to handle WM_CREATE is 
> gone.  Is that true?

Again, not sure what you mean by "context", but there is nothing 
changed about the thread here.

You could nest the creation of 10 windows down this chain of 
WM_CREATE's (in fact, that's one of its purposes) and it's all 
gonna happen for the same thread, in the same "context" (assuming 
that's referring to the thread context).

Furthermore, the system waits for your response, because if you 
return -1, the window is not created, and an error is returned to 
the caller. (Yet another reason why you need to be able to handle 
the message when it's sent, not a year later.)

>
> I'll wait for an answer before thinking more about this.  It 
> feels imminently solvable...

Okay. :P Though I've thought about it for a while and I'm getting 
more and more convinced there isn't a good solution for this 
without the ability to do custom construction...


More information about the Digitalmars-d mailing list