Results 1 to 9 of 9

Thread: [RESOLVED] Trying to get custom mouse cursor to load when the mouse is over a picture box?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Resolved [RESOLVED] Trying to get custom mouse cursor to load when the mouse is over a picture box?

    Hello everyone! I am working on a simple tool to help draw the computer, so when I teach students I can use these touch screen computers they have now. So the students can see my mouse cursor easier, I would like to use a custom one that looks like a big pencil.

    I can get the pencil to show up when I am on the form itself, but when I go over the picturebox to draw, it just gives me the default windows one.

    I am using mouse down, and mouse move to "Draw", and this code to try to load the mouse cursor for the mouse move event, but still no change.

    Picture1.MousePointer = LoadCursorFromFileW(StrPtr(App.Path & "\Pencil.cur"))

    Has anyone else run across this problem? Can a picture box have a custom mouse over it? Thanks!

  2. #2
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,272

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    You need to assign the picture to the MouseIcon property and set the MousePointer property to '99 - Custom'

    The MousePointer property DOES NOT hold the cursor!
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    Good idea. I can perhaps make the cursor into a gif file, and assign it. The only thing is, I cannot open the cur file with my paint programs or paint.net, do you know of a prog that will open this cursor? THANKS!
    Attached Files Attached Files

  4. #4
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,272

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    My posted wasn't intended as an 'idea'. I was describing how you are supposed to use the MousePointer property. Perhaps you can use your current graphic (Pencil.cur) in the way you did previously;

    i.e.
    Picture1.MousePinter = 99
    Picture1.MouseICON = LoadCursorFromFileW(StrPtr(App.Path & "\Pencil.cur"))
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    Thank you! I am getting a type mismatch error on the line Picture1.MouseIcon = LoadCursorFromFileW(StrPtr(App.Path & "\Pencil.cur")), is there is anything I need to add before it?

  6. #6
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    If you only have one PictureBox in your Form, then see this post in your previous thread, else you'll have to convert your pencil.cur, which is actually an .ANI cursor file, to the real .CUR format or .ICO format because VB can't load .ANI cursors. IrfanView can convert your .ANI cursor to .ICO which VB's PictureBox can then use as the MouseIcon by loading through LoadPicture() or setting via the Properties Window.
    Last edited by Bonnie West; Mar 17th, 2013 at 02:09 AM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    That works great. I got the ico file, and it loads up just fine. The only issue is what was the transparent background is now black. I opened the file up, took out the black background, then saved it, but then vb says invalid file type, so then I go back into infraview, save it, then it is saved as a black background again lol. Is there a way to remove the background? Thanks!

  8. #8
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    Before saving that .ANI cursor as an .ICO file, IrfanView will allow you to select the transparent color. Did you dismiss that dialog?
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Trying to get custom mouse cursor to load when the mouse is over a picture box?

    I guess I did! Thank you so much Bonnie that did the trick!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width