bool cdxCDynamicControlsManager::StoreWindowPosition(CWnd & rWnd, LPCTSTR lpszProfile)
{
	ASSERT(::IsWindow(rWnd.m_hWnd) && lpszProfile && *lpszProfile);
	// can't use an empty profile section string; see CWinApp::GetProfileInt() for further information

	WINDOWPLACEMENT	wpl;
	VERIFY( rWnd.GetWindowPlacement(&wpl) );
	BOOL	bVisible	=	rWnd.IsWindowVisible();
	int	iState	=	REGVAL_NOSTATE;

	if(rWnd.IsIconic())
		iState	=	REGVAL_ICONIC;
	else
		if(rWnd.IsZoomed())
			iState	=	REGVAL_MAXIMIZED;

	return	AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_Valid,	REGVAL_INVALID) &&	// invalidate first
				AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_Left,		wpl.rcNormalPosition.left) &&
				AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_Right,		wpl.rcNormalPosition.right) &&
				AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_Top,		wpl.rcNormalPosition.top) &&
				AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_Bottom,	wpl.rcNormalPosition.bottom) &&
				AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_Visible,	bVisible ? REGVAL_VISIBLE : REGVAL_HIDDEN) &&
				AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_State,		iState) &&
				AfxGetApp()->WriteProfileInt(lpszProfile,	lpszRegVal_Valid,	REGVAL_VALID);		// validate position
}
Esempio n. 2
0
bool cdxCDynamicWndEx::StoreWindowPosition(LPCTSTR lpszProfile)
{
	if(!IsWindow() || !lpszProfile || !*lpszProfile)
	{
		ASSERT(false);
		return false;
	}

	CWnd	*pWnd	=	Window();

	WINDOWPLACEMENT	wpl;
	VERIFY( pWnd->GetWindowPlacement(&wpl) );
	CRect windowRect;
	pWnd->GetWindowRect(&windowRect);

	BOOL	bVisible	=	pWnd->IsWindowVisible();
	int	iState	=	REGVAL_NOSTATE;

	if(pWnd->IsIconic())
		iState	=	REGVAL_ICONIC;
	else
		if(pWnd->IsZoomed())
			iState	=	REGVAL_MAXIMIZED;

	CWinApp	*app	=	AfxGetApp();

	if(!app->m_pszRegistryKey || !*app->m_pszRegistryKey)
	{
		TRACE(_T("*** NOTE[cdxCDynamicWndEx::StoreWindowPosition()]: To properly store and restore a window's position, please call CWinApp::SetRegistryKey() in you app's InitInstance() !\n"));
		return false;
	}

	return	app->WriteProfileInt(lpszProfile,	lpszRegVal_Valid,	REGVAL_INVALID) &&	// invalidate first
				app->WriteProfileInt(lpszProfile,	lpszRegVal_Left,		windowRect.left) &&
				app->WriteProfileInt(lpszProfile,	lpszRegVal_Right,		windowRect.right) &&
				app->WriteProfileInt(lpszProfile,	lpszRegVal_Top,		windowRect.top) &&
				app->WriteProfileInt(lpszProfile,	lpszRegVal_Bottom,	windowRect.bottom) &&
//				app->WriteProfileInt(lpszProfile,	lpszRegVal_Left,		wpl.rcNormalPosition.left) &&
//				app->WriteProfileInt(lpszProfile,	lpszRegVal_Right,		wpl.rcNormalPosition.right) &&
//				app->WriteProfileInt(lpszProfile,	lpszRegVal_Top,		wpl.rcNormalPosition.top) &&
//				app->WriteProfileInt(lpszProfile,	lpszRegVal_Bottom,	wpl.rcNormalPosition.bottom) &&
				app->WriteProfileInt(lpszProfile,	lpszRegVal_Visible,	bVisible ? REGVAL_VISIBLE : REGVAL_HIDDEN) &&
				app->WriteProfileInt(lpszProfile,	lpszRegVal_State,		iState) &&
				app->WriteProfileInt(lpszProfile,	lpszRegVal_Valid,	REGVAL_VALID);		// validate position
}
Esempio n. 3
0
void CExtWSGripper::DoPaint( CDC * pDC )
{
	ASSERT( pDC != NULL );
	ASSERT( pDC->GetSafeHdc() != NULL );

	bool bTransparent = false;
	if( PmBridge_GetPM()->GetCb2DbTransparentMode(this) )
	{
		if( PmBridge_GetPM()->PaintDockerBkgnd( true, *pDC, this ) )
			bTransparent = true;
	}
	if( ! bTransparent )
	{
		CRect rcClient;
		GetClientRect( &rcClient );
		pDC->FillSolidRect(
			&rcClient,
			PmBridge_GetPM()->GetColor( CExtPaintManager::CLR_3DFACE_OUT, this ) 
			);
	}

	int nOldBkMode = pDC->SetBkMode(TRANSPARENT);

	CWnd * pWnd = GetParent();
	ASSERT( pWnd != NULL );
	ASSERT_VALID( pWnd );

	if( ! pWnd->IsZoomed() )
	{
		CRect rcClient;
		GetClientRect( &rcClient );
		PmBridge_GetPM()->PaintResizingGripper(
			*pDC,
			rcClient,
			this
			);
	}

	pDC->SetBkMode(nOldBkMode);

	PmBridge_GetPM()->OnPaintSessionComplete( this );
}
Esempio n. 4
0
void CResizableFormView::OnSize(UINT nType, int cx, int cy) 
{
	CFormView::OnSize(nType, cx, cy);

	CWnd* pParent = GetParent();

	// hide zise grip when parent is maximized
	if (pParent->IsZoomed())
		HideSizeGrip(&m_dwGripTempState, GHR_MAXIMIZED);
	else
		ShowSizeGrip(&m_dwGripTempState, GHR_MAXIMIZED);

	// hide size grip when there are scrollbars
	CSize size = GetTotalSize();
	if (cx < size.cx || cy < size.cy)
		HideSizeGrip(&m_dwGripTempState, GHR_SCROLLBAR);
	else
		ShowSizeGrip(&m_dwGripTempState, GHR_SCROLLBAR);

	// hide size grip when the parent window is not resizable
	// or the form is not bottom-right aligned (e.g. there's a statusbar)
	DWORD dwStyle = pParent->GetStyle();
	CRect rectParent, rectChild;
	GetWindowRect(rectChild);
	::MapWindowPoints(NULL, pParent->GetSafeHwnd(), (LPPOINT)&rectChild, 2);
	pParent->GetClientRect(rectParent);
	if (!(dwStyle & WS_THICKFRAME)
		|| (rectChild.BottomRight() != rectParent.BottomRight()))
		HideSizeGrip(&m_dwGripTempState, GHR_ALIGNMENT);
	else
		ShowSizeGrip(&m_dwGripTempState, GHR_ALIGNMENT);

	// update grip and layout
	UpdateSizeGrip();
	ArrangeLayout();
}
Esempio n. 5
0
LRESULT CExtWSGripper::WindowProc(
	UINT message,
	WPARAM wParam,
	LPARAM lParam
	) 
{
	if( message == WM_NCHITTEST )
	{
		CWnd * pWnd = GetParent();
		ASSERT( pWnd != NULL );
		ASSERT_VALID( pWnd );
		if( pWnd->IsZoomed() )
			return HTNOWHERE;

		__EXT_MFC_LONG_PTR dwExStyle = ::__EXT_MFC_GetWindowLong( pWnd->GetSafeHwnd(), GWL_EXSTYLE );
		bool bRTL = ( (dwExStyle & WS_EX_LAYOUTRTL) != 0 ) ? true : false;
		return bRTL 
			? HTBOTTOMLEFT 
			: HTBOTTOMRIGHT;
	}

 	if( message == WM_CREATE )
	{
		LRESULT lResult = CWnd::WindowProc( message, wParam, lParam );

		CRect rcClient;
		GetClientRect( &rcClient );
 	
		POINT ptCorners[] =
		{
			{
				rcClient.left,
				rcClient.bottom
			},
			{
				rcClient.right,
				rcClient.bottom
			},
			{
				rcClient.right,
				rcClient.top
			},
		};

		HRGN hRgn = ::CreatePolygonRgn( ptCorners, sizeof(ptCorners)/sizeof(ptCorners[0]), ALTERNATE );
		SetWindowRgn( hRgn, TRUE );
		
		return lResult;
	}

	if( message == WM_MOUSEACTIVATE )
		return MA_NOACTIVATEANDEAT;

	if( message == WM_ERASEBKGND )
		return 0L;

	if( message == WM_PRINTCLIENT )
	{
		CDC * pDC = CDC::FromHandle( (HDC)wParam );
		DoPaint( pDC );
		return (!0);
	}

	if( message == WM_PAINT )
	{
		ASSERT_VALID( this );
		CPaintDC dcPaint( this );
		CRect rcClient;
		GetClientRect( &rcClient );
		CExtMemoryDC dc(
			&dcPaint,
			&rcClient
			);
		DoPaint( &dc );
		return 0L;
	}

	return CWnd::WindowProc( message, wParam, lParam );
}