예를들어 가상키보드를 구현할 때 가상키보드에 포커스가 옮겨지면 안됩니다.

 

Win32의 SetWindowLong 함수를 사용하시면 포커스가 이동되지 않는 Window를 생성하실 수 있습니다.

 

 

 

private const int GWL_EXSTYLE = -20;

        private const int WS_EX_NOACTIVATE = 0x08000000;

 

        [DllImport("user32.dll")]

        public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

 

        [DllImport("user32.dll")]

        public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

 

        protected override void OnSourceInitialized(EventArgs e)

        {

            base.OnSourceInitialized(e);

 

            WindowInteropHelper helper = new WindowInteropHelper(this);

            IntPtr ip = SetWindowLong(helper.Handle, GWL_EXSTYLE,

                GetWindowLong(helper.Handle, GWL_EXSTYLE) | WS_EX_NOACTIVATE);

        } 

 

 

 

 

 

 

'.Net > WPF' 카테고리의 다른 글

WPF Xaml에서 특수문자 사용  (0) 2013.07.11
WPF 기존 Style에 Style 추가  (0) 2013.07.11
WPF WndProc  (0) 2013.07.10
Binding.UpdateSourceTrigger  (0) 2013.07.09
[MVVM Galasoft.MvvmLight.WPF4] EventToCommand, 이벤트 정보를 넘기자!  (0) 2013.07.05

+ Recent posts