Window always look like active
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Window always look like active

Hybrid View

  1. #1
    Join Date
    Sep 2001
    Location
    Rotmanka, Poland
    Posts
    88

    Window always look like active

    Hi,

    I have my c# application, base on WPF window. I need one not typical action: if window is not active in a OS, border should still look like active.

    Any sugestions ?

    THNX in advance
    Olek

  2. #2
    Join Date
    Sep 2001
    Location
    Rotmanka, Poland
    Posts
    88

    Re: Window always look like active

    I found a answer. Maybe someone will look at same problem, so here it is:

    Set a hook for control a messages:

    HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
    source.AddHook(WndProc);


    Next support WM_NCACTIVE:

    [DllImport("user32.dll")]
    static extern IntPtr DefWindowProc(IntPtr hWnd, IntPtr uMsg, IntPtr wParam, IntPtr lParam);

    private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
    if (hwnd != this.Handle)
    return IntPtr.Zero;

    Message m=new Message();
    m.Msg=msg;
    m.WParam=wParam;
    m.LParam=lParam;


    if (m.Msg == 0x86) // Protected for draw not active - WM_NCACTIVATE
    {

    if ( (m.WParam.ToInt32() & 1) == 0)
    {
    IntPtr ans=DefWindowProc(hwnd, (IntPtr)m.Msg, (IntPtr)1, m.LParam);
    handled = true;
    return ans;
    }
    }

    return IntPtr.Zero;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center