C # forms pinned to the desktop, bottom, embedded in the desktop approach

Source: Internet
Author: User

Want to make a desktop clock, nailed on the desktop does not affect the normal use, only when looking at the desktop display.

Find this code from the online multi-party, but there are still inconvenient places, we discuss.

This program can also display when using "Show desktop", change the Form1.cs of the program to:

[CSharp]View Plaincopy
  1. Using System;
  2. Using System.Collections.Generic;
  3. Using System.ComponentModel;
  4. Using System.Data;
  5. Using System.Drawing;
  6. Using System.Text;
  7. Using System.Windows.Forms;
  8. Using System.Runtime.InteropServices;
  9. Namespace Cbgfinder
  10. {
  11. Public partial class Form1:form
  12. {
  13. [DllImport ("user32.dll", CharSet = CharSet.Auto)]
  14. public static extern IntPtr FindWindow ([MarshalAs (UNMANAGEDTYPE.LPTSTR)] string Lpclassname, [  MarshalAs (UNMANAGEDTYPE.LPTSTR)] string lpwindowname);
  15. [DllImport ("user32")]
  16. private static extern IntPtr FindWindowEx (IntPtr hWnd1, IntPtr hWnd2, string lpsz1, string lpsz2);
  17. [DllImport ("user32.dll")]
  18. public static extern IntPtr SetParent (IntPtr hwndchild, IntPtr hwndnewparent);
  19. Public Form1 ()
  20. {
  21. InitializeComponent ();
  22. }
  23. private void Form1_Load (object sender, EventArgs e)
  24. {
  25. IntPtr pWnd = FindWindow ("ProgMan", null);
  26. PWnd = FindWindowEx (PWnd, IntPtr.Zero, "Shelldll_defview", null);
  27. PWnd = FindWindowEx (PWnd, IntPtr.Zero, "SysListView32", null);
  28. //intptr Twnd = new System.Windows.Interop.WindowInteropHelper (this).  Handle;
  29. SetParent (This.  Handle, pWnd);
  30. }
  31. }
  32. }

The code is: http://download.csdn.net/detail/icyfox_bupt/4382848 No resources

The problem with this program is that if I want to write:

[CSharp]View Plaincopy
    1. This. Formborderstyle=none

is to set up a borderless program, you can not be nailed to the desktop, it is a normal program

Let's discuss it together.

C # forms pinned to the desktop, bottom, embedded in the desktop approach

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.