国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

C#實現主窗體工具欄上按鈕兩幅圖片的交互效果

2024-07-21 02:18:25
字體:
來源:轉載
供稿:網友

初次發文,敬請包涵。
using system.runtime.interopservices;
窗口類添加以下成員或函數
private static int buttonindex;
[dllimport("user32", charset = charset.auto)]
public static extern intptr sendmessage(intptr hwnd, uint msg, uint wparam, ref point lparam);
public const int tb_hittest = 1093;
//本例為四個按鈕(注意:當添加屬性style為separator的按鈕后要作相應的變化)
//添加一個imagelist控件imagelist1(添加八個圖片依次為0...7,順序不能變,
//注意交互時圖片0,1,2,3分別對應圖片4,5,6,7)
//添加一個toolbar控件toolbar1(其imagelist屬性為imagelist1,
//四個按鈕的imageindex分別為0,1,2,3)

//工具欄mousemove事件
private void toolbar1_mousemove(object sender, system.windows.forms.mouseeventargs e)
{
point pt = new point(e.x, e.y);
intptr result =
sendmessage(this.toolbar1.handle, tb_hittest, 0, ref pt);
buttonindex = result.toint32();
const int lowbtnindex = 0;
const int highbtnindex =3;
if((buttonindex >= lowbtnindex ) && (buttonindex <= highbtnindex))
{
for(int u=0;u<4;u++)
{
if(u==buttonindex)
this.toolbar1.buttons[buttonindex].imageindex=4+buttonindex;
else
this.toolbar1.buttons[u].imageindex=u;
}
}
else
{
for(int u=0;u<4;u++)
this.toolbar1.buttons[u].imageindex=u;
}
}

//工具欄mouseleave事件
private void toolbar1_mouseleave(object sender, system.eventargs e)
{
if((buttonindex >= 0) && (buttonindex <=3))
{
this.toolbar1.buttons[buttonindex].imageindex=buttonindex;
}
buttonindex=4;
}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高青县| 井陉县| 曲水县| 峨眉山市| 静乐县| 潼南县| 凤阳县| 东乌珠穆沁旗| 石楼县| 万州区| 西青区| 景宁| 芒康县| 罗平县| 洛隆县| 陆川县| 民权县| 平果县| 滨州市| 闵行区| 平泉县| 黄大仙区| 钦州市| 河津市| 安仁县| 娱乐| 梁平县| 凤山市| 平乡县| 时尚| 沂源县| 亳州市| 石楼县| 儋州市| 淳安县| 柞水县| 宜兰县| 阳泉市| 阳春市| 云南省| 建水县|