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

📄 dlgtx.cpp

📁 一个类似与浩方的战网平台源代码
💻 CPP
字号:
// DlgTX.cpp : implementation file
//

#include "stdafx.h"
#include "LinKGameEx.h"
#include "DlgTX.h"

#include "MyStruct.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgTX dialog


CDlgTX::CDlgTX(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgTX::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgTX)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDlgTX::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgTX)
	DDX_Control(pDX, IDC_TXTZJDLSJ, m_txtZJDLSJ);
	DDX_Control(pDX, IDC_TXTPTPM, m_txtPTPM);
	DDX_Control(pDX, IDC_TXTNC, m_txtNC);
	DDX_Control(pDX, IDC_TXTLKBZ, m_txtLKBZ);
	DDX_Control(pDX, IDC_TXTID, m_txtID);
	DDX_Control(pDX, IDC_TXTGRXY, m_txtGRXY);
	DDX_Control(pDX, IDC_TXTDLCS, m_txtDLCS);
	DDX_Control(pDX, IDC_TXTDJ, m_txtDJ);
	DDX_Control(pDX, IDC_TXTCZCS, m_txtCZCS);
	DDX_Control(pDX, IDC_FRIENDLIST, m_FriendList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgTX, CDialog)
	//{{AFX_MSG_MAP(CDlgTX)
	ON_NOTIFY(NM_DBLCLK, IDC_FRIENDLIST, OnDblclkFriendlist)
	ON_NOTIFY(NM_CLICK, IDC_FRIENDLIST, OnClickFriendlist)
	ON_NOTIFY(NM_RCLICK, IDC_FRIENDLIST, OnRclickFriendlist)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgTX message handlers

BOOL CDlgTX::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CRect m_Rect(0, 0, 0, 0);
	GetParent()->GetClientRect(&m_Rect);
	((CTabCtrl*)GetParent())->AdjustRect(false, &m_Rect); 
	MoveWindow(&m_Rect);

	InitControl();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgTX::InitControl()
{
	FRIEND m_Friend[] =
	{
		{"AAAAA", 0, "济南", "30","30000"},
		{"BBBBB", 0, "青岛", "29","29000"},
		{"CCCCC", 0, "淄博", "28","28000"},
		{"DDDDD", 0, "潍坊", "27","27000"},
		{"EEEEE", 0, "威海", "31","31000"},
		{"FFFFF", 1, "日照", "30","30000"},
		{"GGGGG", 1, "泰安", "29","29000"},
	};
	// 初始化好友列表
	LV_COLUMN lvcol;
	LV_ITEM lvitem;
	int i, iPos, iItemNum;

	lvcol.mask = LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH;
	lvcol.fmt = LVCFMT_CENTER;

	i = 0;
	lvcol.pszText = "昵称";
	lvcol.iSubItem = i;
	lvcol.cx = 70;
	m_FriendList.InsertColumn(i++,&lvcol);

	lvcol.pszText = "地址";
	lvcol.iSubItem = i;
	lvcol.cx = 70;	
	m_FriendList.InsertColumn(i++,&lvcol);

	lvcol.pszText = "等级";
	lvcol.iSubItem = i;
	lvcol.cx = 70;
	m_FriendList.InsertColumn(i++,&lvcol);

	lvcol.pszText = "邻客币";
	lvcol.iSubItem = i;
	lvcol.cx = 70;
	m_FriendList.InsertColumn(i++,&lvcol);

	iItemNum = sizeof(m_Friend)/sizeof(FRIEND);
	for(i = 0 ; i < iItemNum; i++)
	{
		lvitem.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
		lvitem.iItem = i;
		lvitem.iSubItem = 0;
		lvitem.pszText = m_Friend[i].szName;
		lvitem.iImage = m_Friend[i].Lx;
		lvitem.lParam = i;

		//  Fan Hui Biao Xiang Cha Ru Hou De Suo Yin
		iPos = m_FriendList.InsertItem(&lvitem); 
		lvitem.mask = LVIF_TEXT;
		lvitem.iItem = iPos;

		lvitem.iSubItem = 1;
		lvitem.pszText = m_Friend[i].szAddress;
		m_FriendList.SetItem(&lvitem);
		
		lvitem.iSubItem = 2;
		lvitem.pszText = m_Friend[i].szLevel;
		m_FriendList.SetItem(&lvitem);
		
		lvitem.iSubItem = 3;
		lvitem.pszText = m_Friend[i].szMoney;
		m_FriendList.SetItem(&lvitem);
	}
}

void CDlgTX::OnDblclkFriendlist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	POSITION pos = m_FriendList.GetFirstSelectedItemPosition();
	int m_Index = m_FriendList.GetNextSelectedItem(pos);  // 得到项目索引
	if( m_Index != -1)
	{
		CString m_strName = m_FriendList.GetItemText(m_Index, 0);
		for(int i = 0; i < CHATCOUNT; i++)
		{
			if(this->m_Chatting[i].m_hWnd == NULL)
			{
				this->m_Chatting[i].Create(IDD_DLGCHATTING);
				this->m_Chatting[i].SetWindowText( "与 " + m_strName + " 聊天中...");
				this->m_Chatting[i].ShowWindow(1);
				break;
			}
		}
		CString m_strCount;
		m_strCount.Format( "%d", CHATCOUNT);
		if(i == CHATCOUNT) MessageBox( "为减少资源占用,最多与" + m_strCount + "人同时聊天,谢谢 !");
	}
	*pResult = 0;
}

void CDlgTX::OnClickFriendlist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	POSITION pos = m_FriendList.GetFirstSelectedItemPosition();
	int m_Index = m_FriendList.GetNextSelectedItem(pos);  // 得到项目索引
	if( m_Index == -1) return;
	CString m_strName = m_FriendList.GetItemText(m_Index, 0);


	TESTID m_TestID[] =
	{
		{"A1111", "10", "100", "1000", "房A", "11", "1111", "11", "2006-1-1"},
		{"B2222", "20", "200", "2000", "房B", "22", "2222", "22", "2006-2-2"},
		{"C3333", "30", "300", "3000", "房C", "33", "3333", "33", "2006-3-3"},
		{"D4444", "40", "400", "4000", "房D", "44", "4444", "44", "2006-4-4"},
		{"E5555", "50", "500", "5000", "房E", "55", "5555", "55", "2006-5-5"},
		{"F6666", "60", "600", "6000", "房F", "66", "6666", "66", "2006-6-6"},
		{"G7777", "70", "700", "7000", "房G", "77", "7777", "77", "2006-7-7"},
	};

	this->m_txtID.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szID);
	this->m_txtDJ.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szDJ);
	this->m_txtPTPM.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szPTPM);
	this->m_txtGRXY.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szGRXY);
	this->m_txtNC.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szNC);
	this->m_txtDLCS.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szDLCS);
	this->m_txtLKBZ.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szLKBZ);
	this->m_txtCZCS.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szCZCS);
	this->m_txtZJDLSJ.SetWindowText( m_TestID[rand()%(sizeof(m_TestID)/sizeof(TESTID))].szZJDLSJ);

	*pResult = 0;
}

void CDlgTX::OnRclickFriendlist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	CMenu pm;
	pm.LoadMenu( IDR_MYFRIENDMENU);
	CMenu *pPopup = pm.GetSubMenu(0);
	//ClientToScreen(&point); 
	POINT point;
	GetCursorPos( &point);
	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);

	*pResult = 0;
}

⌨️ 快捷键说明

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