-
October 26th, 2012, 03:47 AM
#1
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
-
October 26th, 2012, 06:14 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|