/**
 *  This function 'subclasses' an existing control with the toolbar.  This is
 *  not proper subclassing, as we hide the subclassed control, but borrow its
 *  position.
 *
 *  @param id       The id of the control to subclass.
 */
void DialogToolbar::Subclass(UINT id)
{
    CWnd  *parent        = GetParent();
    CWnd  *toolbarHolder = parent->GetDlgItem(id);
    CSize sizeBar        = CalcFixedLayout(FALSE, TRUE);
    WINDOWPLACEMENT wpl;
    toolbarHolder->GetWindowPlacement(&wpl);
    wpl.rcNormalPosition.bottom = wpl.rcNormalPosition.top  + sizeBar.cy + 4;
    wpl.rcNormalPosition.right  = wpl.rcNormalPosition.left + sizeBar.cx + 4;
    toolbarHolder->SetWindowPlacement(&wpl);
    SetWindowPlacement(&wpl);
    RepositionBars
    (
        AFX_IDW_CONTROLBAR_FIRST, 
        AFX_IDW_CONTROLBAR_LAST, 
        0
    );
    toolbarHolder->ShowWindow(SW_HIDE);
    SetWindowPos
    (
        &CWnd::wndTop,
        0, 0, 0, 0,
        SWP_NOACTIVATE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOMOVE
    );
    INIT_AUTO_TOOLTIP();
}
bool CShowGrafView::paintAll(CDC &dc, const CRect &rect, CFont *axisFont, CFont *buttonFont) {
  if(axisFont == NULL) {
    axisFont = &m_axisFont;
  }

  if(buttonFont == NULL) {
    buttonFont = &m_buttonFont;
  }

  CWnd *systemPanel = GetDlgItem(IDC_SYSTEMPANEL);
  CWnd *buttonPanel = GetDlgItem(IDC_BUTTONPANEL);

  if(systemPanel == NULL || buttonPanel == NULL) {
    return false;
  }
  const GraphArray &ga = getDoc()->getGraphArray();
  WINDOWPLACEMENT wpl;
  systemPanel->GetWindowPlacement(&wpl);
  int buttonPanelWidth = ga.getMaxButtonWidth(dc,*buttonFont) + 30;

  wpl.rcNormalPosition.left   = 0;
  wpl.rcNormalPosition.top    = 0;
  wpl.rcNormalPosition.right  = rect.right - buttonPanelWidth;
  wpl.rcNormalPosition.bottom = rect.bottom;
  systemPanel->SetWindowPlacement(&wpl);

  buttonPanel->GetWindowPlacement(&wpl);
  wpl.rcNormalPosition.left   = rect.right - buttonPanelWidth;
  wpl.rcNormalPosition.top    = 0;
  wpl.rcNormalPosition.right  = rect.right;
  wpl.rcNormalPosition.bottom = rect.bottom;
  buttonPanel->SetWindowPlacement(&wpl);

  m_coordinateSystem.SetFont(axisFont,FALSE);
  m_coordinateSystem.setGrid(theApp.getMainWindow()->hasGrid());
  try {
    m_coordinateSystem.OnPaint();
    CClientDC dc(&m_coordinateSystem);
    m_coordinateSystem.setDC(dc);
    ga.paint(m_coordinateSystem, *buttonFont, getRelativeClientRect(this,IDC_BUTTONPANEL));
//    debugLog(_T("Cells Occupied:\n%s"), m_coordinateSystem.getOccupationMap().toString().cstr());
    return true;
  } catch(Exception e) {
    showException(e);
    return false;
  }
}
void ReportTaskInputSummary::UpdateDynamicSummary(void)
{
	int NumForces;
	CFrameWnd* pFrame = GetParentFrame();
	
	CWnd			*mainWnd = (CWnd*)this;

	if (2 >= (NumForces = CountExternalForces() + 2)) {
		GetDlgItem(IDD_OutlineJointLoads)->ShowWindow(SW_HIDE);
		GetDlgItem(IDD_ReportTaskInputSummaryJointLoads)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_JTNAMES)->ShowWindow(SW_HIDE);
		
		WINDOWPLACEMENT lpwndpl;

		mainWnd->GetWindowPlacement(&lpwndpl);
		//lpwndpl.rcNormalPosition.bottom += lpwndpl.rcNormalPosition.bottom - hack_WindowBottom;
		//mainWnd->SetWindowPlacement(&lpwndpl);
		MoveWindow( 0,0,lpwndpl.rcNormalPosition.right, hack_WindowBottom, TRUE );
//		ResizeParentToFit(FALSE);
		//pFrame->SetWindowPos(NULL, 0, 0, lpwndpl.rcNormalPosition.right + 20, hack_WindowBottom,
		pFrame->SetWindowPos(NULL, 0, 0, lpwndpl.rcNormalPosition.right + 16, hack_WindowBottom,
		SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);

		m_JointLoads.Empty();
		m_JointNames.Empty();
		CWnd			*Footer;
		WINDOWPLACEMENT		FooterLoc;
		Footer = GetDlgItem(IDC_Footer);
		Footer->GetWindowPlacement( &FooterLoc );
		FooterLoc.rcNormalPosition.top		= hack_FooterTop + 13;
		FooterLoc.rcNormalPosition.bottom	= hack_FooterTop + 28+15;
		Footer->SetWindowPlacement(&FooterLoc);
				
	}
	else {
		// /*
		CWnd			*Footer, *Joints, *Names, *Outline;
		WINDOWPLACEMENT		FooterLoc, JointsLoc, OutlineLoc, NamesLoc;
		
		// Show the box for the other joints
		GetDlgItem(IDD_OutlineJointLoads)->ShowWindow(SW_SHOW);
		GetDlgItem(IDD_ReportTaskInputSummaryJointLoads)->ShowWindow(SW_SHOW);
		GetDlgItem(IDC_JTNAMES)->ShowWindow(SW_SHOW);
		
		// Move the footer down 50 units
		Footer = GetDlgItem(IDC_Footer);
		Footer->GetWindowPlacement( &FooterLoc );
		
		Outline = GetDlgItem(IDD_OutlineJointLoads);
		Outline->GetWindowPlacement( &OutlineLoc );
		
		Joints = GetDlgItem(IDD_ReportTaskInputSummaryJointLoads);
		Joints->GetWindowPlacement( &JointsLoc );
		
		Names = GetDlgItem(IDC_JTNAMES);
		Names->GetWindowPlacement( &NamesLoc );
		
		OutlineLoc.rcNormalPosition.top		= hack_FooterTop + 5;
		OutlineLoc.rcNormalPosition.left	= FooterLoc.rcNormalPosition.left;
		OutlineLoc.rcNormalPosition.right	= FooterLoc.rcNormalPosition.right;
		
		NamesLoc.rcNormalPosition.top		= OutlineLoc.rcNormalPosition.top + 15;
		NamesLoc.rcNormalPosition.left		= OutlineLoc.rcNormalPosition.left + 10;
		NamesLoc.rcNormalPosition.right		= OutlineLoc.rcNormalPosition.left + 105;
		NamesLoc.rcNormalPosition.bottom	= NamesLoc.rcNormalPosition.top + (NumForces * TextHeight) + 15;
		
		JointsLoc.rcNormalPosition.top		= OutlineLoc.rcNormalPosition.top + 15;
		JointsLoc.rcNormalPosition.left		= NamesLoc.rcNormalPosition.right + 5;
		JointsLoc.rcNormalPosition.right	= OutlineLoc.rcNormalPosition.right - 10;
		JointsLoc.rcNormalPosition.bottom	= JointsLoc.rcNormalPosition.top + (NumForces * TextHeight) + 15;
		
		OutlineLoc.rcNormalPosition.bottom	= JointsLoc.rcNormalPosition.bottom + 2.5;
		
		
		Joints->SetWindowPlacement(&JointsLoc);
		Outline->SetWindowPlacement(&OutlineLoc);
		Names->SetWindowPlacement(&NamesLoc);
		
		FooterLoc.rcNormalPosition.top		= OutlineLoc.rcNormalPosition.bottom + 13;
		FooterLoc.rcNormalPosition.bottom	= OutlineLoc.rcNormalPosition.bottom + 28+15;
		Footer->SetWindowPlacement(&FooterLoc);
		
		WINDOWPLACEMENT lpwndpl;
		mainWnd->GetWindowPlacement(&lpwndpl);
//		lpwndpl.rcNormalPosition.bottom = hack_WindowBottom - NumForces * TextHeight - 25;
//		mainWnd->SetWindowPlacement(&lpwndpl);
		MoveWindow( 0,0,lpwndpl.rcNormalPosition.right, hack_WindowBottom + NumForces * TextHeight + 25, TRUE );
//		ResizeParentToFit(FALSE);
		pFrame->SetWindowPos(NULL, 0, 0, lpwndpl.rcNormalPosition.right + 16, hack_WindowBottom + NumForces * TextHeight + 25,
		SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
//		this->OnSize(0, lpwndpl.rcNormalPosition.right, hack_WindowBottom + NumForces * TextHeight + 25);

		DisplayExtForces(&m_JointLoads);
		DisplayExtForceNames(&m_JointNames);
		
	}
}
bool cdxCDynamicControlsManager::RestoreWindowPosition(CWnd & rWnd, LPCTSTR lpszProfile, UINT restoreFlags)
{
	ASSERT(::IsWindow(rWnd.m_hWnd) && lpszProfile && *lpszProfile);
	// can't use an empty profile section string; see CWinApp::GetProfileInt() for further information

	//
	// first, we check whether the position had been saved successful any time before
	//

	if( AfxGetApp()->GetProfileInt(lpszProfile,lpszRegVal_Valid,REGVAL_INVALID) != REGVAL_VALID )
		return false;

	//
	// get old position
	//

	WINDOWPLACEMENT	wpl;
	VERIFY( rWnd.GetWindowPlacement(&wpl) );

	//
	// read registry
	//

	int	iState	=	AfxGetApp()->GetProfileInt(lpszProfile,	lpszRegVal_State, REGVAL_NOSTATE);

	//
	// get window's previous normal position
	//

	wpl.rcNormalPosition.left		=	AfxGetApp()->GetProfileInt(lpszProfile,	lpszRegVal_Left,		wpl.rcNormalPosition.left);
	wpl.rcNormalPosition.right		=	AfxGetApp()->GetProfileInt(lpszProfile,	lpszRegVal_Right,		wpl.rcNormalPosition.right);
	wpl.rcNormalPosition.top		=	AfxGetApp()->GetProfileInt(lpszProfile,	lpszRegVal_Top,		wpl.rcNormalPosition.top);
	wpl.rcNormalPosition.bottom	=	AfxGetApp()->GetProfileInt(lpszProfile,	lpszRegVal_Bottom,	wpl.rcNormalPosition.bottom);

	if(wpl.rcNormalPosition.left > wpl.rcNormalPosition.right)
	{
		long	l	=	wpl.rcNormalPosition.right;
		wpl.rcNormalPosition.right	=	wpl.rcNormalPosition.left;
		wpl.rcNormalPosition.left	=	l;
	}
	if(wpl.rcNormalPosition.top > wpl.rcNormalPosition.bottom)
	{
		long	l	=	wpl.rcNormalPosition.bottom;
		wpl.rcNormalPosition.bottom	=	wpl.rcNormalPosition.top;
		wpl.rcNormalPosition.top	=	l;
	}

	//
	// get restore stuff
	//

	UINT	showCmd	=	SW_SHOWNA;
	
	if(restoreFlags & rflg_state)
	{
		if(iState == REGVAL_MAXIMIZED)
			showCmd	=	SW_MAXIMIZE;
		else
			if(iState == REGVAL_ICONIC)
				showCmd	=	SW_MINIMIZE;
	}

	//
	// use MoveWindow() which takes care of WM_GETMINMAXINFO
	//

	rWnd.MoveWindow(	wpl.rcNormalPosition.left,wpl.rcNormalPosition.top,
							wpl.rcNormalPosition.right - wpl.rcNormalPosition.left,
							wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top,
							showCmd == SW_SHOWNA);

	if(showCmd != SW_SHOWNA)
	{
		// read updated position

		VERIFY( rWnd.GetWindowPlacement(&wpl) );
		wpl.showCmd	=	showCmd;
		rWnd.SetWindowPlacement(&wpl);
	}
	
	//
	// get visiblity
	//

	if(restoreFlags & rflg_visibility)
	{
		int	i	=	AfxGetApp()->GetProfileInt(lpszProfile,	lpszRegVal_Visible, REGVAL_NOSTATE);
		if(i == REGVAL_VISIBLE)
			rWnd.ShowWindow(SW_SHOW);
		else
			if(i == REGVAL_HIDDEN)
				rWnd.ShowWindow(SW_HIDE);
	}

	return true;
}
Esempio n. 5
0
void CWindowListDlg::OnContextMenu(CWnd*, CPoint point) 
{
	CPoint ptClient(point);
	m_ctlWindowList.ScreenToClient(&ptClient);

	TCHITTESTINFO info;
	info.flags = TCHT_ONITEM;
	info.pt = ptClient;

	int nIndex = m_ctlWindowList.HitTest(&info);

	CWnd* pWnd = NULL;
	if (nIndex != -1)
	{
		CMenu menu;
		menu.LoadMenu(IDR_WNDLIST_RCLICK);
		CMenu *pMenu = menu.GetSubMenu(0);
		ASSERT(pMenu != NULL);

		WINDOWPLACEMENT placement = { sizeof(WINDOWPLACEMENT) };
		pWnd = GetWnd(nIndex);
		pWnd->GetWindowPlacement(&placement);

		if (placement.showCmd == SW_HIDE)
		{
			menu.EnableMenuItem(ID_WNDLIST_CLOSE, MF_BYCOMMAND | MF_GRAYED);
		}
		else if (placement.showCmd == SW_SHOWMAXIMIZED)
		{
			menu.EnableMenuItem(ID_WNDLIST_MAX,   MF_BYCOMMAND | MF_GRAYED);
		}
		else if (placement.showCmd == SW_SHOWMINIMIZED)
		{
			menu.EnableMenuItem(ID_WNDLIST_MIN,   MF_BYCOMMAND | MF_GRAYED);
		}
		else if (m_ctlWindowList.GetCurSel() == nIndex)
		{
			menu.EnableMenuItem(ID_WNDLIST_SHOW,  MF_BYCOMMAND | MF_GRAYED);
		}
		pWnd->GetWindowPlacement(&placement);

		int res = pMenu->TrackPopupMenu( (TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD),
					 point.x, point.y, this);

		switch(res)
		{
		case ID_WNDLIST_CLOSE:
			pWnd->PostMessage(WM_CLOSE);
			break;
		case ID_WNDLIST_MAX:
			placement.showCmd = SW_SHOWMAXIMIZED;
			pWnd->SetWindowPlacement(&placement);
			break;
		case ID_WNDLIST_MIN:
			placement.showCmd = SW_SHOWMINIMIZED;
			pWnd->SetWindowPlacement(&placement);
			break;
		case ID_WNDLIST_SHOW:
			pWnd->ShowWindow(SW_SHOWNORMAL);
			pWnd->BringWindowToTop();
			break;
		}
	}
}
Esempio n. 6
0
//---------------------------------------------------------------------------
BOOL ReportView::OnPreparePrinting(CPrintInfo* pInfo)
{
	if(pInfo->m_bPreview) {
		return this->DoPreparePrinting(pInfo);
	}
	
	//if(!mPrintMultiple) {

		pInfo->m_bDirect = this->mPrintDirect;

		this->GetParentFrame()->SetActiveWindow();
		this->GetParentFrame()->BringWindowToTop();
		//this->SetActiveWindow();
		//this->BringWindowToTop();
		return this->DoPreparePrinting(pInfo);
	//}


	// printing from print multiple reports


   C_Main_Frame* lMainFramePtr = MainFramePtr();

   if (mDibViewPtr == NULL) {
		mDibViewPtr = lMainFramePtr->Create_Dib_Window();
   }

   CWnd* lFramePtr = this->GetParent();
   ASSERT( lFramePtr != NULL );

   //--- Save existing placement ---
   
   WINDOWPLACEMENT   lSavePlacement;
   lFramePtr->GetWindowPlacement( & lSavePlacement );

   //--- Compute and set print placement ---

   /*lFramePtr->ShowWindow( SW_RESTORE );
   this->ResizeParentToFit( FALSE );*/

   WINDOWPLACEMENT   lPrintPlacement;
   lFramePtr->GetWindowPlacement( & lPrintPlacement );

 // JTK - Commented out to fix print preview issue  
   /*lPrintPlacement.rcNormalPosition.right  -= lPrintPlacement.rcNormalPosition.left;
   lPrintPlacement.rcNormalPosition.bottom -= lPrintPlacement.rcNormalPosition.top ;

   lPrintPlacement.rcNormalPosition.left  = 0;
   lPrintPlacement.rcNormalPosition.top   = 0;
   lFramePtr->MoveWindow(&lPrintPlacement.rcNormalPosition);
   lFramePtr->SetWindowPlacement( & lPrintPlacement );*/
   
   //--- Create the DIB ---
   lFramePtr->SetActiveWindow();
   lFramePtr->BringWindowToTop();
   lFramePtr->UpdateWindow();
   mDibViewPtr->LoadDib(lFramePtr);
   
   //--- Call normal printing ---
   
   pInfo->m_bDirect = mPrintDirect;
   BOOL lPrintResult = mDibViewPtr->OnPreparePrinting( pInfo );  
   
   //--- Restore the window ---

   lFramePtr->SetWindowPlacement( & lSavePlacement );
   lFramePtr->ShowWindow( lSavePlacement.showCmd );
   lFramePtr->UpdateWindow();
   
   return lPrintResult;  
}
Esempio n. 7
0
bool cdxCDynamicWndEx::RestoreWindowPosition(LPCTSTR lpszProfile, UINT restoreFlags)
{
	if(!IsWindow() || !lpszProfile || !*lpszProfile)
	{
		ASSERT(false);
		return false;
	}

	CWnd		*pWnd	=	Window();
	CWinApp	*app	=	AfxGetApp();

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

	//
	// first, we check whether the position had been saved successful any time before
	//

	if( app->GetProfileInt(lpszProfile,lpszRegVal_Valid,REGVAL_INVALID) != REGVAL_VALID )
		return false;

	//
	// get old position
	//

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

	//
	// read registry
	//

	int	iState	=	app->GetProfileInt(lpszProfile,	lpszRegVal_State, REGVAL_NOSTATE);

	//
	// get window's previous normal position
	//

	windowRect.left		=	app->GetProfileInt(lpszProfile,	lpszRegVal_Left,		windowRect.left);
	windowRect.right		=	app->GetProfileInt(lpszProfile,	lpszRegVal_Right,		windowRect.right);
	windowRect.top		=	app->GetProfileInt(lpszProfile,	lpszRegVal_Top,		windowRect.top);
	windowRect.bottom	=	app->GetProfileInt(lpszProfile,	lpszRegVal_Bottom,	windowRect.bottom);
//	wpl.rcNormalPosition.left		=	app->GetProfileInt(lpszProfile,	lpszRegVal_Left,		wpl.rcNormalPosition.left);
//	wpl.rcNormalPosition.right		=	app->GetProfileInt(lpszProfile,	lpszRegVal_Right,		wpl.rcNormalPosition.right);
//	wpl.rcNormalPosition.top		=	app->GetProfileInt(lpszProfile,	lpszRegVal_Top,		wpl.rcNormalPosition.top);
//	wpl.rcNormalPosition.bottom	=	app->GetProfileInt(lpszProfile,	lpszRegVal_Bottom,	wpl.rcNormalPosition.bottom);

	if(windowRect.left > windowRect.right)
	{
		long	l	=	windowRect.right;
		windowRect.right	=	windowRect.left;
		windowRect.left	=	l;
	}
	if(windowRect.top > windowRect.bottom)
	{
		long	l	=	windowRect.bottom;
		windowRect.bottom	=	windowRect.top;
		windowRect.top	=	l;
	}

	//
	// get restore stuff
	//

	UINT	showCmd	=	SW_SHOWNA;
	
	if(restoreFlags & rflg_state)
	{
		if(iState == REGVAL_MAXIMIZED)
			showCmd	=	SW_MAXIMIZE;
		else
			if(iState == REGVAL_ICONIC)
				showCmd	=	SW_MINIMIZE;
	}

	//
	// use MoveWindow() which takes care of WM_GETMINMAXINFO
	//

	pWnd->MoveWindow(	windowRect.left,windowRect.top,
							windowRect.right - windowRect.left,
							windowRect.bottom - windowRect.top,
							showCmd == SW_SHOWNA);

	if(showCmd != SW_SHOWNA)
	{
		// read updated position

		VERIFY( pWnd->GetWindowPlacement(&wpl) );
		wpl.showCmd	=	showCmd;
		pWnd->SetWindowPlacement(&wpl);
	}
	
	//
	// get visiblity
	//

	if(restoreFlags & rflg_visibility)
	{
		int	i	=	app->GetProfileInt(lpszProfile,	lpszRegVal_Visible, REGVAL_NOSTATE);
		if(i == REGVAL_VISIBLE)
			pWnd->ShowWindow(SW_SHOW);
		else
			if(i == REGVAL_HIDDEN)
				pWnd->ShowWindow(SW_HIDE);
	}

	return true;
}