private void WmActivate(IntPtr wParam, IntPtr lParam)
 {
     if (!(_ownerForActivate != IntPtr.Zero))
     {
         return;
     }
     NativeMethods.SendMessage(_ownerForActivate, NativeMethods.Notifyowneractivate, wParam, lParam);
 }
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
            case 126:
                if (IsVisible)
                {
                    RenderLayeredWindow();
                }
                break;

            case 33:
                handled = true;
                return(new IntPtr(3));

            case 132:
                Cursor = GetCursor(lParam) ?? Cursors.None;
                break;

            case 161:
            case 163:
            case 164:
            case 166:
            case 167:
            case 169:
            case 171:
            case 173:
                var targetWindowHandle = TargetWindowHandle;
                NativeMethods.SendMessage(targetWindowHandle, 6, new IntPtr(2), IntPtr.Zero);
                NativeMethods.SendMessage(targetWindowHandle, msg, wParam, IntPtr.Zero);
                break;

            case 6:
                return(IntPtr.Zero);

            case 70:
                var windowPos = (Windowpos)Marshal.PtrToStructure(lParam, typeof(Windowpos));
                windowPos.flags |= 16U;
                Marshal.StructureToPtr(windowPos, lParam, true);
                break;

            case 513:
                if (!IsHitTestVisible)
                {
                    break;
                }
                var pt = new Point((int)lParam & 0xFFFF, ((int)lParam >> 16) & 0xFFFF);
                NativeMethods.PostMessage(TargetWindowHandle,
                                          161, (IntPtr)DecideResizeDirection(pt),
                                          IntPtr.Zero);
                break;
            }
            return(NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam));
        }
        private static void RaiseNonClientMouseMessageAsClient(IntPtr hwnd, int msg, IntPtr lparam)
        {
            var point = new Core.Platform.Point
            {
                X = NativeMethods.GetXlParam(lparam.ToInt32()),
                Y = NativeMethods.GetYlParam(lparam.ToInt32())
            };

            NativeMethods.ScreenToClient(hwnd, ref point);
            NativeMethods.SendMessage(hwnd, msg + 513 - 161, new IntPtr(PressedMouseButtons),
                                      NativeMethods.MakeParam(point.X, point.Y));
        }