wpf jumplist demo
来源:互联网 发布:怎么选课尔雅网络课程 编辑:程序博客网 时间:2024/05/22 11:59
直接上代码。
/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{[DllImport("user32.dll", CharSet = CharSet.Auto)]public static extern int RegisterWindowMessage(string msg);private HwndSource _HwndSource = null;private IntPtr _Handler = IntPtr.Zero;private readonly int Message1 = RegisterWindowMessage("Message_1");private readonly int Message2 = RegisterWindowMessage("Message_2");private readonly int Message3 = RegisterWindowMessage("Message_3");public MainWindow(){InitializeComponent();this.SourceInitialized += new EventHandler(MainWindow_SourceInitialized);this.Loaded += new RoutedEventHandler(MainWindow_Loaded);}void MainWindow_Loaded(object sender, RoutedEventArgs e){this.LoadJumpList(); }void MainWindow_SourceInitialized(object sender, EventArgs e){this._HwndSource = PresentationSource.FromVisual((Visual)sender) as HwndSource;this._Handler = this._HwndSource.Handle;this._HwndSource.AddHook(this.WindowProc);}public IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled){if (msg == Message1){MessageBox.Show("Message_1");}else if (msg == Message2){MessageBox.Show("Message_2");}else if (msg == Message3){MessageBox.Show("Message_3");}return IntPtr.Zero;}private void LoadJumpList(){JumpList jumpList = JumpList.GetJumpList(Application.Current);if (jumpList != null && jumpList.JumpItems != null && jumpList.JumpItems.Count > 0)jumpList.JumpItems.Clear();JumpTask jtNotpad = new JumpTask(){ApplicationPath = "notepad.exe",CustomCategory = "工具",Description = "记事本",Title = "记事本",IconResourcePath = "notepad.exe",IconResourceIndex = 0};JumpTask jtMsPaint = new JumpTask(){ApplicationPath = "mspaint.exe",CustomCategory = "工具",Description = "画图",Title = "画图",IconResourcePath = "mspaint.exe",IconResourceIndex = 0};JumpTask jtCalc = new JumpTask(){ApplicationPath = "calc.exe",CustomCategory = "工具",Description = "计算器",Title = "计算器",IconResourcePath = "calc.exe",IconResourceIndex = 0};int windowInt = this._Handler.ToInt32();JumpTask jtMessage1 = new JumpTask(){CustomCategory = "Message",Description = "Message1",Title = "Message1",ApplicationPath = Assembly.GetEntryAssembly().CodeBase,Arguments = windowInt + " " + Message1};JumpTask jtMessage2 = new JumpTask(){CustomCategory = "Message",Description = "Message2",Title = "Message2",ApplicationPath = Assembly.GetEntryAssembly().CodeBase,Arguments = windowInt + " " + Message2};JumpTask jtMessage3 = new JumpTask(){CustomCategory = "Message",Description = "Message3",Title = "Message3",ApplicationPath = Assembly.GetEntryAssembly().CodeBase,Arguments = windowInt + " " + Message3};if (jumpList == null)jumpList = new JumpList();jumpList.JumpItems.Add(jtNotpad);jumpList.JumpItems.Add(jtMsPaint);jumpList.JumpItems.Add(jtCalc);jumpList.JumpItems.Add(jtMessage1);jumpList.JumpItems.Add(jtMessage2);jumpList.JumpItems.Add(jtMessage3);jumpList.ShowFrequentCategory = true;jumpList.ShowRecentCategory = true;jumpList.Apply();this.ShowInTaskbar = true;}}
/// <summary> /// App.xaml 的交互逻辑 /// </summary> public partial class App : Application { [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); public App() { string[] args = Environment.GetCommandLineArgs(); if (args.Length == 3) { //处理JumpList自定义按钮操作 int handler = Int32.Parse(args[1]); uint msg = UInt32.Parse(args[2]); if (handler != 0 && msg != 0) { SendMessage((IntPtr)handler, msg, IntPtr.Zero, IntPtr.Zero); } Application.Current.Shutdown(); return; } } }
0 0
- wpf jumplist demo
- WPF数据修改demo
- WPF Style demo
- WPF MVVM Demo
- WPF-MVVM-Demo
- QML类型说明-JumpList
- wpf实现iphone滑动效果demo
- WPF Control 控件介绍【附Demo】
- WPF Control 控件介绍【附Demo】
- WPF 多个数据源的实现DEMO
- WPF 实现新手指引功能 DEMO
- DotNET平台下添加JumpList
- Jumplist 用VS2010为Windows7开发应用
- WPF中ListView小Demo的数据绑定应用.
- wpf三维呈现技术web应用demo欣赏
- 使用Prism实现的WPF MVVM点餐Demo
- WPF中ListView小Demo的数据绑定应用
- WPF写的一个使用Log4net.dll库的demo
- 使用文章来增加流量和排名
- WPF 在代码中Binding
- wpf中listview添加排序
- HttpWebRequest下载文件带进度条
- java笔试 打印两个并排三角形
- wpf jumplist demo
- 八卦以象告章
- SynchronizationContext
- 多线程下载或上传数据限速
- popup non topmost
- Mysql安装配置,修改初试密码。
- Java读写文本文件。
- AJAX 跨域访问 — 方法大全
- Java Tutorial