prabhakar_er
September 29th, 2006, 01:34 AM
// URLLinkDlg.cpp : implementation file
//
#include "stdafx.h"
#include "URLLink.h"
#include "URLLinkDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*here i getting error-c2146,error-c2501,error-c1004*/
CSettings sett;
CSchedule sch;
CAbout abt;
CFile fileInput;
char pbuf[1000];
CFileException exi;
///////////////////////////////////////////////////////////////////////
// CURLLinkDlg dialog
CURLLinkDlg::CURLLinkDlg(CWnd* pParent /*=NULL*/)
: CDialog(CURLLinkDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CURLLinkDlg)
m_app = _T("");
m_doc = _T("");
m_mail = _T("");
m_sms = _T("");
m_task = _T("");
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CURLLinkDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CURLLinkDlg)
DDX_Control(pDX, IDC_WEB_LINK5, m_btnWebLink5);
DDX_Control(pDX, IDC_WEB_LINK4, m_btnWebLink4);
DDX_Control(pDX, IDC_WEB_LINK3, m_btnWebLink3);
DDX_Control(pDX, IDC_SHOW_MESSAGE, m_btnShowMessage);
DDX_Control(pDX, IDOK, m_btnClose);
DDX_Control(pDX, IDC_WEB_LINK2, m_btnWebLink2);
DDX_Control(pDX, IDC_MAIL_TO2, m_btnMailto2);
DDX_Control(pDX, IDC_WEB_LINK, m_btnWebLink);
DDX_Control(pDX, IDC_MAIL_TO, m_btnMailto);
DDX_Text(pDX, IDC_STATIC_APP, m_app);
DDX_Text(pDX, IDC_STATIC_DOC, m_doc);
DDX_Text(pDX, IDC_STATIC_MAIL, m_mail);
DDX_Text(pDX, IDC_STATIC_SMS, m_sms);
DDX_Text(pDX, IDC_STATIC_TASK, m_task);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CURLLinkDlg, CDialog)
//{{AFX_MSG_MAP(CURLLinkDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_REFRESH, OnButtonRefresh)
ON_COMMAND(ID_DMSALERT_ABOUT, OnDmsalertAbout)
ON_COMMAND(ID_DMSALERT_SCHEDULEDALERTS, OnDmsalertScheduledalerts)
ON_COMMAND(ID_DMSALERT_SETTINGS, OnDmsalertSettings)
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(WM_LINK_CLICKED, OnLinkCliked)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CURLLinkDlg message handlers
BOOL CURLLinkDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_btnWebLink.SetToolTipText(_T("Goto ")+m_btnWebLink.GetDefaultTipText());
m_btnWebLink.SizeToContent();
m_btnWebLink2.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink2.SetToolTipText();
m_btnWebLink2.SizeToContent();
m_btnWebLink3.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink3.SetToolTipText();
m_btnWebLink3.SizeToContent();
m_btnWebLink4.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink4.SetToolTipText();
m_btnWebLink4.SizeToContent();
m_btnWebLink5.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink5.SetToolTipText();
m_btnWebLink5.SizeToContent();
m_btnMailto.SetURLPrefix(_T("Mailto:"));
m_btnMailto.SetToolTipText();
m_btnMailto.SizeToContent();
m_btnMailto2.SetURL(_T("prabhakar@dewsoftindia.com"));
m_btnMailto2.SetURLPrefix(_T("Mailto:"));
m_btnMailto2.SetToolTipText();
m_btnMailto2.SetToolTipTextColor(RGB(0,100,0));
m_btnMailto2.SizeToContent();
m_btnShowMessage.SetToolTipText(_T("Click to display a message"));
m_btnShowMessage.SetRegularColor(RGB(0,155,155));
m_btnShowMessage.SizeToContent();
m_btnClose.SetToolTipText(_T("Exit"));
m_btnClose.SetRegularColor(RGB(255,0,0));
m_btnClose.SizeToContent();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CURLLinkDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CURLLinkDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
LRESULT CURLLinkDlg::OnLinkCliked(WPARAM wParam, LPARAM lParam)
{
UINT nLinkID = (UINT)wParam;
switch(nLinkID)
{
case IDOK:
OnOK();
break;
case IDC_SHOW_MESSAGE:
MessageBox(_T("This is For Dewsoft India Solution!!"));
break;
}
return 0;
}
void CURLLinkDlg::OnButtonRefresh()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
if (!fileInput.Open("Alert.txt",CFile::modeRead, &exi))
{
//Generate Error Message if there is an error opening the File
TCHAR szCause[255];//Buffer for storing the cause string
CString strFormatted;//String for complete message to be displayed on messagebox
exi.GetErrorMessage(szCause, 255);
strFormatted = _T("The data file could not be opened because of this error: ");
strFormatted += szCause;
//cout << LPCTSTR(strFormatted);
}
fileInput.Read(LPTSTR(pbuf),1000 ); //Input the data in buffer
CString whole=pbuf; // Copy data from buffer to string
fileInput.Close();
whole.TrimRight(); // Trim the spaces to the right of string
whole.TrimLeft();
int c=1;
do
{
CString action=whole.Left(whole.Find(','));//'find' returns index & 'left' returns substring starting from left with no. of characters as argument
//MessageBox(action);
if (c==1)
m_doc = action;
UpdateData(false);
if (c==2)
m_mail = action;
UpdateData(false);
if (c==3)
m_task = action;
UpdateData(false);
if (c==4)
m_app = action;
UpdateData(false);
if (c==5)
m_sms = action;
UpdateData(false);
whole.Delete(0,(whole.Find(',')+1));
c=c+1;
}
while(whole.GetLength()!=0);
}
void CURLLinkDlg::OnDmsalertAbout()
{
// TODO: Add your command handler code here
abt.DoModal();
}
void CURLLinkDlg::OnDmsalertScheduledalerts()
{
// TODO: Add your command handler code here
sch.DoModal();
}
void CURLLinkDlg::OnDmsalertSettings()
{
// TODO: Add your command handler code here
sett.DoModal();
}
//
#include "stdafx.h"
#include "URLLink.h"
#include "URLLinkDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*here i getting error-c2146,error-c2501,error-c1004*/
CSettings sett;
CSchedule sch;
CAbout abt;
CFile fileInput;
char pbuf[1000];
CFileException exi;
///////////////////////////////////////////////////////////////////////
// CURLLinkDlg dialog
CURLLinkDlg::CURLLinkDlg(CWnd* pParent /*=NULL*/)
: CDialog(CURLLinkDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CURLLinkDlg)
m_app = _T("");
m_doc = _T("");
m_mail = _T("");
m_sms = _T("");
m_task = _T("");
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CURLLinkDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CURLLinkDlg)
DDX_Control(pDX, IDC_WEB_LINK5, m_btnWebLink5);
DDX_Control(pDX, IDC_WEB_LINK4, m_btnWebLink4);
DDX_Control(pDX, IDC_WEB_LINK3, m_btnWebLink3);
DDX_Control(pDX, IDC_SHOW_MESSAGE, m_btnShowMessage);
DDX_Control(pDX, IDOK, m_btnClose);
DDX_Control(pDX, IDC_WEB_LINK2, m_btnWebLink2);
DDX_Control(pDX, IDC_MAIL_TO2, m_btnMailto2);
DDX_Control(pDX, IDC_WEB_LINK, m_btnWebLink);
DDX_Control(pDX, IDC_MAIL_TO, m_btnMailto);
DDX_Text(pDX, IDC_STATIC_APP, m_app);
DDX_Text(pDX, IDC_STATIC_DOC, m_doc);
DDX_Text(pDX, IDC_STATIC_MAIL, m_mail);
DDX_Text(pDX, IDC_STATIC_SMS, m_sms);
DDX_Text(pDX, IDC_STATIC_TASK, m_task);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CURLLinkDlg, CDialog)
//{{AFX_MSG_MAP(CURLLinkDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_REFRESH, OnButtonRefresh)
ON_COMMAND(ID_DMSALERT_ABOUT, OnDmsalertAbout)
ON_COMMAND(ID_DMSALERT_SCHEDULEDALERTS, OnDmsalertScheduledalerts)
ON_COMMAND(ID_DMSALERT_SETTINGS, OnDmsalertSettings)
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(WM_LINK_CLICKED, OnLinkCliked)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CURLLinkDlg message handlers
BOOL CURLLinkDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_btnWebLink.SetToolTipText(_T("Goto ")+m_btnWebLink.GetDefaultTipText());
m_btnWebLink.SizeToContent();
m_btnWebLink2.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink2.SetToolTipText();
m_btnWebLink2.SizeToContent();
m_btnWebLink3.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink3.SetToolTipText();
m_btnWebLink3.SizeToContent();
m_btnWebLink4.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink4.SetToolTipText();
m_btnWebLink4.SizeToContent();
m_btnWebLink5.SetURL(_T("http:\\\\www.dewsoftindia.com"));
m_btnWebLink5.SetToolTipText();
m_btnWebLink5.SizeToContent();
m_btnMailto.SetURLPrefix(_T("Mailto:"));
m_btnMailto.SetToolTipText();
m_btnMailto.SizeToContent();
m_btnMailto2.SetURL(_T("prabhakar@dewsoftindia.com"));
m_btnMailto2.SetURLPrefix(_T("Mailto:"));
m_btnMailto2.SetToolTipText();
m_btnMailto2.SetToolTipTextColor(RGB(0,100,0));
m_btnMailto2.SizeToContent();
m_btnShowMessage.SetToolTipText(_T("Click to display a message"));
m_btnShowMessage.SetRegularColor(RGB(0,155,155));
m_btnShowMessage.SizeToContent();
m_btnClose.SetToolTipText(_T("Exit"));
m_btnClose.SetRegularColor(RGB(255,0,0));
m_btnClose.SizeToContent();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CURLLinkDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CURLLinkDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
LRESULT CURLLinkDlg::OnLinkCliked(WPARAM wParam, LPARAM lParam)
{
UINT nLinkID = (UINT)wParam;
switch(nLinkID)
{
case IDOK:
OnOK();
break;
case IDC_SHOW_MESSAGE:
MessageBox(_T("This is For Dewsoft India Solution!!"));
break;
}
return 0;
}
void CURLLinkDlg::OnButtonRefresh()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
if (!fileInput.Open("Alert.txt",CFile::modeRead, &exi))
{
//Generate Error Message if there is an error opening the File
TCHAR szCause[255];//Buffer for storing the cause string
CString strFormatted;//String for complete message to be displayed on messagebox
exi.GetErrorMessage(szCause, 255);
strFormatted = _T("The data file could not be opened because of this error: ");
strFormatted += szCause;
//cout << LPCTSTR(strFormatted);
}
fileInput.Read(LPTSTR(pbuf),1000 ); //Input the data in buffer
CString whole=pbuf; // Copy data from buffer to string
fileInput.Close();
whole.TrimRight(); // Trim the spaces to the right of string
whole.TrimLeft();
int c=1;
do
{
CString action=whole.Left(whole.Find(','));//'find' returns index & 'left' returns substring starting from left with no. of characters as argument
//MessageBox(action);
if (c==1)
m_doc = action;
UpdateData(false);
if (c==2)
m_mail = action;
UpdateData(false);
if (c==3)
m_task = action;
UpdateData(false);
if (c==4)
m_app = action;
UpdateData(false);
if (c==5)
m_sms = action;
UpdateData(false);
whole.Delete(0,(whole.Find(',')+1));
c=c+1;
}
while(whole.GetLength()!=0);
}
void CURLLinkDlg::OnDmsalertAbout()
{
// TODO: Add your command handler code here
abt.DoModal();
}
void CURLLinkDlg::OnDmsalertScheduledalerts()
{
// TODO: Add your command handler code here
sch.DoModal();
}
void CURLLinkDlg::OnDmsalertSettings()
{
// TODO: Add your command handler code here
sett.DoModal();
}