[英]C# tooltip : need cursor visibility set to false
是否可以在工具提示可見時將光標可見性設置為false,並在工具提示消失時再次返回true?
正如sa_ddam213所說:
只需使用Cursors.None屬性
或者你可以手動執行此操作由之前設置一個透明光標圖像ToolTip.Show()
和后ToolTip.Hide()
只是正常顯示光標:
CursorHandler.LoadCursor("ProjName.Resources.Invisible.cur");
ToolTip.Show();
...
ToolTip.Hide();
CursorHandler.LoadCursor("ProjName.Resources.Normal.cur");
這是CursorHandler代碼(我從http://www.codeproject.com/Articles/36540/Adobe-Eyedropper-Control獲得 ):
public class CursorHandler
{
[DllImport("user32.dll")]
private static extern IntPtr LoadCursorFromFile(string fileName);
public static Cursor LoadCursor(string resourcePath)
{
Cursor c = new Cursor(getCursorHandle(resourcePath));
return c;
}
private static IntPtr getCursorHandle(string resourcePath)
{
//Load cursor from Manifest Resource to Stream
Stream streamFrom =
Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath);
Stream streamTo =
File.Create(Environment.GetEnvironmentVariable("TEMP") + @"\~cur.tmp");
BinaryReader br = new BinaryReader(streamFrom);
BinaryWriter bw = new BinaryWriter(streamTo);
//Write cursor to temporary file
bw.Write(br.ReadBytes((int)streamFrom.Length));
bw.Flush();
bw.Close();
br.Close();
bw = null;
br = null;
streamFrom.Close();
streamTo.Close();
streamFrom = null;
streamTo = null;
//Load handle of temporary cursor file
IntPtr hwdCursor = LoadCursorFromFile(
Environment.GetEnvironmentVariable("TEMP") + @"\~cur.tmp");
//Delete temporary cursor file
File.Delete(Environment.GetEnvironmentVariable("TEMP") + @"\~cur.tmp");
return hwdCursor;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.