home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hot Shareware 35
/
hot35.iso
/
ficheros
/
LC
/
SEE4C10.ZIP
/
MFC_PGM.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1998-05-28
|
4KB
|
158 lines
//
// mfc_pgm.cpp
//
// MFC_PGM is intended as a simple example of the use of
// the Microsoft Foundation Class (MFC) library with the
// SMTP Email Engine for C/C++ (SEE4C)
//
#include "stdafx.h"
#include "resource.h"
#include "see.h"
#include "mfc_pgm.h"
static CWnd * MainWndPtr;
// CMainWindow: constructor
CMainWindow::CMainWindow()
{int Row;
CString s = "WSC Test";
LoadAccelTable( "MainAccelTable" );
Create( NULL, "MFC Example Program",
WS_OVERLAPPEDWINDOW, rectDefault, NULL, "MainMenu" );
for(Row=0;Row<NROWS;Row++) Buffer[Row].Empty;
TheRow = 0;
}
// Display character on screen
void CMainWindow::DisplayChar(int nChar)
{int Row;
// process the character
if(nChar==10) return;
if(nChar==13)
{if(TheRow<NROWS-1) TheRow++;
else
{// scroll page (TheRow==NROWS-1)
for(Row=0;Row<=NROWS-2;Row++) Buffer[Row] = Buffer[Row+1];
Buffer[NROWS-1].Empty();
TheRow = NROWS-1;
}
}
else
{// stuff character into display buffer
Buffer[TheRow] += (char)nChar;
}
}
// Display string on screen
void CMainWindow::DisplayLine(CString Text)
{
Buffer[TheRow] += Text;
DisplayChar(13);
Invalidate(TRUE);
}
// CMainWindow message map
BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
//{{AFX_MSG_MAP( CMainWindow )
ON_WM_PAINT()
ON_COMMAND(ID_EXIT, PgmExit)
ON_COMMAND(ID_SEND, PgmSend)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CTheApp NEAR theApp;
// PgmExit: Exits application
void CMainWindow::PgmExit(void)
{
PostQuitMessage(0);
}
// display error message
void CMainWindow::ShowError(int Code)
{static char Buffer[65];
static char Temp[90];
seeErrorText(Code,(LPSTR)Buffer,65);
wsprintf((LPSTR)Temp,"SEE Error %d: %s\n", Code, (LPSTR)Buffer);
DisplayLine((LPSTR)Temp);
}
// PgmSend : Send email
void CMainWindow::PgmSend(void)
{int Code;
/////////////////////////////////////////////////////////
////// IMPORTANT: edit these definitions before compiling
#define SMTP_HOST_NAME "smtp_host_name"
#define YOUR_EMAIL_ADDR "your_email_address"
#define SEND_TO "receipient's email address"
////// EXAMPLE //////////////////////////////////////////
// #define SMTP_HOST_NAME "mail.myisp.net"
// #define YOUR_EMAIL_ADDR "<me@myisp.com>"
// #define SEND_TO "<mike@marshallsoft.com>"
/////////////////////////////////////////////////////////
// connect to SMTP server
DisplayLine("Calling seeConnectTo()...");
Code = seeConnectTo(
(LPSTR)SMTP_HOST_NAME, // SMTP server
(LPSTR)YOUR_EMAIL_ADDR, // return email address
(LPSTR)NULL); // Reply-To header
if(Code<0)
{ShowError(Code);
return;
}
// send email
DisplayLine("Calling seeSendEmail()...");
Code = seeSendEmail(
(LPSTR)"<msc@traveller.com>", // To list
(LPSTR)NULL, // CC list
(LPSTR)NULL, // BCC list
(LPSTR)"Email from MFC_PGM", // subject
(LPSTR)"This is a test.\r\n\r\n--Mike", // message text
(LPSTR)NULL); // MIME attachment
if(Code<0)
{ShowError(Code);
return;
}
DisplayLine("Calling seeClose()...");
Code = seeClose();
Invalidate(TRUE);
}
// OnPaint:
void CMainWindow::OnPaint()
{int Row;
CPaintDC dc( this );
CRect rect;
GetClientRect( rect );
dc.SetTextAlign( TA_BASELINE | TA_LEFT );
dc.SetTextColor( ::GetSysColor( COLOR_WINDOWTEXT ) );
dc.SetBkMode(TRANSPARENT);
dc.SelectStockObject(ANSI_FIXED_FONT);
for(Row=0;Row<=TheRow;Row++)
{// display the row
dc.TextOut( 4, 16+(Row<<4), Buffer[Row], Buffer[Row].GetLength() );
}
}
// InitInstance:
BOOL CTheApp::InitInstance()
{SetDialogBkColor(); //hook gray dialogs
m_pMainWnd = new CMainWindow();
m_pMainWnd->ShowWindow( m_nCmdShow );
m_pMainWnd->UpdateWindow();
MainWndPtr = m_pMainWnd;
return TRUE;
}