【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,DialogUser.cpp,希望对大家有所帮助!
// DialogUser.cpp : implementation file
//
#include "stdafx.h"
#include "MyNetChat.h"
#include "MyNetChatDlg.h"
#include "DialogUser.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogUser dialog
CDialogUser::CDialogUser(CWnd* pParent /*=NULL*/)
: CDialog(CDialogUser::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogUser)
//}}AFX_DATA_INIT
}
void CDialogUser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogUser)
DDX_Control(pDX, IDC_USERDLG, m_aduser);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogUser, CDialog)
//{{AFX_MSG_MAP(CDialogUser)
ON_BN_CLICKED(IDOK, OnAdduser)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogUser message handlers
void CDialogUser::OnAdduser()
{
// TODO: Add my friends
CString Usertext;
char *lpsztext=NULL;
CString nitemstr;
int nitem;
m_aduser.GetWindowText(Usertext);
CMyNetChatDlg *MainDlg=(CMyNetChatDlg*)AfxGetApp()->m_pMainWnd;
nitem=::GetPrivateProfileInt("UserName","NCount",0,".\\MyNetChat.ini");
MainDlg->m_List.GetItemText(0,0,lpsztext,sizeof(lpsztext));
if(lpsztext!=NULL)
{
nitem++;
}
nitemstr.Format("%d",nitem);
AfxMessageBox(lpsztext);
AfxMessageBox(nitemstr);
MainDlg->m_List.InsertItem(nitem,Usertext,0);
::WritePrivateProfileString("UserName","Name"+nitemstr,Usertext,".\\MyNetChat.ini");
::WritePrivateProfileString("UserName","NCount",nitemstr,".\\MyNetChat.ini");
OnOK();
}
上一篇:
DialogToolBarDLG.cpp
下一篇:
如何当一个轻松的班主任