Пример #1
0
 public void NativeWindow_WndProc_InvokeWithInvalidAssignedHandle_Nop(int msg)
 {
     using (new NoAssertContext())
     {
         var window = new SubNativeWindow();
         window.AssignHandle((IntPtr)250);
         var m = new Message
         {
             Msg    = msg,
             Result = (IntPtr)1
         };
         window.WndProc(ref m);
         Assert.Equal(IntPtr.Zero, m.Result);
         Assert.Equal((IntPtr)250, window.Handle);
     }
 }
Пример #2
0
        public void NativeWindow_WndProc_InvokeWithValidAssignedHandle_Success(int msg)
        {
            using var control = new Control();
            var window = new SubNativeWindow();

            window.AssignHandle(control.Handle);

            try
            {
                var m = new Message
                {
                    Msg    = msg,
                    Result = (IntPtr)1
                };
                window.WndProc(ref m);
                Assert.Equal(IntPtr.Zero, m.Result);
                Assert.Equal(control.Handle, window.Handle);
            }
            finally
            {
                window.ReleaseHandle();
            }
        }