Solved

Mousepointer in a textbox- picturebox vb6

Posted on 2014-09-09
7
128 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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 48

Accepted Solution

by:
Martin Liss earned 500 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 48

Expert Comment

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

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

617 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