Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mousepointer in a textbox- picturebox vb6

Posted on 2014-09-09
7
Medium Priority
?
129 Views
Last Modified: 2014-09-10
I have a textbox in a moveable picture box and want to change the mousepointer to vbdefault when over the textbox.The picturebox is set to size(5) in properties, but it will not change to default


Private Sub txtNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 txtNotes.MousePointer = vbDefault
End Sub


Private Sub picNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   'move the picturebox
  If Button = vbLeftButton Then
    picNotes.Move picNotes.Left + (X - NoteDragX), picNotes.Top + (Y - NoteDragY)
  End If
End Sub

How to to this ?
picturebox
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Expert Comment

by:vb_elmar
ID: 40313585
Try this: (you have to choose ANY .cur file from your computer):
Private Sub Form_Load()
    txtNotes.MouseIcon = LoadPicture("C:\mycursor.cur")
    txtNotes.MousePointer = 99 '99=Custom Mousepointer
End Sub

Private Sub txtNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 '''''txtNotes.MousePointer = vbDefault
End Sub


Private Sub picNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   'move the picturebox
  If Button = vbLeftButton Then
    picNotes.Move picNotes.Left + (X - NoteDragX), picNotes.Top + (Y - NoteDragY)
  End If
End Sub

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 40313592
Thanks vb_elmar, but in looking at your code
I want the textbox to vbdefault not a custom cursor

 txtNotes.MouseIcon = LoadPicture("C:\mycursor.cur")
    txtNotes.MousePointer = 99 '99=Custom Mousepointer
0
 
LVL 17

Expert Comment

by:vb_elmar
ID: 40313617
Alternatively you can try this:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub Form_Load()
    hWndChild = txtNotes.hWnd
    hWndNewParent = picNotes.hWnd
    SetParent hWndChild, hWndNewParent
End Sub

Private Sub txtNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 '''''txtNotes.MousePointer = vbDefault
End Sub

Private Sub picNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   'move the picturebox
  If Button = vbLeftButton Then
    picNotes.Move picNotes.Left + (X - NoteDragX), picNotes.Top + (Y - NoteDragY)
  End If
End Sub

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:isnoend2001
ID: 40315858
Hi vb_elmar
I get an error see below
hWndChild = txtNotes.hwnd 'error variable not defined here
    hWndNewParent = picNotes.hwnd
    SetParent hWndChild, hWndNewParent
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 40315972
The picturebox is set to size(5) in properties
I don't know what the above means but this works.

Private Sub txtNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    picNotes.MousePointer = vbDefault
End Sub


Private Sub picNotes_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    picNotes.MouseIcon = LoadPicture("C:\windows\cursors\move_m.cur")
    picNotes.MousePointer = 99 '99=Custom Mousepointer

   'move the picturebox
  If Button = vbLeftButton Then
    picNotes.Move picNotes.Left + (X - NoteDragX), picNotes.Top + (Y - NoteDragY)
  End If
End Sub

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 40315976
Thanks
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40315980
I'm always glad when I can help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question