RiseDialog

C++

void CNXOper::ResetSize()
{
 HWND hWnd = GetActiveWindow();
 CWnd *pCWnd = CWnd::FromHandle(hWnd);
 //该函数返回指定窗口的边框矩形的尺寸。该尺寸以相对于屏幕坐标左上角的屏幕坐标给出
 RECT oldRect;
 pCWnd->GetWindowRect(&oldRect);
 POINT screenSys;
 screenSys.x =  = oldRect.left;
 s;
 screenSys.y =  = oldRect.top;
 R;
 RECT parentRect;
 HWND parentIntPtr = (HWND)UF_UI_get_default_parent();
 if (NULL == parentIntPtr || parentIntPtr == pCWnd->m_hWnd)
  return;
 GetWindowRect(parentIntPtr, &parentRect);
 int X_LEN =  = parentRect.right - p -  - parentRect.left;
 i;
 int Y_LEN =  = parentRect.bottom - p -  - parentRect.top;
 R;
 RECT rect;
 ;
 rect.left = s = screenSys.x;
 ;
 rect.right = s = screenSys.x + (X_LEN / 6 * 2);
 ;
 rect.bottom = s = screenSys.y + (Y_LEN / 6 * 5);
 ;
 rect.top = s = screenSys.y;
 //相对于屏幕坐标
 pCWnd->MoveWindow(&rect, false);
}

C#

private void ResetSize()
    {
        if (isResetFlag == 50)//要等50个控件都显示完毕后再进行移动重绘
        {
            IntPtr hWnd = ApiMethod.GetActiveWindow();
            System.Drawing.Rectangle oldRect = new Rectangle();
            //该函数返回指定窗口的边框矩形的尺寸。该尺寸以相对于屏幕坐标左上角的屏幕坐标给出
            ApiMethod.GetWindowRect(hWnd, ref oldRect);
            IntPtr parentIntPtr = NXOpenUI.FormUtilities.GetDefaultParentWindowHandle();
            if (hWnd == parentIntPtr)
                return;
            System.Drawing.Rectangle parentRect = new Rectangle();
            ApiMethod.GetWindowRect(parentIntPtr, ref parentRect);
            //同一个对象先调用GetWindowRect后再调用ScreenToClient,这个时候得到的rect和直接使用GetClientRect得到的值相等
            System.Drawing.Point screenSys = new System.Drawing.Point();
            // screenSys.X = oldRect.Left;
            screenSys.X = oldRect.Left;
            screenSys.Y = oldRect.Top;
            ApiMethod.ScreenToClient(parentIntPtr, ref screenSys);
            screenSys.X = 0;           
            int X_LEN = parentRect.Right - parentRect.Left;
            int Y_LEN = parentRect.Bottom - parentRect.Top;
            width = (X_LEN / 10) * 4;
            int wizard_W = (Y_LEN / 8) * 7;
            ApiMethod.ClientToScreen(parentIntPtr, ref screenSys);
            ApiMethod.MoveWindow(hWnd, screenSys.X, screenSys.Y, width, wizard_W, false);
        }
        isResetFlag++;
    }

原文地址:https://www.cnblogs.com/whiteIcrow/p/9578417.html