Ejemplo n.º 1
0
 public static extern bool PhysicalToLogicalPoint(NativeMethods.HWND hwnd, ref NativeMethods.POINT pt);
Ejemplo n.º 2
0
 public static extern int GetWindowThreadProcessId(NativeMethods.HWND hWnd, out int lpdwProcessId);
Ejemplo n.º 3
0
 public static extern bool GetWindowPlacement(NativeMethods.HWND hwnd, ref WINDOWPLACEMENT wp);
Ejemplo n.º 4
0
 public static extern int GetWindowLong(NativeMethods.HWND hWnd, int nIndex);
Ejemplo n.º 5
0
 public static extern IntPtr SendMessageTimeout(
     NativeMethods.HWND hwnd, int Msg, IntPtr wParam, StringBuilder lParam, int flags, int uTimeout, out IntPtr pResult);
Ejemplo n.º 6
0
 public static extern bool PeekMessage(
     ref MSG msg, NativeMethods.HWND hwnd, int nMsgFilterMin, int nMsgFilterMax, int wRemoveMsg);
Ejemplo n.º 7
0
 public static extern bool IsWindowVisible(NativeMethods.HWND hwnd);
Ejemplo n.º 8
0
 public static extern void SwitchToThisWindow(NativeMethods.HWND hwnd, bool fAltTab);
Ejemplo n.º 9
0
 public static extern bool GetWindowRect(NativeMethods.HWND hwnd, out NativeMethods.RECT rc);
Ejemplo n.º 10
0
 public static extern bool IsWindowEnabled(NativeMethods.HWND hwnd);
Ejemplo n.º 11
0
 public static extern bool GetClientRect(NativeMethods.HWND hwnd, out NativeMethods.RECT rc);
Ejemplo n.º 12
0
 public static extern NativeMethods.HWND GetAncestor(NativeMethods.HWND hwnd, int gaFlags);
Ejemplo n.º 13
0
 public static extern IntPtr SendMessage(NativeMethods.HWND hWnd, int nMsg, IntPtr wParam, StringBuilder lParam);
Ejemplo n.º 14
0
 public static extern bool RegisterHotKey(NativeMethods.HWND hWnd, int id, int fsModifiers, int vk);
Ejemplo n.º 15
0
 public static extern bool IsIconic(NativeMethods.HWND hwnd);
Ejemplo n.º 16
0
 public static extern bool UnregisterHotKey(NativeMethods.HWND hWnd, int id);
Ejemplo n.º 17
0
 public static extern int GetClassName(NativeMethods.HWND hWnd, StringBuilder classname, int nMax);
Ejemplo n.º 18
0
 public static extern IntPtr SendMessageTimeout(
     NativeMethods.HWND hwnd, int Msg, IntPtr wParam, ref MINMAXINFO lParam, int flags, int uTimeout, out IntPtr pResult);
Ejemplo n.º 19
0
 public static extern int RealGetWindowClass(NativeMethods.HWND hWnd, StringBuilder classname, int nMax);
Ejemplo n.º 20
0
 public static extern int GetMessage(
     ref MSG msg, NativeMethods.HWND hwnd, int nMsgFilterMin, int nMsgFilterMax);
Ejemplo n.º 21
0
 internal extern static bool IsChild(NativeMethods.HWND parent, NativeMethods.HWND child);
Ejemplo n.º 22
0
 public static extern bool PostMessage(
     NativeMethods.HWND hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
Ejemplo n.º 23
0
 internal static extern int DwmGetWindowAttribute(
     NativeMethods.HWND hwnd,
     int dwAttributeToGet, //DWMWA_* values
     ref int pvAttributeValue,
     int cbAttribute);
Ejemplo n.º 24
0
 internal static extern bool SetWindowPos(NativeMethods.HWND hWnd, NativeMethods.HWND hWndInsertAfter, int x, int y, int cx, int cy, int flags);
Ejemplo n.º 25
0
        public HwndTarget(IntPtr hwnd)
        {
            bool exceptionThrown = true;

            AttachToHwnd(hwnd);

            try
            {
                if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info))
                {
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientCreateVisual, EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info, Dispatcher.GetHashCode(), hwnd.ToInt64());
                }

                _hWnd = NativeMethods.HWND.Cast(hwnd);

                // Get the client rectangle...
                GetWindowRectsInScreenCoordinates();

                // Set device independent resolution to 96 DPI.
                // NativeMethods.HDC hdc = NativeMethods.GetDC(_hWnd);

                _devicePixelsPerInchX = 96.0f;
                _devicePixelsPerInchY = 96.0f;

                _lastWakeOrUnlockEvent = DateTime.MinValue;

                //
                // Determine whether hWnd corresponds to MIL or GDI window.
                //
                IntPtr hdcW = UnsafeNativeMethods.GetDC(
                    new HandleRef(this, _hWnd));

                if (hdcW == IntPtr.Zero)
                {
                    //
                    // If we were unable to obtain HDC for the given
                    // window, assume the default of 96 DPI.
                    //

                    _devicePixelsPerInchX = 96.0f;
                    _devicePixelsPerInchY = 96.0f;
                }
                else
                {
                    //
                    // Obtain and cache DPI values for window's HDC.
                    //

                    _devicePixelsPerInchX = (double)UnsafeNativeMethods.GetDeviceCaps(
                        new HandleRef(this, hdcW),
                        NativeMethods.LOGPIXELSX);

                    _devicePixelsPerInchY = (double)UnsafeNativeMethods.GetDeviceCaps(
                        new HandleRef(this, hdcW),
                        NativeMethods.LOGPIXELSY);

                    //
                    // Release DC object.
                    //

                    UnsafeNativeMethods.ReleaseDC(
                        new HandleRef(this, _hWnd),
                        new HandleRef(this, hdcW));
                }

                _worldTransform = new MatrixTransform(new Matrix(
                  _devicePixelsPerInchX * (1.0f / 96.0f), 0,
                  0, _devicePixelsPerInchY * (1.0f / 96.0f),
                  0, 0));

                //
                // Register CompositionTarget with MediaContext.
                //
                MediaContext.RegisterICompositionTarget(Dispatcher, this);

                // Initialize dispatcher timer to work-around a restore issue.
                _restoreDT = new DispatcherTimer();
                _restoreDT.Tick += new EventHandler(InvalidateSelf);
                _restoreDT.Interval = TimeSpan.FromMilliseconds(100);

                exceptionThrown = false;
            }
            finally
            {
                //
                // If exception has occurred after we attached this target to
                // the window, we need to detach from this window. Otherwise, window
                // will be left in a state when no other HwndTarget can be created
                // for it.
                //
                if(exceptionThrown)
                {
                    #pragma warning suppress 6031 // Return value ignored on purpose.
                    VisualTarget_DetachFromHwnd(hwnd);
                }
            }
        }