Solved

Mousepointer in a textbox- picturebox vb6

Posted on 2014-09-09
7
125 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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 47

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 47

Expert Comment

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

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

751 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