標籤:style blog http color io os 使用 ar strong
想做一個案頭時鐘,釘在案頭上不影響正常使用,只在看案頭的時候顯示。
從網上多方尋找找到這麼個代碼,但是還是有不方便的地方,大家探討一下。
這個程式在使用“顯示案頭”的時候還可以顯示,將程式的Form1.cs改為:
[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);
- }
- }
- }
代碼的是:http://download.csdn.net/detail/icyfox_bupt/4382848 沒資源分
這個程式的問題在於,如果我想寫:
[csharp] view plaincopy
- this.FormBorderStyle=None
就是設定無邊框程式,就沒法釘在案頭,就成了正常的程式了
大家一起來討論一下吧。
C#表單釘在案頭、置底、嵌入案頭的辦法