Esempio n. 1
0
CRunMap::CRunMap(CWnd* pParent /*=NULL*/)
	: CDialog(CRunMap::IDD, pParent)
{
	m_bSwitchMode = FALSE;

	//{{AFX_DATA_INIT(CRunMap)
	m_iVis = -1;
	m_bNoQuake = FALSE;
	m_strQuakeParms = _T("");
	m_bSaveVisiblesOnly = FALSE;
	m_iLight = -1;
	m_iCSG = -1;
	m_iQBSP = -1;
	//}}AFX_DATA_INIT

	// read from ini
	CWinApp *App = AfxGetApp();
	m_iCSG = App->GetProfileInt(pszSection, "CSG", 0);
	m_iQBSP = App->GetProfileInt(pszSection, "QBSP", 0);

	// The onlyents option was moved to the CSG setting, so don't allow it for BSP.
	if (m_iQBSP > 1)
	{
		m_iQBSP = 1;
	}

	m_iVis = App->GetProfileInt(pszSection, "Vis", 0);
	m_iLight = App->GetProfileInt(pszSection, "Light", 0);
	m_bNoQuake = App->GetProfileInt(pszSection, "No Game", 0);
	m_strQuakeParms = App->GetProfileString(pszSection, "Game Parms", "");
}
Esempio n. 2
0
void ImageDialog::OnBnClickedBrowseAVI()
{
    CWinApp* theApp = AfxGetApp();

    char buffer[MAX_PATH];
    string lastSave;
    lastSave = theApp->GetProfileString("Last Config", "lastSave");
    int trim = lastSave.rfind("\\");
    lastSave = lastSave.substr(0, trim);

    buffer[0] = '\0';
    OPENFILENAME browse;
    ZeroMemory(&browse, sizeof(browse));
    browse.lStructSize = sizeof(browse);
    browse.hwndOwner = this->m_hWnd;
    browse.lpstrFile = buffer;
    browse.nMaxFile = sizeof(buffer);
    browse.lpstrFilter = "AVI Files\0*.avi\0";
    browse.nFilterIndex = 1;
    browse.lpstrTitle = "Save to AVI File";
    browse.lpstrFileTitle = 0;
    browse.lpstrInitialDir = lastSave.c_str();
    browse.lpstrDefExt = "avi";
    browse.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;

    if (GetSaveFileName(&browse) != 0)
    {
        AVIFilename.SetWindowText(buffer);
        SetAviOptions();
        aviwriter->OpenFile();
        compressionButton.EnableWindow(TRUE);
    }
}
Esempio n. 3
0
void COptionsPage::OnButtonSource(void)
{
	CString strPrompt;

	strPrompt.LoadString(IDS_CHOOSE_SOURCE);
	CFolderDialog dlgFolder(strPrompt, m_strSource, this, BIF_NEWDIALOGSTYLE);
	if (dlgFolder.DoModal() == IDOK)
	{
		m_strSource = dlgFolder.GetFolderPath();
		SetDlgItemText(IDC_EDIT_SOURCE, m_strSource);
#if (_MFC_VER < 0x0700)
		CWinApp* pApp = AfxGetApp();
		ASSERT_VALID(pApp);
		if ((m_timeWrite = pApp->GetProfileInt(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#else
		CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
		ASSERT_VALID(pApp);
		if ((m_timeWrite = pApp->GetProfileTime(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#endif   // _MFC_VER
		{
			m_dtpWrite.SetTime(&m_timeWrite);
		}
		CString strDefTarget = m_strSource + _T(".Update");
		SetDlgItemText(IDC_EDIT_TARGET, pApp->GetProfileString(SZ_REGK_TARGETS, m_strSource, strDefTarget));
	}
}
Esempio n. 4
0
/////////////////////////////////////////////////////////////////////////////
// Create font from info in the application profile.  Reads info in the form
// facename, ptsize, weight, italic
//
zBOOL
ZFontUI::GetProfileFont( zCPCHAR cpcKey,
                         zCPCHAR cpcVal,
                         CFont&  font,
                         CDC     *pDC )
{
   CWinApp *pApp = AfxGetApp( );
   ASSERT_VALID( pApp );
   CString zs = pApp->GetProfileString( cpcKey, cpcVal );
   if ( zs.IsEmpty( ) )
      return( FALSE );

   LOGFONT lf;
   zmemset( &lf, 0, sizeof( LOGFONT ) );
   lf.lfCharSet = DEFAULT_CHARSET;
   int bItalic;
   int nPtSize;

   // scanf is overkill, but I'm lazy
   if ( sscanf( (zCPCHAR) zs, "%[a-zA-Z ],%d,%d,%d",
                  lf.lfFaceName, &nPtSize, &lf.lfWeight, &bItalic ) != 4 )
   {
      return( FALSE );
   }

   lf.lfHeight = MulDiv( -nPtSize,  // convert ptsize to logical units
       ::GetDeviceCaps( pDC ? pDC->m_hDC : ::GetDC( 0 ), LOGPIXELSY ), 72 );

   lf.lfItalic = bItalic;     // because lf.lfItalic is a BYTE
   font.DeleteObject( );      // bye
   return( font.CreateFontIndirect( &lf ) );
}
Esempio n. 5
0
// removes all the items from the history list, and optionally deletes
// the registry items. Note that if the history list is generated from
// a CRecentFileList, then registry entries will not be deleted
void CHistoryCombo::ClearHistory(BOOL bDeleteRegistryEntries/*=TRUE*/)
{
	ResetContent();
	if (! m_sSection.IsEmpty() && bDeleteRegistryEntries)
	{
		// remove profile entries
		CWinApp* pApp = AfxGetApp();
		ASSERT(pApp);
		CString sKey;

		for (int n = 0; n < 1000/* prevent runaway*/; n++)
		{
			sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n);
			CString sText = pApp->GetProfileString(m_sSection, sKey);
			if (sText.IsEmpty())
				break;
			pApp->WriteProfileString(m_sSection, sKey, NULL); // remove entry
		}

		if (! m_sKeyCurItem.IsEmpty())
			sKey = m_sKeyCurItem;
		else if (m_sKeyPrefix.IsEmpty())
			sKey = _T("Last");
		else
			sKey = m_sKeyPrefix;

		pApp->WriteProfileString(m_sSection, sKey, NULL);
	}
}
Esempio n. 6
0
void ImageDialog::OnBnClickedBrowse()
{
    CWinApp* theApp = AfxGetApp();

    char buffer[MAX_PATH];
    string lastSave;
    lastSave = theApp->GetProfileString("Last Config", "lastSave");
    int trim = lastSave.rfind("\\");
    lastSave = lastSave.substr(0, trim);

    buffer[0] = '\0';
    OPENFILENAME browse;
    ZeroMemory(&browse, sizeof(browse));
    browse.lStructSize = sizeof(browse);
    browse.hwndOwner = this->m_hWnd;
    browse.lpstrFile = buffer;
    browse.nMaxFile = sizeof(buffer);
    browse.lpstrFilter = "All Files\0*.*\0";
    browse.nFilterIndex = 1;
    browse.lpstrTitle = "Select Save Path/Filename";
    browse.lpstrFileTitle = 0;
    browse.lpstrInitialDir = lastSave.c_str();
    browse.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

    if (GetSaveFileName(&browse) != 0)
    {
        string file(buffer);
        pngwriter->SetFileName(file);
        filePath.SetWindowText(pngwriter->GetFileName().c_str());
    }
}
// MmView message handlers
int MmView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_timer_id = SetTimer(1, 500, 0);

	// Set static handle
	s_hwnd = GetSafeHwnd();
	ModifyStyle(0, WS_CLIPCHILDREN); // reduce flicker
#ifdef WITH_SPLASH_SCREEN
	LocateWelcomeDoc(TEXT(WITH_SPLASH_SCREEN));
#else
	if(LocateWelcomeDoc(TEXT("..\\..\\Extras\\Welcome\\Welcome.smil")) ||
		LocateWelcomeDoc(TEXT("Extras\\Welcome\\Welcome.smil")) ||
		LocateWelcomeDoc(TEXT("Welcome.smil"))){;}
#endif

#ifdef WITH_SPLASH_SCREEN
	PostMessage(WM_COMMAND, ID_HELP_WELCOME);
#else
	CWinApp* pApp = AfxGetApp();
	CString val = pApp->GetProfileString(_T("Settings"), _T("Welcome"));
	if(val.IsEmpty()) {
		// first time; write the string and play welcome
		pApp->WriteProfileString(_T("Settings"), _T("Welcome"),  _T("1"));
		if(!m_welcomeDocFilename.IsEmpty())
			PostMessage(WM_COMMAND, ID_HELP_WELCOME);
	}
#endif
	return 0;
}
Esempio n. 8
0
CString
TestRunnerModel::loadHistoryEntry( int idx )
{
  CWinApp *app = AfxGetApp();
  ASSERT( app != NULL );

  return app->GetProfileString( _T("CppUnit"), getHistoryEntryName( idx ) );
}
Esempio n. 9
0
void CChatViewerFont::init()
{
	CWinApp* app = AfxGetApp();
	name         = app->GetProfileString( "Style\\Font", "name", name.c_str() );
	size         = app->GetProfileInt( "Style\\Font", "size", size );
	codepage     = app->GetProfileInt( "Style\\Font", "codepage", codepage );
	characterSet = app->GetProfileInt( "Style\\Font", "characterSet", characterSet );
}
Esempio n. 10
0
// saves the history to the profile specified when calling LoadHistory
// if no profile information (ie LoadHistory() wasn't called with it) then
// this function does nothing
void CHistoryCombo::SaveHistory(BOOL bAddCurrentItemToHistory/*=TRUE*/)
{
	TRACE(_T("in CHistoryCombo::SaveHistory\n"));

  if (m_sSection.IsEmpty())
    return;

  CWinApp* pApp = AfxGetApp();
  ASSERT(pApp);

  if (bAddCurrentItemToHistory)
  {
    CString sCurItem;
    GetWindowText(sCurItem);
    // trim it, so we items which differ only by a leading/trailing space
    sCurItem.TrimLeft();
    sCurItem.TrimRight();
    if (! sCurItem.IsEmpty())
      AddString(sCurItem);
  }

  // save history to info cached earlier
  int nMax = min(GetCount(), m_nMaxHistoryItems + 1);
  int n = 0;
  for (n = 0; n < nMax; n++)
  {
    CString sKey;
    sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n);
    CString sText;
    GetLBText(n, sText);
    pApp->WriteProfileString(m_sSection, sKey, sText);
	//TRACE(_T("m_sSection=%s  sKey=%s  sText=%s\n"), m_sSection, sKey, sText);
  }
  // remove redundant items
  for (n = nMax; n < 1000/* prevent runaway*/; n++)
  {
    CString sKey;
    sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n);
	TRACE(_T("m_sKeyPrefix=%s\n"), m_sKeyPrefix);
    CString sText = pApp->GetProfileString(m_sSection, sKey);
    if (sText.IsEmpty())
      break;
    pApp->WriteProfileString(m_sSection, sKey, NULL); // remove entry
  }
  if (m_bSaveRestoreLastCurrent)
  {
    CString sText;
    GetWindowText(sText);
    CString sKey;
    if (!m_sKeyCurItem.IsEmpty())
      sKey = m_sKeyCurItem;
    else if (m_sKeyPrefix.IsEmpty())
      sKey = _T("Last");
    else
      sKey = m_sKeyPrefix;
    pApp->WriteProfileString(m_sSection, sKey, sText);
  }
}
Esempio n. 11
0
bool CEsmOptions::ReadFromRegistry (void) {
  CWinApp* pApp = AfxGetApp();
  CString  Buffer;
  bool	   Result;

	/* General options */
  Buffer = pApp->GetProfileString(ESMSCR_REGSEC_GENERAL, ESMSCR_REGENTRY_AUTHORNAME, NULL);
  SetAuthorName(Buffer);

  Buffer = pApp->GetProfileString(ESMSCR_REGSEC_GENERAL, ESMSCR_REGENTRY_DATAPATH, NULL);
  SetDataPath(Buffer);
  TerminatePath(m_DataPath);

  if (Buffer.IsEmpty()) {
    FindMWRegistryPath();
  }
  else {
    SetMWDataPath(Buffer);
  }

  m_BackupSaves    = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_BACKUPSAVES,    m_BackupSaves) != 0);
  m_AllowExtFuncs  = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_ALLOWEXTFUNCS,  m_AllowExtFuncs) != 0);
  m_StrictIDs      = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_STRICTIDS,      m_StrictIDs) != 0);
  m_AllowBloodmoon = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_ALLOWBLOODMOON, m_AllowBloodmoon) != 0);
  m_AllowTribunal  = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_ALLOWTRIBUNAL,  m_AllowTribunal) != 0);

	/* Script options */
  m_ScriptWarnLevel    = pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_WARNLEVEL,     m_ScriptWarnLevel);
  m_NoScriptFormat     = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_NOSCRFORMAT,  m_NoScriptFormat) != 0);
  m_UseExtraFile       = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_USEEXTRAFILE, m_UseExtraFile) != 0);
  m_NoScriptPrompt     = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_NOSCRPROMPT,  m_NoScriptPrompt) != 0);
  m_InitialIndentLevel = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_INITIALINDENTLEVEL,  m_InitialIndentLevel) != 0);
  m_IndentCommentsMore = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_INDENTCOMMENTSMORE,  m_IndentCommentsMore) != 0);
  m_ScriptFormatType   = pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT,  ESMSCR_REGENTRY_SCRFORMAT,    m_ScriptFormatType);

  Buffer = pApp->GetProfileString(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_EXTRAFILE, m_ExtraFile);
  SetExtraFile(Buffer);

  Buffer = pApp->GetProfileString(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_SCRIPTINDENTSTRING, m_ScriptIndentString);
  SetScriptIndentString(Buffer);

	/* Script user format */
  Result = m_UserScriptOptions.ReadFromRegistry();
  return (Result);
 }
Esempio n. 12
0
bool CRegistrationDlg::testRegistration( bool initializingDialog ) 
{
	if( initializingDialog )
	{
		// Get the app.
		CWinApp * pApp = AfxGetApp( );
		if( ! pApp )
			return false;

		// Read all the settings.
		m_emailAddress	  = pApp->GetProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_EMAIL_ADDRESS );
		m_registrationKey = pApp->GetProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_REGISTRATION_KEY );
	}
	else
	{
		UpdateData( );
	}

	// Get the expected registration key from this email address.
	CString generatedKey;
	CRegistrationHelper registrationHelper;
	registrationHelper.generateRegistrationKey( m_emailAddress, generatedKey );

	// Does the key match?
	if( generatedKey == m_registrationKey )
	{
		// Get the app.
		CWinApp * pApp = AfxGetApp( );
		if( ! pApp )
			return false;

		// Save the settings for the future.
		pApp->WriteProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_EMAIL_ADDRESS, m_emailAddress );
		pApp->WriteProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_REGISTRATION_KEY, m_registrationKey );

		// Update us and the drawing.
		UpdateData( FALSE );
		m_pG3DCallback->updateDrawing( );

		return true;
	}

	return false;
}
Esempio n. 13
0
// loads the history from the specified profile area, and returns the 
// text selected
// the profile area is kept so that in doesn't need to specified again
// when saving the history
CString CHistoryCombo::LoadHistory(LPCTSTR lpszSection, LPCTSTR lpszKeyPrefix, 
				   BOOL bSaveRestoreLastCurrent/*=TRUE*/, 
				   LPCTSTR lpszKeyCurItem/*=NULL*/)
{
  if (lpszSection == NULL || lpszKeyPrefix == NULL || *lpszSection == '\0')
    return "";

  m_sSection = lpszSection;
  m_sKeyPrefix = lpszKeyPrefix;
  m_sKeyCurItem = lpszKeyCurItem == NULL ? "" : lpszKeyCurItem;
  m_bSaveRestoreLastCurrent = bSaveRestoreLastCurrent;
  CWinApp* pApp = AfxGetApp();

  int n = 0;
  CString sText;
  do
  {
    CString sKey;
    sKey.Format("%s%d", m_sKeyPrefix, n++);
    sText = pApp->GetProfileString(m_sSection, sKey);
    if (!sText.IsEmpty())
      CComboBox::AddString(sText);
  }while (!sText.IsEmpty());
  if (m_bSaveRestoreLastCurrent)
  {
    CString sKey;
    if (!m_sKeyCurItem.IsEmpty())
      sKey = m_sKeyCurItem;
    else if (m_sKeyPrefix.IsEmpty())
      sKey = "Last";
    else
      sKey = m_sKeyPrefix;
    sText = pApp->GetProfileString(m_sSection, sKey);
    if (!sText.IsEmpty())
    {
      int nIndex = FindStringExact(-1, sText);
      if (nIndex != -1)
	SetCurSel(nIndex);
      else if (GetStyle() & CBS_DROPDOWN)
	SetWindowText(sText);
    }
  }
  return sText;
}
Esempio n. 14
0
void FindDialog::Help()
{
	CString str;
	CWinApp *app;

	app = AfxGetApp();
	str = app->GetProfileString("help", "path");
	str = str + "\\find_dialog.html";
	ShellExecute(m_hWnd, "open", str, NULL, NULL, SW_SHOWNORMAL);
}
Esempio n. 15
0
void AppSetting:: loadApplicationSetting()
{
	CWinApp* pApp = AfxGetApp();

	showNavigation = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_SHOW_NAVIGATION, 1) != 0;//0 -> false; 1 -> true

	bShowHelpText = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_DISPLAY_TEXT, 1) != 0;
	bShowAxis = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_DISPLAY_AXIS, 1) != 0;
	objPath = pApp->GetProfileString(REGKEY_APP_NAME, REGKEY_OBJECT_PATH);
	simulationDataPath = pApp->GetProfileString(REGKEY_APP_NAME, REGKEY_SIM_DATA_PATH);

	CHAR my_documents[MAX_PATH];
	HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
	CString documentPath(my_documents);
	documentPath.AppendFormat("\\%s", SETTING_NAME);
	if (GetFileAttributes(documentPath) == INVALID_FILE_ATTRIBUTES)
	{
		CreateDirectory(documentPath,NULL);
	}
}
void CModelBrowser::SaveLoadSettings( bool bSave )
{
	CString	str;
	CRect	rect;
	CWinApp	*pApp = AfxGetApp();

	if ( bSave )
	{
		GetWindowRect(rect);
		str.Format("%d %d %d %d", rect.left, rect.top, rect.right, rect.bottom);
		pApp->WriteProfileString(pszIniSection, "Position", str);
		pApp->WriteProfileString(pszIniSection, "Filter", m_pPicker->GetFilter() );
	}
	else
	{
		str = pApp->GetProfileString(pszIniSection, "Position");

		if (!str.IsEmpty())
		{
			sscanf(str, "%d %d %d %d", &rect.left, &rect.top, &rect.right, &rect.bottom);

			if (rect.left < 0)
			{
				ShowWindow(SW_SHOWMAXIMIZED);
			}
			else
			{
				MoveWindow(rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, FALSE);
			}

			Resize();
		}

		str = pApp->GetProfileString(pszIniSection, "Filter");

		if (!str.IsEmpty())
		{
			m_pPicker->SetFilter( str );
		}
	}
}
void CSTWSelectTmplPage::OnButtonDelete() 
{
	if (AfxMessageBox (IDS_CONFIRM_DELETETEMPLATE, MB_ICONQUESTION | MB_YESNO) == IDYES)
	{
		CString strTemplate;
		m_Combo.GetWindowText (strTemplate);
		if (strTemplate.IsEmpty ())
			return;

		// get the number of templates
		CWinApp* pApp = AfxGetApp ();
		int nCount = pApp->GetProfileInt ("Templates", "Count", 0);
		CString s, strName;
		bool bMove = false;

		// delete from the list
		for (int i = 1; i <= nCount; i++)
		{
			if (bMove)
			{
				s.Format ("%d", i);
				strName = pApp->GetProfileString ("Templates", s);
				s.Format ("%d", i - 1);
				pApp->WriteProfileString ("Templates", s, strName);
			}

			s.Format ("%d", i);
			if (pApp->GetProfileString ("Templates", s) == strTemplate)
				bMove = true;
		}

		pApp->WriteProfileInt ("Templates", "Count", nCount - 1);

		// delete the template's settings
		DWORD dwRet = SHDeleteKey (HKEY_CURRENT_USER, "Software\\CdCoverCreator\\Templates\\" + strTemplate);

		// remove from the combo box
		m_Combo.DeleteString (m_Combo.FindStringExact (-1, strTemplate));
	}
}
void CWinHTTrackApp::OnBrowseWebsites()
{
  CString st=dialog0->GetBasePath();

  if (st.GetLength()<=1) {
    CString strSection       = "DefaultValues";    
    CWinApp* pApp = AfxGetApp();
    st = pApp->GetProfileString(strSection, "BasePath");
    st += "\\";
  }

  st+="index.html";
  ShellExecute(NULL,"open",st,"","",SW_RESTORE);	
}
void CXTPRecentFileList::ReadList()
{
	ASSERT(m_arrNames != NULL);
	ASSERT(!m_strSectionName.IsEmpty());
	ASSERT(!m_strEntryFormat.IsEmpty());

	LPTSTR pszEntry = new TCHAR[max(20, m_strEntryFormat.GetLength() + 7)];
	CWinApp* pApp = AfxGetApp();

	for (int iMRU = 0; iMRU < m_nSize; iMRU++)
	{
		CMDTARGET_RELEASE(m_pItems[iMRU]);

		wsprintf(pszEntry, m_strEntryFormat, iMRU + 1);
		m_arrNames[iMRU] = pApp->GetProfileString(m_strSectionName, pszEntry, _T(""));

		if (!m_arrNames[iMRU].IsEmpty())
		{
			m_pItems[iMRU] = new CXTPRecentFileListItem(this);

			wsprintf(pszEntry, _T("Pinned%d"), iMRU + 1);
			m_pItems[iMRU]->m_bPinned = pApp->GetProfileInt(m_strSectionName, pszEntry, FALSE);

			wsprintf(pszEntry, _T("IconId%d"), iMRU + 1);
			m_pItems[iMRU]->m_nIconId = pApp->GetProfileInt(m_strSectionName, pszEntry, -1);

			wsprintf(pszEntry, _T("Caption%d"), iMRU + 1);
			m_pItems[iMRU]->m_strCaption = pApp->GetProfileString(m_strSectionName, pszEntry, _T(""));

			wsprintf(pszEntry, _T("Tag%d"), iMRU + 1);
			m_pItems[iMRU]->m_strTag = pApp->GetProfileString(m_strSectionName, pszEntry, _T(""));

			m_pItems[iMRU]->m_strPathName = m_arrNames[iMRU];
		}
	}
	delete[] pszEntry;
}
Esempio n. 20
0
BOOL CServerSettings::LoadServerFromRegistry(const char* ctx)
{
	CWinApp* pApp = AfxGetApp();
	CString S;
	//int k, nSize;
	//char szKey[32];
	TCHAR szValue[256];

	int   nDefault_Port                       = 119;
	char *szDefault_Server                   = m_szServerName;
	char *szDefault_Username                 = m_szUsername;
	char *szDefault_Password                 = m_szPassword;

	m_nServerPort = pApp->GetProfileInt(ctx,"NNTP_Port",	nDefault_Port);

	S = pApp->GetProfileString(ctx,"Server", szDefault_Server);
	if((S.GetLength() > 2*132) || (S.GetLength() == 0)) S = szDefault_Server;
	strcpy(m_szServerName, (LPCTSTR) S);

	m_bRequireLogin = pApp->GetProfileInt(ctx,"Login", FALSE);
	if((m_bRequireLogin != TRUE) && (m_bRequireLogin != FALSE)) m_bRequireLogin = FALSE;

	m_nConnections = pApp->GetProfileInt(ctx,"Connections", 1);
	if(m_nConnections <1) m_nConnections = 1; else if (m_nConnections>NPOSTTHREAD) m_nConnections=NPOSTTHREAD;

	S = pApp->GetProfileString(ctx,"User", szDefault_Username);
	if((S.GetLength() > 132) || (S.GetLength() == 0))  S = szDefault_Username;
	strcpy(m_szUsername, (LPCTSTR) S);

	S = pApp->GetProfileString(ctx,"Pass", szDefault_Password);
	if((S.GetLength() > 132) || (S.GetLength() == 0)) S = szDefault_Password;
	strcpy(szValue, (LPCTSTR) S);
	::CM_UnMixString(szValue, m_szPassword, 132);
	TRACE("PASSWORD READ: from '%s' TO '%s'\n", szValue, m_szPassword);
	return TRUE;
}
Esempio n. 21
0
static void GetProfileFont(LPCTSTR szSec, LOGFONT* plf)
{
	CWinApp* pApp = AfxGetApp();
	plf->lfHeight = pApp->GetProfileInt(szSec, szHeight, 0);
	if (plf->lfHeight != 0)
	{
		plf->lfWeight = pApp->GetProfileInt(szSec, szWeight, 0);
		plf->lfItalic = (BYTE)pApp->GetProfileInt(szSec, szItalic, 0);
		plf->lfUnderline = (BYTE)pApp->GetProfileInt(szSec, szUnderline, 0);
		plf->lfPitchAndFamily = (BYTE)pApp->GetProfileInt(szSec, szPitchAndFamily, 0);
		plf->lfCharSet = (BYTE)pApp->GetProfileInt(szSec, szCharSet, DEFAULT_CHARSET);
		CString strFont = pApp->GetProfileString(szSec, szFaceName, szSystem);
		_tcsncpy_s((TCHAR*)plf->lfFaceName, LF_FACESIZE, strFont, _TRUNCATE);
		plf->lfFaceName[sizeof plf->lfFaceName-1] = 0;
	}
}
Esempio n. 22
0
CTipDlg::CTipDlg(CWnd* pParent /*=NULL*/)
	: CDialog(IDD_TIP, pParent)
{
	//{{AFX_DATA_INIT(CTipDlg)
	m_bStartup = TRUE;
	//}}AFX_DATA_INIT

	// We need to find out what the startup and file position parameters are
	// If startup does not exist, we assume that the Tips on startup is checked TRUE.
	CWinApp* pApp = AfxGetApp();
	m_bStartup = !pApp->GetProfileInt(szSection, szIntStartup, 0);
	UINT iFilePos = pApp->GetProfileInt(szSection, szIntFilePos, 0);

	// Now try to open the tips file
	m_pStream = fopen("Tips.txt", "r");
	if (m_pStream == NULL)
	{
		m_strTip.LoadString(CG_IDS_FILE_ABSENT);
		return;
	}

	// If the timestamp in the INI file is different from the timestamp of
	// the tips file, then we know that the tips file has been modified
	// Reset the file position to 0 and write the latest timestamp to the
	// ini file
	struct _stat buf;
	_fstat(_fileno(m_pStream), &buf);
	CString strCurrentTime = ctime(&buf.st_ctime);
	strCurrentTime.TrimRight();
	CString strStoredTime = 
		pApp->GetProfileString(szSection, szTimeStamp, NULL);
	if (strCurrentTime != strStoredTime) 
	{
		iFilePos = 0;
		pApp->WriteProfileString(szSection, szTimeStamp, strCurrentTime);
	}

	if (fseek(m_pStream, iFilePos, SEEK_SET) != 0) 
	{
		AfxMessageBox(CG_IDP_FILE_CORRUPT);
	}
	else 
	{
		GetNextTipString(m_strTip);
	}
}
bool CEsmScriptOptions::ReadRegFont (void) {
  CWinApp* pApp = AfxGetApp();
  CString  FontName = _T("FixedSys");
  int	   FontSize   = 8;
  int	   FontBold   = FW_NORMAL;
  int	   FontItalic = FALSE;
  
	/* Read the font options from the registry */
  FontSize   = pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_FONTSIZE, FontSize);
  FontBold   = pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_FONTBOLD, FontBold);
  FontItalic = pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_FONTITALIC, FontItalic);
  FontName   = pApp->GetProfileString(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_FONTNAME, FontName);

	/* Create the font object */
  m_TextFont.Detach();
  CFONT_CREATE(m_TextFont, FontSize, FontBold, FontItalic, FontName);

  return (true);
 }
Esempio n. 24
0
BOOL CNewProj::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
  SetIcon(httrack_icon,false);
  SetIcon(httrack_icon,true);
  EnableToolTips(true);     // TOOL TIPS
  SetForegroundWindow();   // yop en premier plan!

  // disabled
  OnChangeprojname();

  // Patcher l'interface pour les Français ;-)
  if (LANG_T(-1)) {    // Patcher en français
    SetWindowTextCP(this,  LANG(LANG_S10));
    // SetDlgItemTextCP(this, IDOK,LANG(LANG_NEXT )); // "SUIVANT ->");
    // SetDlgItemTextCP(this, IDCANCEL,LANG(LANG_QUIT));  // exit 
    SetDlgItemTextCP(this, IDC_STATIC_projname,LANG(LANG_S11));
    SetDlgItemTextCP(this, IDC_STATIC_basepath,LANG(LANG_S12));
    SetDlgItemTextCP(this, IDC_STATIC_projcateg,LANG(LANG_S13));
    //SetDlgItemTextCP(this, IDC_STATIC_updtcontinue,LANG(LANG_S13));
  }
  
  CString strSection       = "DefaultValues";    
  CWinApp* pApp = AfxGetApp();
  CString st;

  st = pApp->GetProfileString(strSection, "BasePath");
  if (m_projpath.GetLength()==0) {
    if (st != "")
      SetDlgItemTextCP(this, IDC_projpath,st);    
    else
      SetDlgItemTextCP(this, IDC_projpath,LANG(LANG_S20));    
  }

  return TRUE;
}
Esempio n. 25
0
BOOL PSGame::Load(CString strType)
{
	PSIOFile f;
	CFileException e;	

	// If the whole path is in strType, load the game. If not, build the path from the registry.
	char* path_buffer = strType.GetBuffer(_MAX_PATH);
	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];
	_splitpath( path_buffer, drive, dir, fname, ext );
	if (!strcmp(ext, ""))
	{
		CString strSection       = "Directories";
		CString strStringItem    = "Current";

		CWinApp* pApp = AfxGetApp();

		CString strValue;
		strValue = pApp->GetProfileString(strSection, strStringItem);
		strValue += strType + "._ps";
		strType = strValue;
	}
	f.Open(strType, CFile::modeRead, &e);
	if (e.m_cause)
	{
		CString strMessage;
		strMessage.Format("%s%s%s", "The file ", strType, " wasn't found.");
		AfxMessageBox(strMessage, MB_ICONEXCLAMATION);
		return FALSE;
	}
	CString strIn;

	f.ReadString(strIn);
	f.ReadString(strIn);
	int nNrOfPowers = f.ReadInt();
	// Bogus Power
	PSPower* pPower = new PSPower;
	TG.AddPower(pPower);

	for (int i = 0; i < nNrOfPowers; i++)
	{
		pPower = new PSPower;
		TG.AddPower(pPower);
		f.ReadString(pPower->m_strName);
		pPower->SetColor((COLORREF)(f.ReadInt()));
	}

	f.ReadString(strIn);
	if (strIn != "")
	{
		f.Close();
		return FALSE;
	}
	const int nNrOfProvinces = f.ReadInt();
	// Bogus Province
	PSProvince* pProv = new PSProvince;
	TG.AddProvince(pProv);

	for (i = 0; i < nNrOfProvinces; i++)
	{
		f.ReadString(strIn);
		if (strIn.GetLength() != 3)
		{
			f.Close();
			return FALSE;
		}
		pProv = TG.GetProvince(strIn);
		if (!pProv)
		{
			pProv = new PSProvince;
			TG.AddProvince(pProv);
			pProv->m_strName = strIn;
		}
		pProv->SetType((PROVINCE_TYPE)f.ReadInt());
		int nSC = f.ReadInt();
		pProv->SetFlags(nSC);
		if (nSC)
		{
			int nXPos = f.ReadInt();
			pProv->m_SupplySquare.left = nXPos;
			pProv->m_SupplySquare.right = nXPos + SQUAREDIM;
			int nYPos = f.ReadInt();
			pProv->m_SupplySquare.top = nYPos;
			pProv->m_SupplySquare.bottom = nYPos + SQUAREDIM;
		}
		PSCoast* pCoast = new PSCoast(pProv);
		pCoast->m_strName = "Central";
		int nNeighbors = f.ReadInt();
		for (int j = 0; j < nNeighbors; j++)
		{
			f.ReadString(strIn);
			if (strIn.GetLength() != 3)
			{
				f.Close();
				return FALSE;
			}
			PSProvince* pNeigh = TG.GetProvince(strIn);
			if (!pNeigh)
			{
				pNeigh = new PSProvince;
				TG.AddProvince(pNeigh);
				pNeigh->m_strName = strIn;
			}
			pCoast->AddNeighbor(pNeigh);
		}
		pCoast->m_ptDrawUnit.x = f.ReadInt();
		pCoast->m_ptDrawUnit.y = f.ReadInt();

		// Set the polygon.
		int nVertexes = f.ReadInt();
		CPoint* pPt = new CPoint[nVertexes];
		for (j = 0; j < nVertexes; j++)
		{
			(pPt + j)->x = f.ReadInt();
			(pPt + j)->y = f.ReadInt();
			pProv->m_Vertexes.Add(pPt + j);
		}
		pProv->m_poly.CreatePolygonRgn(pPt, nVertexes, ALTERNATE);

		int nBicoastal = f.ReadInt();
		if (nBicoastal)
		{
			for (j = 0; j < 2; j++)
			{
				PSCoast* pCoast = new PSCoast(pProv);
				f.ReadString(pCoast->m_strName);
				int nNeighbors = f.ReadInt();
				for (int k = 0; k < nNeighbors; k++)
				{
					f.ReadString(strIn);
					PSProvince* pNeigh = TG.GetProvince(strIn);
					if (!pNeigh)
					{
						pNeigh = new PSProvince;
						TG.AddProvince(pNeigh);
						pNeigh->m_strName = strIn;
					}
					pCoast->AddNeighbor(pNeigh);
				}
				pCoast->m_ptDrawUnit.x = f.ReadInt();
				pCoast->m_ptDrawUnit.y = f.ReadInt();
			}
		}

		f.ReadString(strIn);
		if (strIn != "")
		{
			f.Close();
			return FALSE;
		}
	}

	// Load first and last year.
	f.ReadString(strIn);
	if (strIn != "Years")
	{
		f.Close();
		return FALSE;
	}
	int nFirst = f.ReadInt();
	int nLast = f.ReadInt();
	if (nLast <= nFirst)
	{
		f.Close();
		return FALSE;
	}
	TG.SetFirstYear(nFirst);
	TG.SetLastYear(nLast);

	f.Close();
	return TRUE;
}
Esempio n. 26
0
BOOL TestRunnerDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	CListCtrl   *listCtrl = (CListCtrl *)GetDlgItem (IDC_LIST);
	CComboBox   *comboBox = (CComboBox *)GetDlgItem (IDC_COMBO_TEST);

	ASSERT (listCtrl);
	ASSERT (comboBox);

	CString title;
	GetWindowText(title);
#if defined(_DEBUG)
	title.Append(" [debug]");
#else
	title.Append(" [release]");
#endif
	SetWindowText(title);

	listCtrl->InsertColumn (0,"Type", LVCFMT_LEFT, 16 + listCtrl->GetStringWidth ("Type"), 1);
	listCtrl->InsertColumn (1,"Name", LVCFMT_LEFT, 16 * listCtrl->GetStringWidth ("X"), 2);
	listCtrl->InsertColumn (2,"Failed Condition", LVCFMT_LEFT, 24 * listCtrl->GetStringWidth ("M"), 3);
	listCtrl->InsertColumn (3,"Line", LVCFMT_LEFT, 16 + listCtrl->GetStringWidth ("0000"), 4);
	listCtrl->InsertColumn (4,"File Name", LVCFMT_LEFT, 36 * listCtrl->GetStringWidth ("M"), 5);

	int numberOfCases = 0;

	CWinApp* pApp = AfxGetApp();
	CString lastTestCS = pApp->GetProfileString("Tests", "lastTest");
	std::string lastTest((LPCSTR) lastTestCS);
	int sel = -1;
	for (std::vector<TestInfo>::iterator it = _tests.begin (); it != _tests.end (); ++it)
	{
		std::string cbName(it->level*4, ' ');
		cbName.append(it->pTest->toString());
		comboBox->AddString (cbName.c_str ());
		if (sel < 0)
		{
			if (lastTest.empty() || lastTest == it->pTest->toString())
			{
				_selectedTest = it->pTest;
				sel = numberOfCases;
			}
		}
		numberOfCases++;
	}

	if (numberOfCases > 0)
	{
		if (sel < 0)
		{
			_selectedTest = _tests[0].pTest;
			sel = 0;
		}
		comboBox->SetCurSel (sel);
	}
	else
	{
		beRunDisabled ();
	}
	CWnd *pProgress = GetDlgItem(IDC_PROGRESS);
	CRect rect;
	pProgress->GetWindowRect(&rect);
	_testsProgress = new ProgressBar (this, rect);

	CButton* autoRunBtn = (CButton*) GetDlgItem(IDC_CHK_AUTORUN);
	autoRunBtn->SetCheck(pApp->GetProfileInt("Tests", "autoRun", BST_UNCHECKED));

	reset ();

	if (autoRunBtn->GetCheck() == BST_CHECKED)
	{
		OnRun();
	}

	return TRUE;  // return TRUE unless you set the focus to a control
					// EXCEPTION: OCX Property Pages should return FALSE
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
BOOL CTextureBrowser::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// Iterate all the active textures for debugging.
	//int nCount = g_Textures.GetActiveTextureCount();
	//for (int nTexture = 0; nTexture < nCount; nTexture++)
	//{
	//	IEditorTexture *pTexture = g_Textures.GetActiveTexture(nTexture);
	//	const char *pszName = pTexture->GetName();
	//	DBG("%d: %s\n", nTexture, pszName);
	//}
	
	m_cSizeList.SubclassDlgItem(IDC_TEXTURESIZE, this);
	m_cFilter.SubclassDlgItem(IDC_FILTER, this);
	m_cKeywords.SubclassDlgItem(IDC_KEYWORDS, this);
	m_cCurName.SubclassDlgItem(IDC_CURNAME, this);
	m_cCurDescription.SubclassDlgItem(IDC_CURDESCRIPTION, this);
	m_cUsed.SubclassDlgItem(IDC_USED, this);
   
	m_FilterOpaque.SubclassDlgItem(IDC_FILTER_OPAQUE, this);
	m_FilterTranslucent.SubclassDlgItem(IDC_FILTER_TRANSLUCENT, this);
	m_FilterSelfIllum.SubclassDlgItem(IDC_FILTER_SELFILLUM, this);
	m_FilterEnvMask.SubclassDlgItem(IDC_FILTER_ENVMASK, this);
	m_ShowErrors.SubclassDlgItem(IDC_SHOW_ERROR, this);

	m_FilterOpaque.SetCheck( true );
	m_FilterTranslucent.SetCheck( true );
	m_FilterSelfIllum.SetCheck( true );
	m_FilterEnvMask.SetCheck( true );
	m_ShowErrors.SetCheck( true );

	//
	// Create CTextureWindow that takes up area of dummy control.
	//
	RECT r;
	GetDlgItem(IDC_BROWSERDUMMY)->GetClientRect(&r);
	m_cTextureWindow.Create(this, r);

	// Show everything initially
	m_cTextureWindow.SetTypeFilter( ~0, true );

	//
	// Add latest history to the filter combo.
	//
	for (int i = 0; i < m_nFilterHistory; i++)
	{
		m_cFilter.AddString(m_FilterHistory[i]);
	}

	//
	// Set the name filter unless one was explicitly specified.
	//
	if (m_szNameFilter[0] == '\0')
	{
		//
		// No name filter specified. Use whatever is on top of the history.
		//
		if (m_cFilter.GetCount() > 0)
		{
			m_cFilter.GetLBText(0, m_szNameFilter);
			m_cFilter.SetCurSel(0);
		}
	}

	m_cFilter.SetWindowText(m_szNameFilter);
	m_cTextureWindow.SetNameFilter(m_szNameFilter);

	//
	// Done with the name filter; clear it for next time.
	//
	m_szNameFilter[0] = '\0';

	// Add the global list of keywords to the keywords combo.
	for( int i=0; i< g_Textures.GetNumKeywords(); i++ )
	{
		m_cKeywords.AddString( g_Textures.GetKeyword(i) );
	}

	//
	// Set the keyword filter.
	//
	m_cKeywords.SetWindowText(m_szLastKeywords);
	m_cTextureWindow.SetKeywords(m_szLastKeywords);

	m_cUsed.SetCheck(m_bUsed);

	// Refresh the list of used textures if enabled.
	if (m_bUsed)
	{
		SetUsed(TRUE);
	}

	CWinApp *pApp = AfxGetApp();
	CString str = pApp->GetProfileString(pszIniSection, "Position");
	if (!str.IsEmpty())
	{
		CRect r;
		sscanf(str, "%d %d %d %d", &r.left, &r.top, &r.right, &r.bottom);

		if (r.left < 0)
		{
			ShowWindow(SW_SHOWMAXIMIZED);
		}
		else
		{
			MoveWindow(r.left, r.top, r.right-r.left, r.bottom-r.top, FALSE);
		}
	}

	int iSize = pApp->GetProfileInt(pszIniSection, "ShowSize", 0);
	m_cSizeList.SetCurSel(iSize);
	OnSelendokTexturesize();

	if (szInitialTexture[0])
	{
		m_cTextureWindow.SelectTexture(szInitialTexture);
	}

	m_cTextureWindow.ShowWindow(SW_SHOW);

	SetTimer(1, 500, NULL);

	m_cFilter.SetFocus();

	return(FALSE);
}
Esempio n. 28
0
BOOL CProgramSettings::LoadFromRegistry()
{
	CWinApp* pApp = AfxGetApp();
	CString S;
	char szKey[32];
	//char szValue[256];
	int k, nSize;

	int   nDefault_BWCap                      = 0;
#define   MaxLines_UPPER_BOUND       12345
	int   nDefault_MaxLines                   = 1950;
	int   nDefault_bShowProgressDialogOnStart = TRUE;
	BOOL  nDefault_HighlightCurrentFile       = TRUE;
	BOOL  nDefault_bAutoRetry                 = TRUE;
	BOOL  nDefault_bSound                     = TRUE;
	BOOL  bDefault_bDetectPAR2                = FALSE;
	BOOL  bDefault_XNoArchiveHeader           = FALSE;
	BOOL  bDefault_XServerDate                = FALSE;
	BOOL  bDefault_HeaderPartial              = FALSE;
	BOOL  bDefault_ShowGroupDialogBeforePosting = TRUE;
	BOOL  bDefault_SortFiles                  = TRUE;
	BOOL  bDefault_FileThread                 = TRUE;
	char szDefault_From[]                     = "*****@*****.**";
	char szDefault_FromNick[]                 = "Yenc-PP-A&A";
	char szDefault_ReplyTo[]                  = "";
	char szDefault_Organization[]             = "";
	char szDefault_FollowupTo[]               = "";
	char szDefault_nViewColWid[]              = "289:42:168:195";
	char szDefault_DomainID[]                 = "powerpost2000AA.local";
	char szDefault_Skin[]                     = "Default";

	LoadServerFromRegistry("Settings");

	m_Disclaimer = pApp->GetProfileInt("Settings","Disclaimer",	0);

	m_nBandwidthCap = pApp->GetProfileInt("Settings","BandwidthCap",	nDefault_BWCap);

	m_nMaxLines = pApp->GetProfileInt("Settings","MaxLines", nDefault_MaxLines);
	if(m_nMaxLines > MaxLines_UPPER_BOUND) m_nMaxLines = MaxLines_UPPER_BOUND;
	if(m_nMaxLines < 500) m_nMaxLines = 500;

	m_bHighlightCurrentFile = pApp->GetProfileInt("Settings","HL_Last", nDefault_HighlightCurrentFile);
	if((m_bHighlightCurrentFile != TRUE) && (m_bHighlightCurrentFile != FALSE)) m_bHighlightCurrentFile = nDefault_HighlightCurrentFile;

	m_bSortFilesOnAdd = pApp->GetProfileInt("Settings", "SortOnAdd", bDefault_SortFiles);
	if((m_bSortFilesOnAdd != TRUE) && (m_bSortFilesOnAdd != FALSE)) m_bSortFilesOnAdd= bDefault_SortFiles;

	m_bSysTrayIcon = pApp->GetProfileInt("Settings", "SysTray", FALSE);
	if((m_bSysTrayIcon != TRUE) && (m_bSysTrayIcon != FALSE)) m_bSysTrayIcon = FALSE;

	S = pApp->GetProfileString("Settings","Skin", szDefault_Skin);
	if((S.GetLength() > MAX_PATH-1) || (S.GetLength() == 0)) S = szDefault_Skin;
	strcpy(m_szSkin, (LPCTSTR) S);

	m_bAutoRetry = pApp->GetProfileInt("Settings","AutoRetry", nDefault_bAutoRetry);
	if((m_bAutoRetry != TRUE) && (m_bAutoRetry != FALSE)) m_bAutoRetry = nDefault_bAutoRetry;

	m_bDetectPAR2 = pApp->GetProfileInt("Settings","DetectPAR2", bDefault_bDetectPAR2);
	if((m_bDetectPAR2 != TRUE) && (m_bDetectPAR2 != FALSE)) m_bDetectPAR2 = bDefault_bDetectPAR2;

	m_bShowProgressDialogOnStart = pApp->GetProfileInt("Settings","AutoShowProgress", nDefault_bShowProgressDialogOnStart);
	if((m_bShowProgressDialogOnStart != TRUE) && (m_bShowProgressDialogOnStart != FALSE)) m_bShowProgressDialogOnStart = FALSE;

	m_bXNoArchiveHeader = pApp->GetProfileInt("Settings","XNoArchiveHeader", bDefault_XNoArchiveHeader);
	if((m_bXNoArchiveHeader != TRUE) && (m_bXNoArchiveHeader != FALSE)) m_bXNoArchiveHeader = bDefault_XNoArchiveHeader;

	m_bXServerDate = pApp->GetProfileInt("Settings","XServerDate", bDefault_XServerDate);
	if((m_bXServerDate != TRUE) && (m_bXServerDate != FALSE)) m_bXServerDate = bDefault_XServerDate;

	m_bHeaderPartial = pApp->GetProfileInt("Settings","HeaderPartial", bDefault_HeaderPartial);
	if((m_bHeaderPartial != TRUE) && (m_bHeaderPartial != FALSE)) m_bHeaderPartial = bDefault_HeaderPartial;

	m_nCheckStop = pApp->GetProfileInt("Settings","CheckStop", FALSE);
	if((m_nCheckStop != TRUE) && (m_nCheckStop != FALSE)) m_nCheckStop = FALSE;

	m_bFileThread = pApp->GetProfileInt("Settings","FileThread", FALSE);
	if((m_bFileThread != TRUE) && (m_bFileThread != FALSE)) m_bFileThread = FALSE;

	S = pApp->GetProfileString("Settings","H_From", szDefault_From);
	if((S.GetLength() > 131) || (S.GetLength() == 0)) S = szDefault_From;
	strcpy(m_szFrom, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","H_FromNick", szDefault_FromNick);
	if((S.GetLength() > 63) || (S.GetLength() == 0)) S = szDefault_FromNick;
	strcpy(m_szFromNick, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","H_ReplyTo", szDefault_ReplyTo);
	if((S.GetLength() > 131) || (S.GetLength() == 0)) S = szDefault_ReplyTo;
	strcpy(m_szReplyTo, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","H_Org", szDefault_Organization);
	if((S.GetLength() > 131) || (S.GetLength() == 0)) S = szDefault_Organization;
	strcpy(m_szOrganization, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","H_Followup", szDefault_FollowupTo);
	if((S.GetLength() > 131) || (S.GetLength() == 0)) S = szDefault_FollowupTo;
	strcpy(m_szFollowupTo, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","H_DomainID", szDefault_DomainID);
	if((S.GetLength() > 131) || (S.GetLength() == 0)) S = szDefault_DomainID;
	strcpy(m_szDomainID, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","LastDir", "");
	if(S.GetLength() >= _MAX_PATH) S = "";
	strcpy(m_szLastAddDir, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","LastTempl_yEnc","(\?\?\?\?) [$1/$2] - \"$F\" yEnc");
	if(S.GetLength() >= 132) S = "(\?\?\?\?) [$1/$2] - \"$F\" yEnc";
	strcpy(m_szLastSubjectTemplate, (LPCTSTR) S);

	S = pApp->GetProfileString("Settings","ViewColWid", szDefault_nViewColWid);
	k = sscanf((LPCTSTR) S, "%d:%d:%d:%d", &m_nViewColWid[0], &m_nViewColWid[1], &m_nViewColWid[2], &m_nViewColWid[3]);
	if(k != 4)
	{
		// 289:42:168:195
		m_nViewColWid[0] = 289;
		m_nViewColWid[1] = 42;
		m_nViewColWid[2] = 168;
		m_nViewColWid[3] = 195;
	}

	S = pApp->GetProfileString("Settings","StartTime","0:0:0");
	k = sscanf((LPCTSTR) S, "%d:%d:%d", &m_nStartTimeSel[0], &m_nStartTimeSel[1], &m_nStartTimeSel[2]);
	if(k != 3)
	{
		m_nStartTimeSel[0] = 0;
		m_nStartTimeSel[1] = 0;
		m_nStartTimeSel[2] = 0;
	}

	S = pApp->GetProfileString("Settings","StopTime","0:0:0");
	k = sscanf((LPCTSTR) S, "%d:%d:%d", &m_nStopTimeSel[0], &m_nStopTimeSel[1], &m_nStopTimeSel[2]);
	if(k != 3)
	{
		m_nStopTimeSel[0] = 0;
		m_nStopTimeSel[1] = 0;
		m_nStopTimeSel[2] = 0;
	}

	// Load Group List
	m_GroupList.RemoveAll();
	nSize = pApp->GetProfileInt("Settings","GrpListSize", 0);

	for(k = 0; k < nSize; k++)
	{
		sprintf(szKey, "GrpList_%04d", k);
		S = pApp->GetProfileString("Settings", szKey, "");
		if(S.GetLength() > 0)
			CM_CSA_INSERT(m_GroupList, (LPCTSTR) S);
	}

	if(nSize == 0)
		m_GroupList.Add("alt.binaries.test");

	for (k = 0; k < NSERVERS; k++)
	{
		sprintf(szKey,"Server%d",k);
		servers[k].LoadServerFromRegistry(szKey);
	}

	return TRUE;
}
Esempio n. 29
0
//fillboxes expects i to be a registry value(1 to latest), not a listbox value (0 to latest-1)!
void CLogin::FillBoxes(int i, bool FillListBox)
{
	if(0 > i)
	{
		ASSERT(1);
		return;
	}

	CWinApp* pApp = AfxGetApp();

	UINT latest = pApp->GetProfileInt("History", "Latest", 0);

	//out of bounds - not ASSERT()able since the calling functions can be dumb to this.
	if(latest < i)
		return;


	static char buf[256];

	sprintf(buf, "History\\%d", i);

	CString name, host, zone, port, default_resource;

	//1st, copy all values from this registry entry to local values.
	name = pApp->GetProfileString(buf, "Name");
	host = pApp->GetProfileString(buf, "Host");
	zone = pApp->GetProfileString(buf, "Zone");
	port = pApp->GetProfileString(buf, "Port");

	//for debug purposes, assert that the values actually exist.
	//ASSERT(0 != name.Compare(""));
	//ASSERT(0 != host.Compare(""));
	//ASSERT(0 != zone.Compare(""));
	//ASSERT(0 != port.Compare(""));

	//to keep multiple copies of the same value appearing in each box
	//(there may be more than one domain with the username charliec, for instance).
	//only add if the value isn't in there already.
	int status = m_NameCombobox.FindStringExact(-1, name);
	if(CB_ERR == status)
		status = m_NameCombobox.AddString(name);
	m_NameCombobox.SetCurSel(status);

	status = m_HostCombobox.FindStringExact(-1, host);
	if(CB_ERR == status)
		status = m_HostCombobox.AddString(host);
	m_HostCombobox.SetCurSel(status);

	status = m_ZoneCombobox.FindStringExact(-1, zone);
	if(CB_ERR == status)
		status = m_ZoneCombobox.AddString(zone);
	m_ZoneCombobox.SetCurSel(status);

	status = m_PortCombobox.FindStringExact(-1, port);
	if(CB_ERR == status)
		status = m_PortCombobox.AddString(port);
	m_PortCombobox.SetCurSel(status);

	int n;
	if(FillListBox)
	{
		CString new_profile = name + " in " + zone + " at " + host + " | " + port;
		m_prevLogins.Add(new_profile);

		//m_ListBox.InsertItem(i-1, new_profile, 0); 
		n = m_ListBox.InsertItem(i-1, name);
		m_ListBox.SetItemText(n, 1, zone);
		m_ListBox.SetItemText(n, 2, host);
		m_ListBox.SetItemText(n, 3, port);
	}
}
Esempio n. 30
0
void CLogin::OnLoginRemove() 
{
	int count = m_ListBox.GetSelectedCount();

	//someone hit remove without selecting something to remove.
	if(0 == count)
		return;

	ASSERT(1 == count);


	if(AfxMessageBox("Do you want to delete the selected login data?", MB_YESNO) != IDYES)
		return;

	POSITION POS = m_ListBox.GetFirstSelectedItemPosition();
	int i = m_ListBox.GetNextSelectedItem(POS);

	CWinApp* pApp = AfxGetApp();

	UINT latest = pApp->GetProfileInt("History", "Latest", 0);

	//latest should never be 0 if there was something to remove.
	//nevertheless, if it is 0 we should return and do nothing.
	if(0 == latest)
	{
		ASSERT(1);	
		return;
	}

	CString name, host, zone, port;

	char buf[256];
	char buf2[256];

	//i is the listbox id for the profile to be removed.
	//the registry id for the profile is always i+1.
	//latest is always a valid entry, but latest+1 is not - hence no reason to move
	for(UINT j = i + 1; j < latest; j++)
	{
		sprintf(buf, "History\\%d", j);
		sprintf(buf2, "History\\%d", j+1);

		name = pApp->GetProfileString(buf2, "Name");
		host = pApp->GetProfileString(buf2, "Host");
		zone = pApp->GetProfileString(buf2, "Zone");
		port = pApp->GetProfileString(buf2, "Port");
		pApp->WriteProfileString(buf, "Name", name);
		pApp->WriteProfileString(buf, "Host", host);
		pApp->WriteProfileString(buf, "Zone", zone);
		pApp->WriteProfileString(buf, "Port", port);
	}

	//reflect that we're now one-less a profile and remove the last one.
	sprintf(buf, "History\\%d", latest);
	//erase all the child values
	pApp->WriteProfileString(buf, "Name", NULL);
	pApp->WriteProfileString(buf, "Host", NULL);
	pApp->WriteProfileString(buf, "Zone", NULL);
	pApp->WriteProfileString(buf, "Port", NULL);

	//erase the history key itself
	HKEY hKey;
	sprintf(buf, "%d", latest);
	::RegOpenKey(HKEY_CURRENT_USER, "Software\\San Diego Supercomputer Center\\WINI\\History", &hKey);
	::RegDeleteKey(hKey, buf);

	if(--latest < 0)
		latest = 0;

	pApp->WriteProfileInt("History", "Latest", latest);

	//finally, update the GUI
	m_ListBox.DeleteItem(i);

	//fills the left-hand boxes with the profile following the removed one.
	//don't fill up the right-hand listbox. it should handle case where i
	//is an illegal value safely.
	//remember, the parameter is i+1 not to find the subsequent value.
	//the subsequent value is now i, we are feeding fillboxes i+1 because
	//it works in registry range, not listbox range!
	FillBoxes(i+1, false);
}