void ReportTaskInputSummary::OnInitialUpdate() 
{	
	int i=0;

	CWnd *mainWnd = (CWnd*)this;

	{
		WINDOWPLACEMENT lpwndpl;
		mainWnd->GetWindowPlacement(&lpwndpl);

		//hack_WindowBottom = lpwndpl.rcNormalPosition.;
		//Yijun: resize the windows
		hack_WindowBottom = 550;
	}
	{
		CWnd *tempFrame = GetDlgItem(IDC_HANDSFRAME);
		WINDOWPLACEMENT tempCoords;
		tempFrame->GetWindowPlacement(&tempCoords);
		hack_FooterTop = tempCoords.rcNormalPosition.bottom;
	}
	
	this->ReportView::OnInitialUpdate();	

	// Set the hand force box units
	C_Hom_Doc* docPtr = (C_Hom_Doc*)GetDocument();
	mUnitsLabel = "Hand Locations (" + docPtr->LengthUnits() + ")";
	mHandForceUnits = CString("Hand Forces (") + docPtr->ForceUnits() + ")";
	m3DLowBackCompressionUnits = "3D Low back Compression (" + docPtr->ForceUnits() + ")";
	UpdateData(false);
}
/**
 *  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();
}
cdxCDynamicControlsManager::ControlData::ControlData(cdxCDynamicControlsManager & rMaster, CWnd & ctrl, const PositionSetup & rPosSetup)
:	m_rMaster(rMaster), m_pCtrl(NULL),
	m_pNext(NULL), m_pPrev(NULL),
	m_posSetup(rPosSetup)
{
	ASSERT(::IsWindow(ctrl.m_hWnd));		// control must have already been created !
	ASSERT(rPosSetup.IsValid());

	//
	// get initial values
	//

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

	m_rectOriginal	=	wpl.rcNormalPosition;

	//
	// remember control
	//

	new ControlEntry(ctrl,*this);
	ASSERT(m_pCtrl != NULL);

	//
	// link us to the cdxCDynamicControlsManager's list
	//

	if(m_pNext = m_rMaster.m_pFirst)
		m_pNext->m_pPrev	=	this;
	m_pPrev	=	NULL;
	m_rMaster.m_pFirst	=	this;
}
bool cdxCDynamicControlsManager::StretchWindow(CWnd & rWnd, const CSize & szDelta)
{
	ASSERT(::IsWindow(rWnd.m_hWnd));

	WINDOWPLACEMENT	wpl;
	rWnd.GetWindowPlacement(&wpl);

	wpl.rcNormalPosition.left		-=	szDelta.cx / 2;
	wpl.rcNormalPosition.right		+=	(szDelta.cx + 1) / 2;
	wpl.rcNormalPosition.top		-=	szDelta.cy / 2;
	wpl.rcNormalPosition.bottom	+=	(szDelta.cy + 1) / 2;
//	wpl.flags	=	SW_SHOWNA|SW_SHOWNOACTIVATE;

	if((wpl.rcNormalPosition.left >= wpl.rcNormalPosition.right) ||
		(wpl.rcNormalPosition.top >= wpl.rcNormalPosition.bottom))
		return false;

	VERIFY( rWnd.SetWindowPos(	NULL,
										wpl.rcNormalPosition.left,
										wpl.rcNormalPosition.top,
										wpl.rcNormalPosition.right - wpl.rcNormalPosition.left,
										wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top,
										SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER) );

	return true;
}
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
}
示例#6
0
bool cdxCDynamicWndEx::StretchWindow(const CSize & szDelta)
{
	if(!IsWindow())
	{
		ASSERT(false);
		return false;
	}

	CWnd	*pWnd	=	Window();

	WINDOWPLACEMENT	wpl;
	pWnd->GetWindowPlacement(&wpl);

	wpl.rcNormalPosition.left		-=	szDelta.cx / 2;
	wpl.rcNormalPosition.right		+=	(szDelta.cx + 1) / 2;
	wpl.rcNormalPosition.top		-=	szDelta.cy / 2;
	wpl.rcNormalPosition.bottom	+=	(szDelta.cy + 1) / 2;
//	wpl.flags	=	SW_SHOWNA|SW_SHOWNOACTIVATE;

	if((wpl.rcNormalPosition.left >= wpl.rcNormalPosition.right) ||
		(wpl.rcNormalPosition.top >= wpl.rcNormalPosition.bottom))
		return false;

	VERIFY( pWnd->SetWindowPos(NULL,
										wpl.rcNormalPosition.left,
										wpl.rcNormalPosition.top,
										wpl.rcNormalPosition.right - wpl.rcNormalPosition.left,
										wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top,
										SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER) );

	return true;
}
示例#7
0
LRESULT CDocSelector::OnSelChange(WPARAM wParam, LPARAM)
{
	// Killing the timer, because timer can change the
	// selection in between the procedure...
	KillTimer( DS_TIMER_ID ); // Yogesh Jagota

	// sent when a button gets clicked
	CSwitcherButton* newsel = (CSwitcherButton*)wParam;

	// Yogesh Jagota
	CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
	CWnd* Window = (CWnd*)newsel->m_FrameWnd;

	WINDOWPLACEMENT	wndpl;

	Window->GetWindowPlacement( &wndpl);

	if(wndpl.showCmd == SW_SHOWMINIMIZED) Window->ShowWindow(SW_RESTORE);
	
	pFrame->MDIActivate( Window );
	// End Yogesh Jagota

	if (m_iSelectedButton > -1)
		GetButtonFromID(m_iSelectedButton)->Unselect();

	m_iSelectedButton = newsel->m_iID;

	// Reactivate the timer...
	SetTimer( DS_TIMER_ID, 10, NULL ); // Yogesh Jagota

	return 1;
}
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;
  }
}
示例#9
0
void CDlgIBAFastlane::UpdateBugle()
{
	CWnd *pBugle = GetDlgItem(IDC_PIC_BUGLE);

	WINDOWPLACEMENT wp;
	pBugle->GetWindowPlacement(&wp);

	InvalidateRect(&wp.rcNormalPosition);
}
void CExtStatusControlBar::OnPaint() 
{
	_SyncStatusBarColors();
CPaintDC dc( this );
	//Default();
	CStatusBar::UpdateAllPanes( FALSE, TRUE );
	CStatusBar::DefWindowProc(WM_PAINT,(WPARAM)dc.GetSafeHdc(),0);

CWnd * pWnd = GetTopLevelParent();
	if( pWnd != NULL )
	{
		WINDOWPLACEMENT _wp;
		::memset( (void*)&_wp, 0, sizeof(WINDOWPLACEMENT) );
		_wp.length = sizeof(WINDOWPLACEMENT);
		pWnd->GetWindowPlacement( &_wp );
		if( _wp.showCmd != SW_SHOWMAXIMIZED )
		{
			CRect rcGrip;
			GetClientRect( &rcGrip );
			rcGrip.left = rcGrip.right - ::GetSystemMetrics( SM_CXVSCROLL );
			dc.FillSolidRect(
				&rcGrip,
				g_PaintManager->GetColor(CExtPaintManager::CLR_3DFACE_OUT)
				);
			CFont * pOldFont =
				dc.SelectObject( &g_PaintManager->m_FontMarlett );
			ASSERT( pOldFont != NULL );
			COLORREF clrOld =
				dc.SetTextColor(
					g_PaintManager->GetColor( CExtPaintManager::CLR_TEXT_OUT )
					);
			INT nOldBkMode = dc.SetBkMode(TRANSPARENT);
			rcGrip.OffsetRect( -2, -2 );
			dc.DrawText(
				_T("o"), 1, rcGrip, DT_SINGLELINE|DT_RIGHT|DT_BOTTOM
				);
			dc.SetBkMode( nOldBkMode );
			dc.SetTextColor( clrOld );
			dc.SelectObject( pOldFont );
		} // if( _wp.showCmd != SW_SHOWMAXIMIZED )
	} // if( pWnd != NULL )

    dc.SelectStockObject( NULL_BRUSH );
INT nItem = m_bOuterRectInFirstBand ? 0 : 1;
	for( ; nItem < m_nCount; nItem++ )
	{
		CRect rc;
		GetItemRect( nItem, rc );
		CExtPaintManager::PAINTCONTROLBARBORDERSDATA _pcbbd(
			this,
			CExtPaintManager::__CB_INNER_STATUSBAR_ITEM,
			0,
			rc
			);
		g_PaintManager->PaintControlBarBorders( dc, _pcbbd );
	} // for( ; nItem < m_nCount; nItem++ )
}
//						============================
BOOL 					CMessageCentre::OnInitDialog() 
//						============================
{
	CDialog::OnInitDialog();

	// Set icon on the dialog
	HICON icon = AfxGetApp()->LoadIcon(IDI_ICON2);
	// Make it a small icon
	SetIcon(icon,false);

	// Change the dialog background to yellow
	m_brush.CreateSolidBrush(RGB(255,204,0));

	// Calculate the difference in height for 'Less Detail' en 'More Detail'
	// states of this dialog
	WINDOWPLACEMENT wp;
	CRect Recto;
	CWnd* pMore;
	CWnd* pLess;
	int nCaptionHeight = ::GetSystemMetrics(SM_CYCAPTION);

	m_nHeightDifference = 0;
	pMore = GetDlgItem(IDC_MORE_DETAIL_SIZE);
	pLess = GetDlgItem(IDC_LESS_DETAIL_SIZE);

	if ((pMore != 0) && (pLess != 0))
	{
		//pMore->GetWindowPlacement(&wp);
		//m_nHeightDifference = wp.rcNormalPosition.bottom;
		GetClientRect(&Recto);
		m_nHeightDifference = Recto.bottom; // + nCaptionHeight;

		pLess->GetWindowPlacement(&wp);
		m_nHeightDifference = m_nHeightDifference - wp.rcNormalPosition.bottom;


	}

//	m_button_pauze.SubclassDlgItem(IDC_BTN_PAUSE,this);
//	m_button_stop.SubclassDlgItem(IDC_BTN_STOP,this);
//	m_button_detail.SubclassDlgItem(IDC_BTN_DETAIL,this);
//	m_Progress.SubclassDlgItem(IDC_PROGRESS,this);

	// Set the texts of all controls
	m_pDlg->SetControlTexts();

	// Set the range of the progress indicator (0 ... 1000)
	m_Progress.SetRange(0, 1000);

	// Return TRUE unless you set the focus to a control
	return TRUE;
}
示例#12
0
//	CHANGE!	04/03/97	John Moore
//	First create the tab bar and initialize the tab controls...
BOOL CMainFrame::CreateTabBar()
{
	if (!m_wndTabBar.Create(this, IDD_TABDIALOG, WS_CHILD | CBRS_RIGHT |
		CBRS_TOOLTIPS | CBRS_FLYBY, IDD_TABDIALOG) )
	{
		TRACE0("Failed to create tab bar\n");
		return FALSE;       // fail to create
	}

	//	Create the property sheet and its pages...
	m_wndTabControls = new CFusionTabControls( &m_wndTabBar );

	//	Now set the area for our tabs...
	RECT rect;
	CWnd* WndPtr = m_wndTabBar.GetDlgItem( IDC_GROUP1 );
	WndPtr->GetClientRect( &rect );

	if (!m_wndTabControls->Create( WS_CHILD|WS_VISIBLE|TCS_MULTILINE, rect, &m_wndTabBar, 0 ))
	{
		TRACE0( "CFusionTabControls: Create(...) Failed\n" );
		return FALSE;
	}

	TabFont.CreateFont
	(
		12, 0, 
		0, 0, 
		FW_BOLD,
		0, 0, 0,
		ANSI_CHARSET, 
		OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, 
		DRAFT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE,
		"MS Sans Serif"
	) ;
	m_wndTabControls->SetFont( &TabFont ) ;

	//	Now let's set the position of our tabs...
	WINDOWPLACEMENT	WndPlace;
	WndPtr->GetWindowPlacement( &WndPlace );
	m_wndTabControls->SetWindowPos( NULL, WndPlace.rcNormalPosition.left,
			WndPlace.rcNormalPosition.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
	m_wndTabControls->m_WindowPlacement = WndPlace;

	m_wndTabControls->CreateTabs();

	return TRUE;
}
示例#13
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
}
示例#14
0
void CWindowListDlg::OnSelchangeWindowTabs(NMHDR* pNMHDR, LRESULT* pResult) 
{
	CWnd* pWnd = GetWnd(m_ctlWindowList.GetCurSel());

	if (IsWindow(pWnd->m_hWnd))
	{
		WINDOWPLACEMENT placement = { sizeof(WINDOWPLACEMENT) };

		pWnd->GetWindowPlacement(&placement);

		if (placement.showCmd == SW_HIDE || 
			placement.showCmd == SW_MINIMIZE ||
			placement.showCmd == SW_SHOWMINIMIZED)
		{
			pWnd->ShowWindow(SW_SHOWNORMAL);
		}
		pWnd->BringWindowToTop();
	}
	
	*pResult = 0;
}
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;
}
示例#17
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;  
}
示例#18
0
void CInformErrorDialog::GetDialogInfo()
{
	// Skip this if we've already done it.
	if (ValidInfo)
		return;

	// Find out how bug the dialog is by default.
	CRect DlgRect;
	GetClientRect(&DlgRect);
	DialogSize.cx = DlgRect.Width();
	DialogSize.cy = DlgRect.Height();

	// Find out the button spacing/sizes etc.
	CWnd *pCtrl1 = GetDlgItem(ButtonID[0]);
	CWnd *pCtrl2 = GetDlgItem(ButtonID[1]);
	ENSURE((pCtrl1 != NULL) && (pCtrl2 != NULL), 
		   "Can't find control in CInformErrorDialog::OnInitDialog()");

	// Safety check.
	if ((pCtrl1 == NULL) || (pCtrl2 == NULL))
		return;

	// Get width of buttons, and the spacing between the buttons and the edge of the dialog.
	WINDOWPLACEMENT Placement;
	Placement.length = sizeof(WINDOWPLACEMENT);
	pCtrl1->GetWindowPlacement(&Placement);

	DefTopOfButton = Placement.rcNormalPosition.top;
	DefButtonSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;
	DefButtonSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;
	EdgeSpacing = Placement.rcNormalPosition.left;

	// Get space between adjacent buttons.
	Placement.length = sizeof(WINDOWPLACEMENT);
	pCtrl2->GetWindowPlacement(&Placement);

	ButtonSpacing = Placement.rcNormalPosition.left - (EdgeSpacing + DefButtonSize.cx);

	// Find the position of the icon.
	CWnd *pIconCtrl = GetDlgItem(_R(IDC_ERRORBOX_ICON));
	ENSURE(pIconCtrl != NULL, "Can't find Icon control in CInformErrorDialog::GetDialogInfo()");

	// Safety check.
	if (pIconCtrl == NULL)
		return;

	Placement.length = sizeof(WINDOWPLACEMENT);
	pIconCtrl->GetWindowPlacement(&Placement);
	
	DefIconPos.x = Placement.rcNormalPosition.left;
	DefIconPos.y = Placement.rcNormalPosition.top;

	// Find the position of the message text area.
	CWnd *pMsgCtrl = GetDlgItem(_R(IDC_ERRORBOX_TEXT));
	ENSURE(pMsgCtrl != NULL, "Can't find Text control in CInformErrorDialog::GetDialogInfo()");

	// Safety check.
	if (pMsgCtrl == NULL)
		return;

	Placement.length = sizeof(WINDOWPLACEMENT);
	pMsgCtrl->GetWindowPlacement(&Placement);

	DefMsgSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;
	DefMsgSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;

	// The static variables now contain valid information.
	ValidInfo = TRUE;
}
void CSimpleDcmViewerDlg::drawPictCtrl()
{
	if (TFileManager::getInst()->m_D == 0) return;

	static bool first = true;

	if (first)
	{
		CWnd *cwndPC = GetDlgItem(IDC_PC);
		first = false;
		CRect r;
		WINDOWPLACEMENT winplace;
		cwndPC->GetClientRect(&r);
		cwndPC->GetWindowPlacement(&winplace);

		m_pcW = m_pcH = PC_SIZE;//-2
		m_pcX = winplace.rcNormalPosition.left;
		m_pcY = winplace.rcNormalPosition.top;
	}


	// picture ControlのCWndを取得
	CWnd *pcWnd = GetDlgItem(IDC_PC);
	CDC  *pcDC = pcWnd->GetDC(); 


	BITMAPINFO binfo;
	ZeroMemory(&binfo, sizeof(binfo));
	binfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	binfo.bmiHeader.biBitCount = 32;//1pixel 32-bit (4-byte)
	binfo.bmiHeader.biPlanes   = 1;
	binfo.bmiHeader.biWidth    =  PC_SIZE;
	binfo.bmiHeader.biHeight   = -PC_SIZE; //if negative : origin --> left top 

	byte    *bmpbits; 
	HBITMAP  hbmp = CreateDIBSection(NULL, &binfo, DIB_RGB_COLORS, (void **)(&bmpbits), NULL, 0);

	CBitmap *cbmp = CBitmap::FromHandle(hbmp);
	CDC cbmpDC;
	cbmpDC.CreateCompatibleDC(pcDC);          
	CBitmap *oldBmp = cbmpDC.SelectObject(cbmp);

	const int    imgW = TFileManager::getInst()->m_W;
	const int    imgH = TFileManager::getInst()->m_H;
	const int    imgD = TFileManager::getInst()->m_D;
	const int    imgZ = m_slider_z       .GetPos();
	const float  vMax = (float)m_slider_winLvMax.GetPos();
	const float  vMin = (float)m_slider_winLvMin.GetPos();
	int x0 = m_spin_clipXmin.GetPos32(), x1 = m_spin_clipXmax.GetPos32();  t_cropI(x0, 0, imgW - 1);  t_cropI(x0, 0, imgW - 1);
	int y0 = m_spin_clipYmin.GetPos32(), y1 = m_spin_clipYmax.GetPos32();  t_cropI(y0, 0, imgH - 1);  t_cropI(y0, 0, imgH - 1);
	int z0 = m_spin_clipZmin.GetPos32(), z1 = m_spin_clipZmax.GetPos32();  t_cropI(z0, 0, imgD - 1);  t_cropI(z0, 0, imgD - 1);

	if (imgZ < 0 || imgZ > imgD - 1) return;


	const int WH = imgW * imgH;
	float *sliceImg = TFileManager::getInst()->m_volume[imgZ];

	double xCoef = imgW / (double)PC_SIZE;
	double yCoef = imgH / (double)PC_SIZE;

	for (int y = 0; y < PC_SIZE; ++y)
	{
		for (int x = 0; x < PC_SIZE; ++x)
		{
			int imgX = (int)((x + 0.5) * xCoef);
			int imgY = (int)((y + 0.5) * yCoef);
			int imgI = imgX + imgY * imgW;
			const float imgV = sliceImg[imgI];

			int bmpI = (x + y * PC_SIZE) * 4;
			if (x0 <= imgX && imgX <= x1 && y0 <= imgY && imgY <= y1 && z0 <= imgZ && imgZ <= z1)
			{
				byte c = (byte)(255.0 * min(1, max(0, (imgV - vMin) / (vMax - vMin))));
				bmpbits[bmpI + 0] = bmpbits[bmpI + 1] = bmpbits[bmpI + 2] = c;
			}
			else {
				bmpbits[bmpI + 0] = 192; bmpbits[bmpI + 1] = bmpbits[bmpI + 2] = 0;
			}
		}
	}

	pcDC->BitBlt(1, 1, PC_SIZE - 2, PC_SIZE - 2, &cbmpDC, 0, 0, SRCCOPY);


	//解放
	cbmpDC.SelectObject(oldBmp);
	DeleteDC(cbmpDC);
	DeleteObject(hbmp);
	pcWnd->ReleaseDC(pcDC);
}
示例#20
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;
		}
	}
}
示例#21
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;
}