Using delegate for WindowProc - possible ?

Juan Campanas johnny at bells.com
Thu Dec 29 22:02:54 PST 2011


On Thursday, 29 December 2011 at 20:08:45 UTC, bls wrote:
> import std.stdio;
> import std.functional;
>
> int main(string[] argv)
> {
> 	
>
> 	extern(Windows)	int delegate( int i) dg;
> 	alias dg callback;
>
> 			
> 			callback = toDelegate(&test);
>
> 			writeln( callback( 1 ) );
> 			
> 			readln();
>
>
> return 0;
> }
>
> extern(Windows) int test(int i) { return 41 +i;}
>
> hth, bjoern

Wow! This is actually pretty cool! I needed something similar, 
but it was to call a member function from the Windows procedure, 
and I had to use some thunking though assembly.

Maybe I can adapt my code to use a delegate like this instead.


More information about the Digitalmars-d-learn mailing list