How I can pass the WndProc as a parameter?

Injeckt vinsentlou9 at gmail.com
Sat Sep 10 10:39:12 UTC 2022


I define this function:

     extern(Windows)
     static LRESULT WndProc(HWND hwnd, UINT message, WPARAM 
wParam, LPARAM lParam) nothrow {
         return 0;
     }

Then I define in another .d file:

     void KK_CreateWindowClass(WNDPROC WndProc) {
         WNDCLASSEX wndclass;
         wndclass.lpfnWndProc = WndProc;
     }

And after all, I call it:

     KK_CreateWindowClass(WndProc);


But I get these bugs:
server.d(29): Error: function `server.WndProc(void* hwnd, uint 
message, uint wParam, int lParam)` is not callable using argument 
types `()`
server.d(29): too few arguments, expected `4`, got `0`
server.d(29): Error: function `utils.KK_CreateWindowClass(extern 
(Windows) int function(void*, uint, uint, int) nothrow @system 
WndProc)` is not callable using argument types `(_error_)`
server.d(29): cannot pass argument `__error` of type `_error_` to 
parameter `extern (Windows) int function(void*, uint, uint, int) 
nothrow @system WndProc`




More information about the Digitalmars-d-learn mailing list