BOOL COXHistoryCombo::SetAutoPersistent(LPCTSTR pszValueName, 
										LPCTSTR pszCompany /* = NULL */, 
										LPCTSTR pszApplication /* = NULL */)
{
	ASSERT_VALID(this);

	BOOL bSuccess = TRUE;
	if (m_hWnd != NULL)
	{
		// Control is already created, restore persistent values now
		bSuccess = RestoreContents(pszValueName, pszCompany, pszApplication);
	}
	if (bSuccess)
	{
		// Only set the new values if the previous save succeeded
		m_bAutoPersistent = TRUE;
		m_sAutoPersistentCompany = pszCompany;
		m_sAutoPersistentApplication = pszApplication;
		m_sAutoPersistentValueName = pszValueName;
	}
	else
	{
		TRACE0("COXHistoryCombo::SetAutoPersistent : Failed to save the current contents, failing\n");
	}

	ASSERT_VALID(this);

	return bSuccess;
}
void COXHistoryCombo::InitCombo(CWnd* pParentWnd /* = NULL */)
{
	ASSERT_VALID(this);

#if defined (_WINDLL)
#if defined (_AFXDLL)
	AFX_MANAGE_STATE(AfxGetAppModuleState());
#else
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif
#endif

	// Create a toolbar as sibling of this control
	// ... Invisible by default, we will show it when the correct dimensions are knwon
	//     in PositionToolbar
	// ... Get the parent window if none was specified
	if (pParentWnd == NULL)
	{
		pParentWnd = GetParent();
	}
	ASSERT(pParentWnd != NULL);

	// ... Toolbar should have been constructed, but not created yet
	ASSERT(m_pToolbar!=NULL);
	ASSERT(m_pToolbar->m_hWnd==NULL);
	VERIFY(m_pToolbar->Create(pParentWnd, WS_CHILD | CBRS_TOOLTIPS));

	m_pToolbar->SetWindowPos( &wndTop, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE );
	SetWindowPos( &wndTop, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE );

	// Set the recipient for notifications messages to this window
	// (This will not become the actual owner : see also COXHistoryCombo::OnDestroy)
	m_pToolbar->SetOwner(this);
	
	RefreshToolbar();

#ifdef _DEBUG
	// Check the styles of the control
	if ((GetStyle() & CBS_AUTOHSCROLL) != CBS_AUTOHSCROLL)
		TRACE0("COXHistoryCombo::InitCombo : Control does not have the CBS_AUTOHSCROLL style, text may be truncated\n");
	if ((GetStyle() & CBS_SORT) == CBS_SORT)
		TRACE0("COXHistoryCombo::InitCombo : Control has the CBS_SORT style, new items will not be added at the top\n");
#endif // _DEBUG

	// Start auto persistence if necessary
	if (m_bAutoPersistent)
	{
		RestoreContents(m_sAutoPersistentValueName, m_sAutoPersistentCompany, 
			m_sAutoPersistentApplication);
	}

	ASSERT_VALID(this);
}
Example #3
0
flag VLL_Sep::EvalPressureSens()
  {
  ExtraH2oSettled=0.0;
//  SetVLEMixFrac(H2oSettled);

  double BigDiff=0.0;

  // Must be closed and have contents
  if (!Contents.Closed() || Contents.Mass()< 1.0e-6)
    {
    ZeroVLSensitivities(0);
    return True;
    }

  Contents.SetHoldVentExpand();
  ContStartInfo Start(Contents);

//  ContStartInfo Start(C);
  // Vapour Sensitivity
  double QMassV=1.0;
  double DeltaFrac=Range(1.0e-6, 0.1*Max(1.0, Start.MassV)/NZ(fabs(QMassV)), 1.0);
  Contents.AddM(Contents, som_Vap, DeltaFrac);
  double AvgPSensV=(Contents.Press()-Start.Pres)/DeltaFrac;
  RestoreContents(Contents, Start);

  // Liquid Sensitivity
  double QMassL=1.0;
  DeltaFrac=Range(1.0e-6, 0.1*Max(1.0, Start.MassL)/NZ(fabs(QMassL)), 1.0);
  Contents.AddM(Contents, som_SL, DeltaFrac);
  double AvgPSensL=(Contents.Press()-Start.Pres)/DeltaFrac;
  RestoreContents(Contents, Start);

  SetEquilibratingV2L(0, Contents, Start);
  //SetVLSensitivities(0, Contents, Start);
  SetStaticHeadSensitivities(0, Contents, Start);
  // Flash to Equilibrium


  ContStartInfo Equil(Contents);

  double DeltaMass, Mv0, Mv1, P0, P1;
  JoinRec & J=Joins[0];
  for (int c=0; c<J.NConns(); c++)
    {
    int i=J.IONo(c);
    SpConduit &Cd=*IOConduit(i);

    double XH2OScl;
    if (IOId_Self(i)==VLLIO_boot)
      XH2OScl=1.0;
    else if (IO_In(i))
      XH2OScl=1.0-H2ORemEff;
    else
      XH2OScl=0.0;

    // Transfer to retain equil due to movement of vapour
    RestoreContents(Contents, Equil);

    DeltaMass=Max(1.0e-6, 0.001*Equil.MassV);
    P0=Contents.Press();
    Contents.AddM(Cd, som_Vap, DeltaMass);
    P1=Contents.Press();
    double PSensV=(fabs(P1-P0)>1.0e-6) ? (P1-P0)/DeltaMass : AvgPSensV;

    Mv0=Contents.Mass(som_Vap);
    ExtraH2oSettled=XH2OScl*Cd.Qm(Steam())*DeltaMass/GTZ(Cd.QMass(som_Vap));
    ConvergeStates();
    Mv1=Contents.Mass(som_Vap);
    double V2LQVFrac=(Mv0-Mv1)/DeltaMass;

    // Transfer to retain equil due to movement of liquor
    RestoreContents(Contents, Equil);

    DeltaMass=Max(1.0e-6, 0.001*Equil.MassL);
    P0=Contents.Press();
    Contents.AddM(Cd, som_SL, DeltaMass);
    P1=Contents.Press();
    //double PSensL=(P1-P0)/DeltaMass;
    double PSensL=(fabs(P1-P0)>1.0e-6) ? (P1-P0)/DeltaMass : AvgPSensL;

    Mv0=Contents.Mass(som_Vap);
    ExtraH2oSettled=XH2OScl*Cd.Qm(Water())*DeltaMass/GTZ(Cd.QMass(som_Liq));
    ConvergeStates();
    Mv1=Contents.Mass(som_Vap);

    double V2LQLFrac=(Mv0-Mv1)/DeltaMass;

    Set_IO_PSensVL(i, PSensV, PSensL);
    Set_IO_V2LQmFact(i, V2LQVFrac, V2LQLFrac);

//    dbgpln("     V2L  V:%14.6g L:%14.6g  %14.6g %14.6g  %s",
//      V2LQVFrac, V2LQLFrac, XH2OScl, ExtraH2oSettled, Nd_Rmt(i)->FullObjTag());
    }

  RestoreContents(Contents, Start);
  ExtraH2oSettled=0.0;

  Contents.ClrHoldVentExpand();

  return true;//False;
  };