⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csendingmaildlg.cpp

📁 有关win32应用程序编程和wince应用程序编程的很全面
💻 CPP
字号:
// CSendingMailDlg.cpp: implementation of the CSendingMailDlg class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CSendingMailDlg.h"
#include "resource.h"
#include "CSendMailManager.h"
#include "harTransform.h"
#include "CGPRSManager.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSendingMailDlg g_sendingmaildlg;
extern TCHAR g_username[ADDRESS_LENTH];
CSendingMailDlg::CSendingMailDlg()
{

}

CSendingMailDlg::~CSendingMailDlg()
{

}


BOOL CALLBACK CSendingMailDlgProc(const HWND hDlg, const UINT uiMessage, const WPARAM wParam, const LPARAM lParam)
{
	BOOL	bProcessedMsg = TRUE;
	switch(uiMessage)
	{
		case WM_INITDIALOG:
			CSendingMailDlg::InitialDlg(g_sendingmaildlg,hDlg);
			break;
			
		case WM_COMMAND:
			break;	

		case WM_TIMER:
		{
			if(wParam == 1000)
			{
				KillTimer(hDlg,1000);
				CSendingMailDlg::SendMail(g_sendingmaildlg);
				CSendingMailDlg::DestroyDlg(g_sendingmaildlg,hDlg);
			}
			break;
		}

		case WM_CLOSE:
			CSendingMailDlg::DestroyDlg(g_sendingmaildlg,hDlg);
			break;
		
		default:
			bProcessedMsg = FALSE;
			break;
	}
	return bProcessedMsg;
}



BOOL CSendingMailDlg::DlgBox(CSendingMailDlg &dlg, HINSTANCE hinst, HWND parent)
{
	dlg.m_result = DialogBox(hinst,MAKEINTRESOURCE(IDD_DIALOG_MAILSENDING),parent,(DLGPROC)CSendingMailDlgProc);
	if(dlg.m_result == -1)
		return FALSE;
	return TRUE;
}

BOOL CSendingMailDlg::InitialDlg(CSendingMailDlg &dlg, HWND hDlg)
{

	// Specify that the dialog box should stretch full screen
	SHINITDLGINFO shidi;
	ZeroMemory(&shidi, sizeof(shidi));
    shidi.dwMask = SHIDIM_FLAGS;
    shidi.dwFlags = SHIDIF_SIPDOWN;
    shidi.hDlg = hDlg;
            

	// If we could not initialize the dialog box, return an error
	if (!(SHInitDialog(&shidi)))
	{
		return FALSE;
	}

	SetTimer(hDlg,1000,200,NULL);
	dlg.m_cur = LoadCursor(NULL,IDC_WAIT);
	return TRUE;
}

BOOL CSendingMailDlg::DestroyDlg(CSendingMailDlg &dlg, HWND hDlg)
{
	SetCursor(NULL);
	DeleteObject(dlg.m_cur);
	if(!EndDialog(hDlg,dlg.m_result))
		return FALSE;
	return TRUE;
}



BOOL CSendingMailDlg::SendMail(CSendingMailDlg &dllg)
{

	SetCursor(dllg.m_cur);
	TCHAR *timf;
	char* imf;
	int index,i,size = 0;
	int sid[3] = {IDC_EDIT_TO,IDC_EDIT_SUBJECT,IDC_EDIT_CONTENT};
	int len[3] = {MAILEIDTADDRESSLENGH,MAIL_SUBJECTLENTH,MAIL_CONTENTLENTH};
//
	TCHAR* address = new TCHAR[MAILEIDTADDRESSLENGH+1];
	if(address==NULL)
		return dllg.m_res = FALSE;
	GetWindowText(GetDlgItem(dllg.m_parent,IDC_EDIT_TO),address,MAILEIDTADDRESSLENGH);
	if(lstrlen(address) == 0)
	{
		delete []address;
		g_messageid = DESNOT_EMPTY;
		return dllg.m_res = FALSE;
	}
	delete []address;

	
////得到imf
	for(i = 0;i < 3;++i)
	{
		size += len[i];
		if(i != 2)
			size++;
	}
	timf = new TCHAR[size+2];
	if(timf == NULL)
		return dllg.m_res = FALSE;
	index = 0;
	for(i = 0;i < 3;++i)
	{
		int actl = GetWindowText(GetDlgItem(dllg.m_parent,sid[i]),timf+index,len[i]);
		if(i != 2)
		{
			lstrcat(timf+index,L"\n");
			index += actl + 1;
		}

	}
	CharTransform trans;
	imf = trans.TCharToChar(timf);
	delete []timf;
	
	CSendMailManager msend;
	CGPRSManager mag;
	if (!mag.TrigerConnection())
	{
		g_messageid = GPRS_CREAEFAIL;
		return FALSE;
	}
	BOOL res = msend.SendMail(imf,strlen(imf),g_username,dllg.m_pdlg->m_sendtime);
	mag.Release();
	return dllg.m_res = res;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -