[.NET] resources檔案做cursor的兩種方法

看板Visual_Basic作者 (clark-tsai)時間10年前 (2014/05/03 23:33), 10年前編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
請輸入專案類型(網站專案或者應用程式專案):Visual Studio 2012 VB.NET 打擾各位了, 我是vb新手, 如有發言不當, 希望各位海涵... 最近想試著更換鼠標, 用了兩種方法但卻發生一點問題 方法一(直接用*.cur檔) dim ms as new system.io.memorystream(my.resources.pen) me.cursor = new cursor(ms) 卻出現以下錯誤訊息(節錄) System.ArgumentException: Image format is not valid. The image file may be corrupted. Parameter name: stream ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A01E1 (CTL_E_INVALIDPICTURE) at System.Windows.Forms.UnsafeNativeMethods.IPersistStream.Load(IStream pstm) at System.Windows.Forms.Cursor.LoadPicture(IStream stream) =>上述錯誤訊息我去google之後也沒發現任何有效的解法, 只得知可以使用方法二 我以為是我的*.cur有問題, 但我從windows\cursor下隨便抓出一個來測試, 也是出現一樣的錯誤訊息... --------- 方法二(使用*.png圖檔) dim cur as new bitmap(my.resources.cur) me.cursor = new cursor(cur.GetHicon) 這個方法可以成功編譯, 但卻發生了問題... 我用一個button, 我的鼠標要移到快中間, button才會感應到 如此圖所示, 我鼠標由下往上這時候才剛好button感應到 http://ppt.cc/Jn3o 我想是因為原本的鼠標太小, 而我的鼠標卻希望能在32*32pixel以上... 不知道有什麼方法可以解決我的問題, 先謝謝各位 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.231.69.139 ※ 文章網址: http://www.ptt.cc/bbs/Visual_Basic/M.1399131229.A.FF4.html ※ 編輯: reaper8046 (118.231.69.139), 05/03/2014 23:58:21

05/04 22:51, , 1F
jacascript = =?
05/04 22:51, 1F

05/06 14:16, , 3F
參考看看
05/06 14:16, 3F

05/07 18:26, , 4F
似乎還是一樣 但還是謝謝
05/07 18:26, 4F
文章代碼(AID): #1JPGnT_q (Visual_Basic)