做了一个简易的QQ界面
1 功能:点击 我的好友会出现好友列表
点击 QQ群会出现QQ群列表
点击 最近联系人 会出现联系人列表
点击 右上方的叉叉 就能关闭了
实现步骤
把窗口的FormBorderStyle设置为none
再把背景图片设置为QQ界面
然后拖一个panel到窗口中
再拖3个 button和一个listview到panel中
拖到panel中 你就可以设置定位
比如把QQ群这个按钮设置到panel的底部
再拖两个 imagelist
为了保存好友的头像和群组的头像
具体代码如下
还有一个要点是 Dock根据拖进窗口的先后来排优先级
因为这个我浪费了很多时间
一直想不明白
private void Form1_Load(object sender, EventArgs e)
{
qqlistView.LargeImageList = userImagelist;
qqlistView.SmallImageList = groupImagelist;
friendButton.SendToBack();//可以设置控件的层次
friendButton.Dock = DockStyle.Top;
qqlistView.Dock = DockStyle.Top;
groupButton.Dock = DockStyle.Bottom;
recentButton.SendToBack();
recentButton.Dock = DockStyle.Bottom;
qqlistView.View = View.Tile;
qqlistView.Clear();
qqlistView.Items.Add("大娃", 0);//添加项目
qqlistView.Items.Add("二娃", 1);
qqlistView.Items.Add("三娃", 2);
qqlistView.Items.Add("四娃", 3);
qqlistView.Items.Add("五娃", 4);
qqlistView.Items.Add("六娃", 5);
qqlistView.Items.Add("七娃", 6);
}
private void recentButton_Click(object sender, EventArgs e)
{
recentButton.Dock = DockStyle.Top;
qqlistView.Dock = DockStyle.Top;
friendButton.Dock = DockStyle.Bottom;
groupButton.SendToBack();
groupButton.Dock = DockStyle.Bottom;
qqlistView.View = View.Tile;
qqlistView.Clear();
qqlistView.Items.Add("大娃", 0);
qqlistView.Items.Add("二娃", 1);
qqlistView.Items.Add("三娃", 2);
qqlistView.Items.Add("四娃", 3);
}
private void groupButton_Click(object sender, EventArgs e)
{
groupButton.Dock = DockStyle.Top;
qqlistView.Dock = DockStyle.Top;
friendButton.Dock = DockStyle.Bottom;
recentButton.SendToBack();
recentButton.Dock = DockStyle.Bottom;
qqlistView.View = View.List;
qqlistView.Clear();
qqlistView.Items.Add("熊大", 0);
qqlistView.Items.Add("熊二", 1);
qqlistView.Items.Add("熊三", 2);
}
private void CloseLabel_Click(object sender, EventArgs e)
{
Close();
}
private void friendButton_Click(object sender, EventArgs e)
{
qqlistView.LargeImageList = userImagelist;
qqlistView.SmallImageList = groupImagelist;
friendButton.Dock = DockStyle.Top;
qqlistView.Dock = DockStyle.Top;
recentButton.Dock = DockStyle.Bottom;
groupButton.Dock = DockStyle.Bottom;
friendButton.SendToBack();
recentButton.SendToBack();
qqlistView.View = View.Tile;
qqlistView.Clear();
qqlistView.Items.Add("大娃", 0);
qqlistView.Items.Add("二娃", 1);
qqlistView.Items.Add("三娃", 2);
qqlistView.Items.Add("四娃", 3);
qqlistView.Items.Add("五娃", 4);
qqlistView.Items.Add("六娃", 5);
qqlistView.Items.Add("七娃", 6);
}
private int startX, startY;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
startX = e.X;
startY = e.Y;
}
}
private void Form1_MouseMove(object sender, MouseEventArgs e)//移动窗口
{
if(e.Button==MouseButtons.Left)
{
this.Left += e.X - startX;
this.Top += e.Y - startY;
}
}