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