国产探花免费观看_亚洲丰满少妇自慰呻吟_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;
}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 京山县| 驻马店市| 乌拉特前旗| 新竹县| 宣化县| 邢台县| 防城港市| 沁源县| 阳春市| 哈巴河县| 从化市| 鄂州市| 海晏县| 古蔺县| 水富县| 双桥区| 葵青区| 琼海市| 海淀区| 吉木乃县| 金秀| 许昌市| 确山县| 松原市| 泽普县| 龙泉市| 罗平县| 房山区| 大庆市| 陵水| 连城县| 崇明县| 安义县| 清苑县| 重庆市| 瑞金市| 凤冈县| 富源县| 繁昌县| 玛沁县| 新乡市|