c# - Custom control - can't receive focus or mouse events -


i have created winforms custom control, , while can receive mousewheel messages fine, none of mousedown, mousemove, or mouseup messages received.

i have set following controlstyles:

setstyle(controlstyles.userpaint | controlstyles.optimizeddoublebuffer | controlstyles.allpaintinginwmpaint, true); 

(i have tried setting controlstyles.selectable , controlstyles.usermouse, makes no difference)

i have put code in gotfocus , lostfocus events, , can see in circumstances control focus, lose again immediately.

this gis map viewer / editor control, , must able receive focus, both can receive mouse events, can use hotkeys perform various actions.

any ideas?

[edit: here's code demonstrates this. question guess identical setting focus .net usercontrol...?, wasn't answered satisfactorily. ]

public partial class customcontrol1 : control {     public customcontrol1()     {         setstyle(controlstyles.userpaint | controlstyles.optimizeddoublebuffer | controlstyles.allpaintinginwmpaint | controlstyles.selectable | controlstyles.usermouse, true);         mousewheel += customcontrol1_mousewheel;         mousedown += customcontrol1_mousedown;         mousemove += customcontrol1_mousemove;         mouseup += customcontrol1_mouseup;     }      void customcontrol1_mouseup(object sender, mouseeventargs e)     {         debug.write("mouseup"); // never gets fired     }      void customcontrol1_mousemove(object sender, mouseeventargs e)     {         debug.write("mousemove"); // never gets fired     }      void customcontrol1_mousedown(object sender, mouseeventargs e)     {         debug.write("mousedown"); // never gets fired     }      void customcontrol1_mousewheel(object sender, mouseeventargs e)     {         debug.write("mousewheel"); // works fine!     }      protected override void onpaint(painteventargs pe)     {         // drawing stuff here     } } 


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -