c# - Get MouseDown event when mouse goes down on Form border? -


i cannot figure out how mousedown event when mouse down/clicked on border of form. easy see raised when mouse down in (i think called) client area of form, never raised when down on border.

here sscce demonstrates issue. label in center of form changed when mouse down on client area , not border.

is there anyway catch event or have raised?

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms;  namespace mouseeventtest {     public partial class form1 : form     {         random rand = new random();          public form1()         {             initializecomponent();         }          private void form1_mousedown(object sender, mouseeventargs e)         {             label1.text = rand.next().tostring();         }           /// <summary>         /// required designer variable.         /// </summary>         private system.componentmodel.icontainer components = null;          /// <summary>         /// clean resources being used.         /// </summary>         /// <param name="disposing">true if managed resources should disposed; otherwise, false.</param>         protected override void dispose(bool disposing)         {             if (disposing && (components != null))             {                 components.dispose();             }             base.dispose(disposing);         }          #region windows form designer generated code          /// <summary>         /// required method designer support - not modify         /// contents of method code editor.         /// </summary>         private void initializecomponent()         {             this.label1 = new system.windows.forms.label();             this.suspendlayout();             //              // label1             //              this.label1.autosize = true;             this.label1.location = new system.drawing.point(42, 30);             this.label1.name = "label1";             this.label1.size = new system.drawing.size(91, 13);             this.label1.tabindex = 0;             this.label1.text = "99999999999999";             //              // form1             //              this.autoscaledimensions = new system.drawing.sizef(6f, 13f);             this.autoscalemode = system.windows.forms.autoscalemode.font;             this.clientsize = new system.drawing.size(185, 75);             this.controls.add(this.label1);             this.name = "form1";             this.text = "form1";             this.mousedown += new system.windows.forms.mouseeventhandler(this.form1_mousedown);             this.resumelayout(false);             this.performlayout();          }          #endregion          private system.windows.forms.label label1;     } } 

edit: have solved problem, created another. if visting question in future here related question asked. (hopefully) me/us figure out when mouse has been released too. wm_nclbuttonup message not sent @ end of dragging form, how so?

override wndproc method:

const int wm_nclbuttondwn = 0xa1;  protected override void wndproc(ref message m) {     if (m.msg == wm_nclbuttondwn)     {         this.text = "got it!";     }      base.wndproc(ref m); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -