winforms - How to return a value in WndProc for C#? -


in application, hid cursor using setcursor(null) , make sure windows not reset cursor state, handled wm_setcursor in wndproc method.

however in msdn documentation c++, in order handle wm_setcursor have return true. in c#'s wndproc, void method cannot return value.

so how accomplish return statement in c#?

c++ variant:

static lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, {             case wm_setcursor:         if (loword(lparam) == htclient)         {             setcursor(hcursor);             return true;         }         break; } 

you can return without calling base.wndproc:

protected override void wndproc(ref message m){     if(m.msg == wm_setcursor) {         int lowword = (m.lparam.toint32() << 16) >> 16;         if(lowword == htclient){           setcursor(hcursor);           return;         }     }     base.wndproc(ref m); } 

i guess works (i've experienced messages not sure wm_setcursor):

protected override void wndproc(ref message m){          base.wndproc(ref m);     if(m.msg == wm_setcursor) {         int lowword = (m.lparam.toint32() << 16) >> 16;         if(lowword == htclient){           setcursor(hcursor);           m.result = new intptr(1);         }                } } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -