wndproc

WM_NCLBUTTONUP message not sent at the end of dragging a form, how to do so?

天涯浪子 提交于 2019-12-01 18:07:11
问题 EDIT: tl;dr go to the first comment. This question stems from another question of mine Get MouseDown event when mouse goes down on Form border? In that question I needed to have a form fire an event when the user pushed the left mouse button down on the form border (preparing to drag), which works perfectly. The problem is when the user has finished this action, by letting go of the left mouse button, I would also like to have an event fired. To do so I produced this code to be placed in a

WPF: How do I make a custom modal dialog flash?

微笑、不失礼 提交于 2019-12-01 18:05:58
Normally when you open a Modal Dialog and try to click on it's parent window the Modal Dialog's titlebar flashes. When creating a custom, borderless, chromeless, window in WPF you lose all that functionality and must rebuild it yourself. I've looked high and low and for the life of me cannot figure out how to get my Modal window to flash. Though it still beeps... I figure I'm going to have to watch for some event(s) in WndProc that I'll have to handle, but I can't figure out which event or how to do it. I've tried watching the window changed and window changing event as well as the WM_ACTIVATE

Where to call base.WndProc() or base.DefWndProc()?

孤者浪人 提交于 2019-12-01 17:58:57
I have some questions regarding overriding the WndProc method of a Windows Form / NativeWindow. What exactly is the difference between WndProc and DefWndProc (edit: I thought it is called "DefaultWndProc" before)? I can only override WndProc, but what is DefWndProc for, which I can call anytime? And where to call base.WndProc in my overridden method? Or should I call DefWndProc instead? The following positions came into my mind: protected override void WndProc(ref Message m) { // 1st: I call the base handler at the start, in front of my handling. // Are there disadvantages here? base.WndProc

WPF: How do I make a custom modal dialog flash?

五迷三道 提交于 2019-12-01 17:56:09
问题 Normally when you open a Modal Dialog and try to click on it's parent window the Modal Dialog's titlebar flashes. When creating a custom, borderless, chromeless, window in WPF you lose all that functionality and must rebuild it yourself. I've looked high and low and for the life of me cannot figure out how to get my Modal window to flash. Though it still beeps... I figure I'm going to have to watch for some event(s) in WndProc that I'll have to handle, but I can't figure out which event or

C#: How to drag a from by the form and its controls?

岁酱吖の 提交于 2019-12-01 17:09:56
问题 I use the following code to drag a borderless form, by clicking and dragging the form itself. It works, but it doesn't for when you click and drag a control located on the form. I need to be able to drag it when clicked on some of the controls but not others - drag by labels, but don't by buttons and text boxes. How do I do it? protected override void WndProc(ref Message m) { base.WndProc(ref m); const int WM_NCHITTEST = 0x84; const int HTCLIENT = 0x1; const int HTCAPTION = 0x2; if (m.Msg ==

C#: How to drag a from by the form and its controls?

坚强是说给别人听的谎言 提交于 2019-12-01 17:04:33
I use the following code to drag a borderless form, by clicking and dragging the form itself. It works, but it doesn't for when you click and drag a control located on the form. I need to be able to drag it when clicked on some of the controls but not others - drag by labels, but don't by buttons and text boxes. How do I do it? protected override void WndProc(ref Message m) { base.WndProc(ref m); const int WM_NCHITTEST = 0x84; const int HTCLIENT = 0x1; const int HTCAPTION = 0x2; if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT) m.Result = (IntPtr)HTCAPTION; } Actually, I found the

What does the Result property of a windows message mean and when and how to use it?

那年仲夏 提交于 2019-12-01 13:23:11
问题 Result property meaning: Specifies the value that is returned to window in response to handling the message But MSDN does not says anymore: http://msdn.microsoft.com/en-us/library/system.windows.forms.message.result%28v=vs.110%29.aspx I will remark this quote words from the user @ Idle_Mind in this question Trying to write a better WndProc Handling: You can set the Result() property to change the way the message is handled. It is just like a winapi function return success value? Zero = true

Winforms - WM_NCHITEST message for click on control

妖精的绣舞 提交于 2019-12-01 10:46:08
I have a simple windows form with no border and several label controls (nothing that needs to be clicked). I needed to be able to allow the user to move the form by clicking anywhere on it, so I found this question, and used the following code found there. private const int WM_NCHITTEST = 0x84; private const int HTCLIENT = 0x1; private const int HTCAPTION = 0x2; protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_NCHITTEST: base.WndProc(ref m); if ((int)m.Result == HTCLIENT) { m.Result = (IntPtr)HTCAPTION; return; } else { return; } break; } base.WndProc(ref m); } This

Winforms - WM_NCHITEST message for click on control

放肆的年华 提交于 2019-12-01 08:25:25
问题 I have a simple windows form with no border and several label controls (nothing that needs to be clicked). I needed to be able to allow the user to move the form by clicking anywhere on it, so I found this question, and used the following code found there. private const int WM_NCHITTEST = 0x84; private const int HTCLIENT = 0x1; private const int HTCAPTION = 0x2; protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_NCHITTEST: base.WndProc(ref m); if ((int)m.Result ==

C# Form Move Stopped Event

强颜欢笑 提交于 2019-12-01 05:27:14
Is there any event in C# that fires when the form STOPS being moved. Not while its moving. If there is no event for it, is there a way of doing it with WndProc? The ResizeEnd event fires after a move ends. Perhaps you could use that. This is not a failsafe solution, but it's pure .NET and it's dead simple. Add a timer to your form, set it to a relatively short delay (100-150 ms seemed OK for me). Add the following code for the Form.LocationChanged and Timer.Tick events: private void Form_LocationChanged(object sender, EventArgs e) { if (this.Text != "Moving") { this.Text = "Moving"; }