您的位置:首页 > 其它

Windows Mobile 功能导航界面的设计(1)

2009-09-20 13:00 441 查看
在 Windows Mobile 系统中,程序和设置使用 ListView 控件进行导航,以图标和文字的方式向用户展现系统中的各种应用程序和设置,如下图所示:

隐藏 ListView 边框
public Form1()
{
InitializeComponent();

ShowBorder(listView1.Handle, false);
ShowBorder(listView2.Handle, false);
ShowBorder(listView3.Handle, false);
}

const int GWL_STYLE = -16;
const int WS_BORDER = 0x00800000;
const int SWP_NOSIZE = 0x1;
const int SWP_NOMOVE = 0x2;
const int SWP_FRAMECHANGED = 0x20;

[DllImport("coredll.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

[DllImport("coredll.dll")]
private extern static void SetWindowLong(IntPtr hwnd, int nIndex, int dwNewLong);

[DllImport("coredll.dll")]
private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int uflags);

private void ShowBorder(IntPtr handle, bool bShow)
{
int style = GetWindowLong(handle, GWL_STYLE);
if (bShow)
{
style |= WS_BORDER;
}
else
{
style &= ~WS_BORDER;
}
SetWindowLong(handle, GWL_STYLE, style);
SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}
效果如下图所示:





现在看起来是不是好多了。用 ListView 作为功能导航界面基本可以满足要求,如果你觉得整个界面都是图标比较单调,可以用 PictureBox 在窗体上方放一张图片,而 TabControl 在图片的下方填满剩余的空间,这样看上去会更加专业,你们可以自己试一试。关于 ListView 作为功能导航界面的介绍就到这,你们可以下载本文的示例代码试试。

示例代码(已更新):ListViewNav.zip

作者:黎波
博客:http://bobli.cnblogs.com/
日期:2009年9月20日
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: