c# - TaskBarButton middle mouse button event -
i have taskbar buttons. @ taskbar there lot of events, there 1 event @ click of button.
taskbar.buttonclick += new system.windows.forms.toolbarbuttonclickeventhandler(this.taskbarbuttonclick);
i need event button press taskbar middle mouse button.
something
if (e.button == mousebuttons.middle) { messagebox.show("middle"); }
only taskbar
i know example. did that. problem event taskbar. need event button provided on taskbar
e.button not of type mousebuttons
. of type toolbarbutton
. references location on toolbar clicked, not location on mouse used make click.
toolbar button
if need handle toolbar button clicked reference this example using toolbarbuttonclickeventhandler
works.
//add buttons. taskbar.buttons.add(new toolbarbutton()); //index 0 taskbar.buttons.add(new toolbarbutton()); //index 1 //add handler taskbar.buttonclick += new toolbarbuttonclickeventhandler ( this.taskbar_buttonclick); private void taskbar_buttonclick (object sender, toolbarbuttonclickeventargs e) { // evaluate button property determine button clicked. switch(taskbar.buttons.indexof(e.button)) { case 0: //whatever want when 1st toolbar button clicked break; case 1: //whatever want when 2nd toolbar button clicked break; } }
mouse button
you add event handler mousedown
event trap mouse button clicked.
taskbar.mousedown += new mouseeventhandler(this.taskbar_mousedown); private void taskbar_mousedown(object sender, mouseeventargs e) { // determine mouse button clicked. if(e.button == mousebuttons.middle) { messagebox.show("middle"); } }
Comments
Post a Comment