Solved

Mousepointer in a textbox- picturebox vb6

Posted on 2014-09-09
7
121 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
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 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

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!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

679 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