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

📄 loginlist.cpp

📁 BQYAHOO的Visual C++源代码
💻 CPP
字号:
//负责处理左边列表控件

#include "stdafx.h"
#include "resource.h"
#include "LogInList.h"


extern CXMLDATA XmlData;
BQYAHOO * by=NULL;

//


//
static int Xindex;
static HWND XhwndDownLoadFileList;
static HWND XhwndEdit;
DWORD WINAPI LogInThread(LPVOID lpParam) ;
//

void CLogInListCtrl::Init()
{	
	SetExtendedListViewStyle ( LVS_EX_FULLROWSELECT );
	InsertColumn ( 0, "", LVCFMT_LEFT, 0, 0 );
	SetColumnWidth ( 0, LVSCW_AUTOSIZE_USEHEADER );		
	LoadXmlData();		
}


void CLogInListCtrl::LoadXmlData()
{
	XmlData.clear ();
	XmlData.ReadData ();

	DeleteAllItems();

	int len=XmlData.VName .size ();
	for(int n=0;n<len;n++)
	{
		InsertItem(n,XmlData.VName [n].c_str ());
	}
}

LRESULT CLogInListCtrl::OnLButtonDBClick( UINT , CPoint )
{
	if(by==NULL)
	{
		by=new BQYAHOO();
	}
	else
	{
		by->LogOut ();
		::Sleep (1000);
		delete(by);
		by=new BQYAHOO();
	}
	if(!LogIn()) return 0;	

	
	return 0;
}


bool CLogInListCtrl::LogIn()
{
	//开始进行登陆
	
	//
	int index = GetSelectedIndex();
	if(index==-1) return false;	
	::SetWindowText (hwndEdit,"登陆");


	Xindex=index;
	XhwndDownLoadFileList=hwndDownLoadFileList;
	XhwndEdit=hwndEdit;

	DWORD dwThreadId, dwThrdParam = index; 
    HANDLE hThread; 
    hThread = CreateThread( 
        NULL,                        // no security attributes 
        0,                           // use default stack size  
        LogInThread,                  // thread function 
        &dwThrdParam,                // argument to thread function 
        0,                           // use default creation flags 
        &dwThreadId);                // returns the thread identifier 

	if (hThread == NULL) return false;
	CloseHandle( hThread );

	by->SubDirectory =XmlData.VName [index];

	return true;
}


DWORD WINAPI LogInThread( LPVOID index )  //为了保证界面不出现“死机”的感觉,只好使用线程
{ 
	
	if(!by->BeforeLogIn ()) return false;

	::SetWindowText (XhwndEdit,"进入登陆页面");
	byte LogInCode[160];
	memset(LogInCode,0,160);
	strncpy((char *)LogInCode,XmlData.VLogInCode [Xindex].c_str (),160);
	if(!by->LogIn (LogInCode,XmlData.VDownLoadCode [Xindex])) 
	{
		::SetWindowText (XhwndEdit,"目前无法登陆该邮箱,请稍后再试");
		return false;
	}
	::SetWindowText (XhwndEdit,"开始登陆");
	if(!by->InInBox ()) return false;
	::SetWindowText (XhwndEdit,"进入收件箱");
	if(by->GetDescribeFile ()==true)
	{
		
		::SetWindowText (XhwndEdit,"该邮箱支持描述文件。");
	}
	else
	{
	
		::SetWindowText (XhwndEdit,"该邮箱不支持描述文件,本版本要求邮箱必须支持描述文件,否则无法登录。");
		return 0;

	}
	::SendMessage (XhwndDownLoadFileList,WM_LOGINOK,NULL,NULL);

	//

	//
    return 0; 
} 

bool CLogInListCtrl::DeleteTheItem()
{
	int index = GetSelectedIndex();
	if(index==-1) return false;	

	::SetWindowText (hwndEdit,"删除邮箱");
	
	//删除
	XmlData.VDownLoadCode .erase (XmlData.VDownLoadCode.begin ()+index);
	XmlData.VLogInCode .erase (XmlData.VLogInCode .begin ()+index);
	XmlData.VName .erase (XmlData.VName .begin ()+index);

	XmlData.WriteData ();

	return true;
}	


LRESULT CLogInListCtrl::OnRButtonDown(UINT, CPoint pt)
{
	
	return true;
}

LRESULT CLogInListCtrl::OnContextMenu(HWND hwnd, CPoint pt) //处理快捷菜单
{
	
	int index = GetSelectedIndex();
	if(index==-1) return false;	


	HMENU hmenu;            // top-level menu 
    HMENU hmenuTrackPopup;  // shortcut menu 

	hmenu=::GetMenu (this->hwndMain );
	hmenuTrackPopup=::GetSubMenu (hmenu,0);
	 TrackPopupMenu(hmenuTrackPopup, 
            TPM_LEFTALIGN | TPM_RIGHTBUTTON, 
			pt.x, pt.y, 0,this->hwndMain, NULL);

	return true;
}

⌨️ 快捷键说明

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