문제

i got some trick to capture mouse touch title bar but the routine fire repeatedly when i place mouse on title bar. here is the routine

protected override void WndProc(ref Message m)
{
            if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
            {
        listBox1.Items.Add("mouse move on title bar");
            }
            else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
            {
        listBox1.Items.Add("mouse leave from title bar");            
            }

            base.WndProc(ref m);
}

can any one tell me any trick as a result WndProc fire only once when mouse touch the title bar instead of repeatedly firing. thanks

도움이 되었습니까?

해결책

Are you looking for this?I am controlling addition of items to listbox using flag.

private bool insideTitleBar = false;
private bool outsideTitleBar = false;

protected override void WndProc(ref Message m)
{
    if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
    {        
           if(!insideTitleBar)
           {
            listBox1.Items.Add("mouse move on title bar");
            insideTitleBar = true;
            outsideTitleBar = false;
           }
    } 
    else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
    {
           if(!outsideTitleBar)
           {      
            listBox1.Items.Add("mouse leave from title bar");            
            outsideTitleBar = true;
            insideTitleBar = false;
           }
    }
    base.WndProc(ref m);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top