Click here to Skip to main content
13,043,154 members (62,359 online)

Windows Forms

 
AnswerRe: How to capture snap of any SDI windowForm including title bar Pin
Richard MacCutchan12-Mar-13 2:08
mvpRichard MacCutchan12-Mar-13 2:08 
GeneralRe: How to capture snap of any SDI windowForm including title bar Pin
Tridip Bhattacharjee13-Mar-13 8:29
memberTridip Bhattacharjee13-Mar-13 8:29 
GeneralRe: How to capture snap of any SDI windowForm including title bar Pin
Richard MacCutchan13-Mar-13 22:31
mvpRichard MacCutchan13-Mar-13 22:31 
QuestionHow to detect mouse over & out on win form title bar Pin
Tridip Bhattacharjee9-Mar-13 9:23
memberTridip Bhattacharjee9-Mar-13 9:23 
i want to detect mouse over on title bar or mouse out from title bar in my c# winform apps. i got a code sample which works but the problem is when i place the mouse on any area of win form then mouse leave occur and when i put mouse on title bar then right event call. actually i want that if i place my mouse on any area of form except title bar then nothing should happen.only when i will place mouse on title bar then a notification should come to me and when i will remove mouse from title to out of my form then label should display mouse out message but if remove mouse from title bar to form body then label should be blank.

here is code. just run this code and tell me what modification i should do to get my expected result. thanks
using System.Runtime.InteropServices;

public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

protected override void WndProc(ref Message m)
{
if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
{
TrackNcMouseLeave(this);
//ShowClientArea();
label1.Text = "mouse move on title bar";
}
else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
{
//HideClientAreaIfPointerIsOut();
label1.Text = "mouse leave from title bar";
}

base.WndProc(ref m);
}

protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
//HideClientAreaIfPointerIsOut();
}

private int previouseHeight;

private void ShowClientArea()
{
if (this.ClientSize.Height == 0)
this.ClientSize = new Size(this.ClientSize.Width, previouseHeight);
}

private void HideClientAreaIfPointerIsOut()
{
if (this.Bounds.Contains(Cursor.Position))
return;
previouseHeight = this.ClientSize.Height;
this.ClientSize = new Size(this.ClientSize.Width, 0);
}

public static void TrackNcMouseLeave(Control control)
{
TRACKMOUSEEVENT tme = new TRACKMOUSEEVENT();
tme.cbSize = (uint)Marshal.SizeOf(tme);
tme.dwFlags = 2 | 0x10; // TME_LEAVE | TME_NONCLIENT
tme.hwndTrack = control.Handle;
TrackMouseEvent(tme);
}

[DllImport("user32")]
public static extern bool TrackMouseEvent([In, Out] TRACKMOUSEEVENT lpEventTrack);

[StructLayout(LayoutKind.Sequential)]
public class TRACKMOUSEEVENT
{
public uint cbSize;
public uint dwFlags;
public IntPtr hwndTrack;
public uint dwHoverTime;
}
}
tbhattacharjee

QuestionWinforms Html Editor Pin
tarjeetsalh7-Mar-13 1:41
membertarjeetsalh7-Mar-13 1:41 
AnswerRe: Winforms Html Editor Pin
Dave Kreskowiak7-Mar-13 2:27
mvpDave Kreskowiak7-Mar-13 2:27 
GeneralRe: Winforms Html Editor Pin
tarjeetsalh10-Mar-13 21:28
membertarjeetsalh10-Mar-13 21:28 
GeneralRe: Winforms Html Editor Pin
Dave Kreskowiak11-Mar-13 5:41
mvpDave Kreskowiak11-Mar-13 5:41 
QuestionThread Leak Pin
michaelbarb25-Feb-13 5:12
membermichaelbarb25-Feb-13 5:12 
AnswerRe: Thread Leak Pin
Bernhard Hiller27-Feb-13 23:36
memberBernhard Hiller27-Feb-13 23:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 11 Jan 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid