Пример #1
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.
	CHexEditApp *aa = dynamic_cast<CHexEditApp *>(AfxGetApp());
	m_bStartup = aa->tipofday_;
	UINT iFilePos = aa->GetProfileInt(szSection, szIntFilePos, 0);

	const char *tip_name = "HexEdit.tip";

	// Now try to open the tips file in the current directory
	m_pStream = fopen(tip_name, "r");
	if (m_pStream == NULL) 
	{
// AP: This bit added by me -----------------------------------------------------------
		// Not found so try to open from the .exe dir
		if ((m_pStream = fopen(GetExePath() + tip_name, "r")) == NULL)
// ------------------------------------------------------------------------------------
		{
			VERIFY(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 = 
		aa->GetProfileString(szSection, szTimeStamp, NULL);
	if (strCurrentTime != strStoredTime) 
	{
		iFilePos = 0;
		aa->WriteProfileString(szSection, szTimeStamp, strCurrentTime);
	}

	if (fseek(m_pStream, iFilePos, SEEK_SET) != 0) 
	{
		AfxMessageBox(CG_IDP_FILE_CORRUPT);
	}
	else 
	{
		GetNextTipString(m_strTip);
	}
}
Пример #2
0
BOOL CTipDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // If Tips file does not exist then disable NextTip
    if ( m_sTips == NULL )
        GetDlgItem(IDC_NEXTTIP)->EnableWindow(FALSE);
    else
    {
        GetNextTipString(m_strTip);
        UpdateData(FALSE);
    } // end else

    return TRUE;  // return TRUE unless you set the focus to a control
}
Пример #3
0
/********************************************************************************************

>	TipsDlg::TipsDlg()

	Author:		Colin_Barfoot (Xara Group Ltd) <*****@*****.**>
	Created:	03/08/96
	Purpose:	This default constructor provides the only way to instantiate TipsDlg objects

********************************************************************************************/
TipsDlg::TipsDlg() : DialogOp(TipsDlg::IDD(), TipsDlg::Mode)
{
	m_bSentInvalid	= FALSE;

	m_bTipOK		= FALSE;
	m_iHashPosition	= 0;

	m_pCurrentMsg	= NULL;
	m_pRenderer		= NULL;

	m_pTipTextGadget	= NULL;

	Camelot.GetPrefValue(szSection, szIntNextID, &g_uNextID);
	// Now try to get the next tip
	GetNextTipString();
}        
Пример #4
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);
	}
}
Пример #5
0
/********************************************************************************************

>	void TipsDlg::OnNextTip()

	Author:		Colin_Barfoot (Xara Group Ltd) <*****@*****.**>
	Created:	03/08/96
	Purpose:	Responds to a user's request for the Next Tip by displaying it.

********************************************************************************************/
void TipsDlg::OnNextTip()
{
	GetNextTipString();

	// Check there's more help & disable the more button if there isn't
	HelpID helpID = GetTipHelpID();
	if (helpID == 0)
	{
		EnableGadget(_R(IDC_MORE), FALSE);
	}
	else
	{
		EnableGadget(_R(IDC_MORE), TRUE);
	}		

	DrawTipString();
}
Пример #6
0
CTipDlg::CTipDlg(CWnd* pParent /*=NULL*/)
	: CDialog(IDD_TIP, pParent)
{
	//{{AFX_DATA_INIT(CTipDlg)
	m_bStartup = TRUE;
	//}}AFX_DATA_INIT

	m_bStartup = g_bStartTipsByDefault;

	// 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(g_szTipsSection, g_szTipsIntStartup, g_bStartTipsByDefault );
	UINT iFilePos = pApp->GetProfileInt(g_szTipsSection, g_szTipsIntFilePos, 0);

	m_strTips = LocLoadString( IDS_TIPS );
	m_iTipPos = iFilePos;

	{
		GetNextTipString(m_strTip);
	}
}
Пример #7
0
void CTipDlg::OnNextTip()
{
	GetNextTipString(m_strTip);
	UpdateData(FALSE);
}
Пример #8
0
CTipDlg::CTipDlg(CWnd* pParent /*=NULL*/)
	: CDialog(IDD_TIP, pParent)
{
char fullfilename[MAX_PATH];
char filename [MAX_PATH];
char * p;

  // look for tips.txt in the same directory as the executable file
  if (GetModuleFileName (NULL, fullfilename, sizeof (fullfilename)))
   {

// remove last part of file name to get working directory

    strcpy (filename, fullfilename);

    p = strrchr (filename, '\\');
    if (p)
      *p = 0;

    strcat (filename, "\\tips.txt");
    }
  else
    strcpy (filename, "tips.txt");

	//{{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 = !App.db_get_int("control", szIntStartup, 0);
	UINT iFilePos = App.db_get_int("control", szIntFilePos, 0);

	// Now try to open the tips file
	m_pStream = fopen(filename, "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 = 
		App.db_get_string("control", szTimeStamp, "");
	if (strCurrentTime != strStoredTime) 
	{
		iFilePos = 0;
		App.db_write_string("control", szTimeStamp, strCurrentTime);
	}

	if (fseek(m_pStream, iFilePos, SEEK_SET) != 0) 
	{
		AfxMessageBox(CG_IDP_FILE_CORRUPT);
	}
	else 
	{
		GetNextTipString(m_strTip);
	}
}