Ejemplo n.º 1
0
// Move window the topmost in z-order
        static public bool SetWindowZOrder(IntPtr hWnd, IntPtr hWndInsertAfter)
        {
            if (hWnd == IntPtr.Zero)
            {
                return(false);
            }
            bool bSuccess = IMCWin32API.SetWindowPos(
                hWnd,
                hWndInsertAfter,
                0,
                0,
                0,
                0,
                IMCWin32API.SWP_NOMOVE | IMCWin32API.SWP_NOSIZE
                );

            return(true);
        }
Ejemplo n.º 2
0
        // Centralize the window
        static public bool SetWindowPosAndSize(IntPtr hWnd, out bool bNeedHScroll, out bool bNeedVScroll)
        {
            bNeedHScroll = false;
            bNeedVScroll = false;
            if (hWnd == IntPtr.Zero)
            {
                return(false);
            }

            // Get window resolution
            int nResolutionX = IMCWin32API.GetSystemMetrics(IMCWin32API.SM_CXSCREEN);
            int nResolutionY = IMCWin32API.GetSystemMetrics(IMCWin32API.SM_CYSCREEN);
            // Get window size
            int nWndX;
            int nWndY;

            if (!GetWindowSize(hWnd, out nWndX, out nWndY))
            {
                return(false);
            }
            bNeedHScroll = ((nWndX > nResolutionX) ? true : false);
            bNeedVScroll = ((nWndY > nResolutionY) ? true : false);

            // Get the start position
            int nStartX = (bNeedHScroll ? 0 : (nResolutionX - nWndX) >> 1);
            int nStartY = (bNeedVScroll ? 0 : (nResolutionY - nWndY) >> 1);

            // Set window position
            IMCWin32API.SetWindowPos(
                hWnd,
                IntPtr.Zero,
                nStartX,
                nStartY,
                (bNeedHScroll ? nResolutionX : nWndX),
                (bNeedVScroll ? nResolutionY : nWndY),
                /*IMCWin32API.SWP_NOSIZE | */ IMCWin32API.SWP_NOZORDER
                );
            return(true);
        }