[wpf]自定義滑鼠指標
周銀輝看看wpf cursor類的兩個建構函式吧:
public
cursor(stream cursorstream)
public
cursor(
string
cursorfile)
恩, 均要求用 ani 或 cur, 無語啊,我要使用一張普通呢? 或者甚至是在程式記憶體中動態生成一張而生成滑鼠指標呢?
於是乎, 我們可以折騰出如下**, 它可以從由一張來建立滑鼠指標:
//////
this class allow you create a cursor form a bitmap
///internal
class
bitmapcursor : safehandle
}public
static
cursor createbmpcursor(bitmap cursorbitmap)
protected
bitmapcursor(bitmap cursorbitmap)
: base
((intptr)(-1
), true
)protected
override
bool
releasehandle()
[dllimport(
"user32")]
private
static
extern
bool
destroyicon(intptr hicon);
}下面是一段示例**:
private
static
cursor createmycursor()
有人會說"啊!bitmap? winform的! 就不可以從wpf的影象來生成麼?"
那麼免費贈送如下函式:
public
static
bitmap bitmapsourcetobitmap(
this
bitmapsource source)
}
WPF 自定義滑鼠樣式
this class allow you create a cursor form a bitmap internal class bitmapcursor safehandle public static cursor createbmpcursor bitmap cursorbitmap pub...
使用自定義的滑鼠指標
using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.text using system.window...
wpf 修改輸入框 游標 WPF 自定義滑鼠游標
在程式中使用自定義滑鼠游標的三種方式 radiobutton senderbutton sender as radiobutton 方式一 string cursorpath directory.getcurrentdirectory cursorpath mycursor.cur senderbu...