Solved

Mousepointer in a textbox- picturebox vb6

Posted on 2014-09-09
7
116 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
  • 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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 45

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 45

Expert Comment

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now