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
- Using System;
- Using System.Collections.Generic;
- Using System.ComponentModel;
- Using System.Data;
- Using System.Drawing;
- Using System.Text;
- Using System.Windows.Forms;
- Using System.Runtime.InteropServices;
- Namespace Cbgfinder
- {
- Public partial class Form1:form
- {
- [DllImport ("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr FindWindow ([MarshalAs (UNMANAGEDTYPE.LPTSTR)] string Lpclassname, [ MarshalAs (UNMANAGEDTYPE.LPTSTR)] string lpwindowname);
- [DllImport ("user32")]
- private static extern IntPtr FindWindowEx (IntPtr hWnd1, IntPtr hWnd2, string lpsz1, string lpsz2);
- [DllImport ("user32.dll")]
- public static extern IntPtr SetParent (IntPtr hwndchild, IntPtr hwndnewparent);
- Public Form1 ()
- {
- InitializeComponent ();
- }
- private void Form1_Load (object sender, EventArgs e)
- {
- IntPtr pWnd = FindWindow ("ProgMan", null);
- PWnd = FindWindowEx (PWnd, IntPtr.Zero, "Shelldll_defview", null);
- PWnd = FindWindowEx (PWnd, IntPtr.Zero, "SysListView32", null);
- //intptr Twnd = new System.Windows.Interop.WindowInteropHelper (this). Handle;
- SetParent (This. Handle, pWnd);
- }
- }
- }
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
- 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