Using delegate for WindowProc - possible ?
bls
bizprac at orange.fr
Thu Dec 29 11:39:00 PST 2011
On 12/28/2011 03:45 PM, Tal wrote:
> Can I do something like this :
> ______________________________________________________________________
> extern (Windows) LRESULT delegate (HWND hWnd, UINT message, WPARAM wParam,
> LPARAM lParam) MyWinProcDelegate;
>
> this() {
> MyWinProcDelegate =&Events;
> }
>
> extern (Windows) LRESULT Events (HWND hWnd, UINT message, WPARAM wParam,
> LPARAM lParam) {
> MessageBoxA(null , "Success!!!" , null ,0);
> return DefWindowProcA(hWnd, message, wParam, lParam);
> }
> ______________________________________________________________________
>
> The Events() doesn't seem to fire... am I missing something ?
ok next try : At least it compiles ..
import std.functional;
int main(string[] argv)
{
extern(Windows) int delegate() dg;
alias dg callback;
callback = toDelegate(&test);
return 0;
}
extern(Windows) int test() { return 42;}
hth, bjoern
More information about the Digitalmars-d-learn
mailing list