如图设置好登陆窗口。
添加一个picturebox 作为显示图片
添加2个lable静态文本框。一个帐号,一个密码
添加一个combobox 选择框
一个textbox 密码框
两个button 一个作为登陆,一个作为注册
两个checkbox 选择框 一个记住密码,一个隐身登陆。
详细代码
private void login_Click(object sender, System.EventArgs e)
{
string uid;
bool RememberMe=this.checkBox1.Checked;
if(this.comboBox1.SelectedText=="")
{
uid=this.comboBox1.Text;
}
else
{
uid=this.comboBox1.SelectedText;
}
string pwd=this.textBox2.Text;
if(!Regx.isNull(uid)||!Regx.isNull(pwd))
{
MessageBox.Show("请输入用户名或密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
if(Regx.isNumber(uid))
{
UserInf.AddUser(uid,pwd,RememberMe);
this.Visible=false;
main Q_main=new main(uid,pwd);
ShareDate.MainFormHand=Q_main.Handle.ToInt32();
Q_main.Show();
}
else
{
MessageBox.Show("请输入合法的QQ号码!","错误",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}
private void button1_Click(object sender, System.EventArgs e)
{
PlaySound.play(1);
}
private void Form1_Load(object sender, System.EventArgs e)
{
QQloginCont.UserInf.DelFile(Application.StartupPath+"\\SerInf\\OnlineInf.dat");
DataTable dt=UserInf.GetUserInf();
if(dt!=null)
{
this.comboBox1.DataSource=dt;
this.comboBox1.DisplayMember="user";
this.comboBox1.ValueMember="pwd";
}
this.textBox2.Text="";
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.textBox2.Text=this.comboBox1.SelectedValue.ToString().Trim();
}
private void reg_Click(object sender, System.EventArgs e)
{
if(MessageBox.Show("客户端现在未开放注册接口!若需要注册,请到官网!\n点击是访问官网","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.Yes)
{
string SerInfFile="SerInf\\SerInf.dat";
string StrIp=getSerInf.ReadXmlNode(SerInfFile,"//root//server//ip");
System.Diagnostics.Process.Start("http://"+StrIp+"/QQWebSite/Default.aspx");
}
}
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
MessageBox.Show("功能未开放!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
添加一个from窗体
0 评论:
发表评论