Esempio n. 1
0
LRESULT COleIPFrameWnd::OnResizeChild(WPARAM, LPARAM lParam)
{
	// notify the container that the rectangle has changed!
	COleServerDoc* pDoc = (COleServerDoc*)GetActiveDocument();
	if (pDoc == NULL)
		return 0;

	ASSERT_KINDOF(COleServerDoc, pDoc);

	// get new rect and parent
	CRect rectNew;
	rectNew.CopyRect((LPCRECT)lParam);
	CWnd* pParentWnd = GetParent();
	ASSERT_VALID(pParentWnd);

	// convert rectNew relative to pParentWnd
	ClientToScreen(&rectNew);
	pParentWnd->ScreenToClient(&rectNew);

	// adjust the new rectangle for the current control bars
	CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST);
	ASSERT(pLeftOver != NULL);
	CRect rectCur = m_rectPos;
	pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside);
	rectNew.left += m_rectPos.left - rectCur.left;
	rectNew.top += m_rectPos.top - rectCur.top;
	rectNew.right -= rectCur.right - m_rectPos.right;
	rectNew.bottom -= rectCur.bottom - m_rectPos.bottom;
	OnRequestPositionChange(rectNew);

	return 0;
}
//*****************************************************************************
void CBCGPFrameWnd::AdjustClientArea ()
{
    CWnd* pChildWnd = GetDlgItem (AFX_IDW_PANE_FIRST);
    if (pChildWnd != NULL)
    {
        CRect rectClientAreaBounds = m_dockManager.GetClientAreaBounds ();

        rectClientAreaBounds.left += m_rectBorder.left;
        rectClientAreaBounds.top  += m_rectBorder.top;
        rectClientAreaBounds.right -= m_rectBorder.right;
        rectClientAreaBounds.bottom -= m_rectBorder.bottom;

        pChildWnd->CalcWindowRect (rectClientAreaBounds);

        if (!pChildWnd->IsKindOf (RUNTIME_CLASS (CSplitterWnd)) &&
                !pChildWnd->IsKindOf (RUNTIME_CLASS (CFormView)))
        {
            pChildWnd->ModifyStyle (0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
        }
        else
        {
            pChildWnd->ModifyStyle (0, WS_CLIPSIBLINGS);
        }


        pChildWnd->SetWindowPos (&wndBottom, rectClientAreaBounds.left,
                                 rectClientAreaBounds.top,
                                 rectClientAreaBounds.Width (),
                                 rectClientAreaBounds.Height (),
                                 SWP_NOACTIVATE);
    }
}
Esempio n. 3
0
void COleIPFrameWnd::RecalcLayout(BOOL /*bNotify*/)
{
	ASSERT_VALID(this);

	// better have a parent window (only used for inplace)
	CWnd* pParentWnd = GetParent();
	ASSERT_VALID(pParentWnd);

	// first call reposition bars with arbitarily large rect just to
	//  see how much space the bars will take up
	CRect rectBig(0, 0, INT_MAX/2, INT_MAX/2);
	CRect rectLeft;
	RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery,
		&rectLeft, &rectBig);

	// grow the rect by the size of the control bars
	CRect rect = m_rectPos;
	rect.left -= rectLeft.left;
	rect.top -= rectLeft.top;
	rect.right += INT_MAX/2 - rectLeft.right;
	rect.bottom += INT_MAX/2 - rectLeft.bottom;

	// see how much extra space for non-client areas (such as scrollbars)
	//  that the view needs.
	CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST);
	if (pLeftOver != NULL)
	{
		rectBig = m_rectPos;
		pLeftOver->CalcWindowRect(&rectBig, CWnd::adjustOutside);
		rect.left -= m_rectPos.left - rectBig.left;
		rect.top -= m_rectPos.top - rectBig.top;
		rect.right += rectBig.right - m_rectPos.right;
		rect.bottom += rectBig.bottom - m_rectPos.bottom;
	}

	// adjust for non-client area on the frame window
	CalcWindowRect(&rect, CWnd::adjustOutside);

	// the frame window must be clipped to the visible part in the container
	CRect rectVis;
	rectVis.IntersectRect(&rect, &m_rectClip);

	// move the window
	AfxRepositionWindow(NULL, m_hWnd, &rectVis);

	// now resize the control bars relative to the (now moved) frame
	pParentWnd->ClientToScreen(&rect);
	ScreenToClient(&rect);
	RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST,
		CWnd::reposDefault, NULL, &rect);
}
Esempio n. 4
0
// </snippet1>
LRESULT CInPlaceFrame::OnResizeChild(WPARAM /*wParam*/, LPARAM lParam)
{
	// notify the container that the rectangle has changed!
	CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument();
	if (pDoc == NULL)
		return 0;

	ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CWordPadDoc)));

	// get new rect and parent
	CRect rectNew;
	rectNew.CopyRect((LPCRECT)lParam);
	CWnd* pParentWnd = GetParent();
	ASSERT_VALID(pParentWnd);

	// convert rectNew relative to pParentWnd
	ClientToScreen(&rectNew);
	pParentWnd->ScreenToClient(&rectNew);

	if (m_wndRulerBar.GetStyle()&WS_VISIBLE)
	{
		CRect rect;
		m_wndRulerBar.GetWindowRect(&rect);
		rectNew.top += rect.Height();
	}
	rectNew.left += HORZ_TEXTOFFSET;
	rectNew.top += VERT_TEXTOFFSET;

	// adjust the new rectangle for the current control bars
	CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST);
	ASSERT(pLeftOver != NULL);
	CRect rectCur = m_rectPos;
	pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside);
	rectNew.left += m_rectPos.left - rectCur.left;
	rectNew.top += m_rectPos.top - rectCur.top;
	rectNew.right -= rectCur.right - m_rectPos.right;
	rectNew.bottom -= rectCur.bottom - m_rectPos.bottom;
	OnRequestPositionChange(rectNew);

	return 0;
}
Esempio n. 5
0
// Create window for runtime
bool CRuntime::MakeWindows(CRuntimeSetup* crSetup)
{
	hWnds.resize(0);

    WNDCLASSEX wc;

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;

    wc.lpfnWndProc = CRuntime_WindowProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = sizeof(long);
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(hInstance, "MAINICON");
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = NULL;
    wc.lpszMenuName = NULL;

	if (crSetup->screensaver)
		wc.lpszClassName = "WindowsScreenSaverClass"; 
	else
	    wc.lpszClassName = "ConstructRt";

    wc.hIconSm = (HICON)LoadImage(hInstance, "MAINICON", IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); 

    //Register class
    if(!RegisterClassEx(&wc))
        return false;

	DWORD style = WS_CLIPCHILDREN;
	DWORD exStyle = NULL;

	if (minimize_box)						style |= WS_MINIMIZEBOX;
	if (maximize_box)						style |= WS_MAXIMIZEBOX;
	if (resizable != resize_disabled)		style |= WS_THICKFRAME;

#ifdef CONSTRUCT_DIRECTX9
	// Fullscreen apps have to be popup to display correctly (no caption etc)
	if (fullscreen || !caption)
		style |= WS_POPUP;
	else
		style |= WS_OVERLAPPED | WS_SYSMENU;

	int windowCount = renderer.GetMultiHeadCount();

#else
	style |= WS_OVERLAPPED | WS_SYSMENU;

	int windowCount = 1;
	bool fullscreen = false;
#endif

    // Create windows
	for (int i = 0; i < windowCount; i++) {

		HWND curHwnd;
		HWND hWndParent = NULL;
		if (i > 0) hWndParent = hWnds.front();

		if (crSetup->screensaver) {
			curHwnd = CreateWindowEx (exStyle, "WindowsScreenSaverClass", "",
								style, CW_USEDEFAULT, CW_USEDEFAULT, crSetup->winWidth, crSetup->winHeight,
								hWndParent, NULL, hInstance, this);

			SetWindowLong(curHwnd, GWL_USERDATA, (long)this);
			hWnds.push_back(curHwnd);
		}
		else {
			curHwnd = CreateWindowEx (exStyle, "ConstructRt", "",
								style, CW_USEDEFAULT, CW_USEDEFAULT, crSetup->winWidth, crSetup->winHeight,
								hWndParent, NULL, hInstance, this);

			SetWindowLong(curHwnd, GWL_USERDATA, (long)this);
			hWnds.push_back(curHwnd);

		}
	}

#ifdef CONSTRUCT_DEBUGGER
//	m_Debugger.DoModal();
//	m_Debugger.ShowWindow(SW_SHOW);
#endif

	// Set the main window client area to the desired size and center it
	if (!fullscreen) {
		expectedResize = true;	// Stop device reset, SetWindowPos() calls WM_SIZE

		CWnd w;
		w.Attach(hWnds.front());
		CRect clientRec;
		clientRec.SetRect(0, 0, crSetup->winWidth, crSetup->winHeight);
		w.CalcWindowRect(&clientRec);
		w.SetWindowPos(NULL, 0, 0, clientRec.Width(), clientRec.Height(), SWP_NOMOVE | SWP_NOZORDER);

		// Now centre the window
		DEVMODE DevMode;
		EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &DevMode);
		int windowX = (DevMode.dmPelsWidth / 2) - (clientRec.Width() / 2);
		int windowY = (DevMode.dmPelsHeight / 2) - (clientRec.Height() / 2);
		w.SetWindowPos(NULL, windowX, windowY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

		w.Detach();

		expectedResize = false;
	}

    //Success
    return true;
}
Esempio n. 6
0
void gkToolBarPaneBase::RepositionBarsInternal(UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver,
													UINT nFlags, LPRECT lpRectParam, LPCRECT lpRectClient, BOOL bStretch)
{
	ASSERT(nFlags == 0 || (nFlags & ~reposNoPosLeftOver) == reposQuery || 
		(nFlags & ~reposNoPosLeftOver) == reposExtra);

	// walk kids in order, control bars get the resize notification
	//   which allow them to shrink the client area
	// remaining size goes to the 'nIDLeftOver' pane
	// NOTE: nIDFirst->nIDLast are usually 0->0xffff

	AFX_SIZEPARENTPARAMS layout;
	HWND hWndLeftOver = NULL;

	layout.bStretch = bStretch;
	layout.sizeTotal.cx = layout.sizeTotal.cy = 0;
	if (lpRectClient != NULL)
		layout.rect = *lpRectClient;    // starting rect comes from parameter
	else
		GetClientRect(&layout.rect);    // starting rect comes from client rect

	if ((nFlags & ~reposNoPosLeftOver) != reposQuery)
		layout.hDWP = ::BeginDeferWindowPos(8); // reasonable guess
	else
		layout.hDWP = NULL; // not actually doing layout

	for (HWND hWndChild = ::GetTopWindow(m_hWnd); hWndChild != NULL;
		hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT))
	{
		UINT_PTR nIDC = ((UINT)(WORD)::GetDlgCtrlID(hWndChild));
		CWnd* pWnd = CWnd::FromHandlePermanent(hWndChild);
		if (nIDC == nIDLeftOver)
			hWndLeftOver = hWndChild;
		else if (nIDC >= nIDFirst && nIDC <= nIDLast && pWnd != NULL)
			::SendMessage(hWndChild, WM_SIZEPARENT, 0, (LPARAM)&layout);
	}

	// if just getting the available rectangle, return it now...
	if ((nFlags & ~reposNoPosLeftOver) == reposQuery)
	{
		ASSERT(lpRectParam != NULL);
		if (bStretch)
			::CopyRect(lpRectParam, &layout.rect);
		else
		{
			lpRectParam->left = lpRectParam->top = 0;
			lpRectParam->right = layout.sizeTotal.cx;
			lpRectParam->bottom = layout.sizeTotal.cy;
		}
		return;
	}

	// the rest is the client size of the left-over pane
	if (nIDLeftOver != 0 && hWndLeftOver != NULL)
	{
		CWnd* pLeftOver = CWnd::FromHandle(hWndLeftOver);
		// allow extra space as specified by lpRectBorder
		if ((nFlags & ~reposNoPosLeftOver) == reposExtra)
		{
			ASSERT(lpRectParam != NULL);
			layout.rect.left += lpRectParam->left;
			layout.rect.top += lpRectParam->top;
			layout.rect.right -= lpRectParam->right;
			layout.rect.bottom -= lpRectParam->bottom;
		}
		// reposition the window
		if ((nFlags & reposNoPosLeftOver) != reposNoPosLeftOver)
		{
			pLeftOver->CalcWindowRect(&layout.rect);
			RepositionWindowInternal(&layout, hWndLeftOver, &layout.rect);
		}
	}

	// move and resize all the windows at once!
	if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP))
		TRACE(traceAppMsg, 0, "Warning: DeferWindowPos failed - low system resources.\n");
}