【问题标题】:WPF-Window between desktop and icons (Windows 8.1)桌面和图标之间的 WPF-Window (Windows 8.1)
【发布时间】:2015-10-14 09:41:22
【问题描述】:

我使用了来自 CodeProject 的精彩文章。 http://www.codeproject.com/Articles/856020/Draw-Behind-Desktop-Icons-in-Windows 这个项目在 Windows 8.1 上对我来说运行良好

使用表单的示例。现在我将更改表格 到 WPF-Window(使用 Visualstudio 2015 和 .net 4.5.2)。

// The WPF-Window for infos behind the icon
public partial class InfoBehindIcon : Window
{
    public InfoBehindIcon()
    {
        InitializeComponent();
        // in .xaml: the decoration switched off
    }
}

// The MainWindow - class
    ....
    private HInfoBehindIcon.InfoBehindIcon infoBehindIcon = new HInfoBehindIcon.InfoBehindIcon(); 

    public MainWindow()
    {
        InitializeComponent();
         ....
        iniDesktopHandlerWPF();

        ... in CodeProject example starting here the Form with
         //   System.Windows.Forms.Application.Run(InfoBIForm);
        ... how to start here the WPF-Window behind the Icon?

    }

    private void iniDesktopHandlerWPF()
    {
       ... Code from CodeProject example 
        if(dc != IntPtr.Zero)
        {
            // here I change the Form to WPF-Window
            infoBehindIcon.Loaded += infoBehindIcon_EventWPF;
        }
    }

    private void infoBehindIcon_EventWPF(object sender, EventArgs e)
    {
        infoBehindIcon.Topmost = false;
        InfoPanel.HW32.SetParent(new WindowInteropHelper(infoBehindIcon).Handle, workerw);
    }

使用表单的版本运行没有问题。 当我尝试对 WPF 进行更改时,第二个窗口正在启动,但是 它没有在桌面和图标之间运行。 有没有办法解决这个问题? 还是更好地使用表格? (对不起,我是 C# 的新手)

【问题讨论】:

    标签: c# .net wpf windows


    【解决方案1】:

    这个问题太简单太容易了。我解决了这个

        public MainWindow()
        {
            InitializeComponent();
             ....
            iniDesktopHandlerWPF();
    
            ... in CodeProject starting here the Form with
             //   System.Windows.Forms.Application.Run(InfoBIForm);
            ... how to start here the WPF-Window behind the Icon?
    
        }
    

        public MainWindow()
        {
            InitializeComponent();
             ....
            iniDesktopHandlerWPF();
    
            ... in CodeProject starting here the Form with
             //   System.Windows.Forms.Application.Run(InfoBIForm);
            ... how to start here the WPF-Window behind the Icon?
    
            infoBehindIcon.Show();          
        }
    

    现在它对我来说很好用。我没看到……;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-25
      • 2023-04-09
      相关资源
      最近更新 更多