|
-
Jan 3rd, 2010, 11:07 AM
#1
Thread Starter
PowerPoster
[RESOLVED] i'm tryng clean a string without sucess:(
heres my MouseIcon property:
Code:
Public Property Let MouseIcon(ByVal vNewValue As String)
strMouseIcon = vNewValue
If strMouseIcon = "" Then
UserControl.MousePointer = 0
RestoreLastCursor
Exit Property
End If
If ValidMouse(UCase(strMouseIcon)) = False Then Exit Property
If UCase(strMouseIcon) Like "*.ANI" = True Then
If Ambient.UserMode = True Or blnEnter = True Then
SaveLastCursor
StartAnimatedCursor strMouseIcon
End If
Else
If strMouseIcon <> "" Then
UserControl.MousePointer = 99
UserControl.MouseIcon = LoadPicture(strMouseIcon)
Else
RestoreLastCursor
UserControl.MousePointer = 0
End If
End If
PropertyChanged "MouseIcon"
End Property
and heres the module for work with animated cursors:
Code:
Option Explicit
Private Declare Function LoadCursorFromFile Lib "user32" Alias _
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetSystemCursor Lib "user32" _
(ByVal hcur As Long, ByVal id As Long) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function CopyIcon Lib "user32" (ByVal hcur As Long) As Long
Private Const OCR_NORMAL = 32512
Private mlngOldCursor As Long
Private lngNewCursor As Long
Public Sub SaveLastCursor()
mlngOldCursor = CopyIcon(GetCursor())
End Sub
Public Sub StartAnimatedCursor(AniFilePath As String)
lngNewCursor = LoadCursorFromFile(AniFilePath)
SetSystemCursor lngNewCursor, OCR_NORMAL
End Sub
Public Sub RestoreLastCursor() 'Restore last cursor
SetSystemCursor mlngOldCursor, OCR_NORMAL
End Sub
to be honestly my property is empty, but the strMouseIcon still having the valeu. sometimes i don't understand somethings.
can anyone explain to me what isn't right?
thanks
-
Jan 3rd, 2010, 11:11 AM
#2
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
-
Jan 3rd, 2010, 11:23 AM
#3
Re: i'm tryng clean a string without sucess:(
What do you mean "clean a string"? You empty a string by setting it to vbNullString. Nowhere in your posted code are you doing that. The only way strMouseIcon can be empty is if it is passed that way to your property as vNewValue
-
Jan 3rd, 2010, 11:28 AM
#4
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
 Originally Posted by LaVolpe
What do you mean "clean a string"? You empty a string by setting it to vbNullString. Nowhere in your posted code are you doing that. The only way strMouseIcon can be empty is if it is passed that way to your property as vNewValue
ín these case the vNewValue is ""(empty).
but in debug is showed the strMouseIcon value.
why these is appen?
-
Jan 3rd, 2010, 12:08 PM
#5
Re: i'm tryng clean a string without sucess:(
Recommend searching your project for lines like: strMouseIcon =
You might be setting the variable elsewhere in your project.
-
Jan 3rd, 2010, 12:19 PM
#6
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
 Originally Posted by LaVolpe
Recommend searching your project for lines like: strMouseIcon =
You might be setting the variable elsewhere in your project.
ok. i will try. but why i don't recive the value in property page section and in porperty window?
-
Jan 3rd, 2010, 12:23 PM
#7
Re: i'm tryng clean a string without sucess:(
Maybe you should show us your Property Get MouseIcon routine?
-
Jan 3rd, 2010, 12:26 PM
#8
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
 Originally Posted by LaVolpe
Maybe you should show us your Property Get MouseIcon routine?
Code:
Public Property Get MouseIcon() As String
MouseIcon = strMouseIcon
End Property
Public Property Let MouseIcon(ByVal vNewValue As String)
strMouseIcon = vNewValue
Debug.Print strMouseIcon
If strMouseIcon = "" Then
UserControl.MousePointer = 0
Debug.Print strMouseIcon
Exit Property
End If
If ValidMouse(UCase(strMouseIcon)) = False Then Exit Property
If UCase(strMouseIcon) Like "*.ANI" = True Then
If Ambient.UserMode = True Or blnEnter = True Then
SaveLastCursor
StartAnimatedCursor strMouseIcon
End If
Else
If strMouseIcon <> "" Then
UserControl.MousePointer = 99
UserControl.MouseIcon = LoadPicture(strMouseIcon)
Else
RestoreLastCursor
UserControl.MousePointer = 0
UserControl.MouseIcon = Empty
End If
End If
PropertyChanged "MouseIcon"
End Property
-
Jan 3rd, 2010, 12:28 PM
#9
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
Code:
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If x > MousePos.x Then
mdMouseDirection = MouseDirectionRight
ElseIf x < MousePos.x Then
mdMouseDirection = MouseDirectionLeft
ElseIf y < MousePos.y Then
mdMouseDirection = MouseDirectionUp
ElseIf y > MousePos.y Then
mdMouseDirection = MouseDirectionDown
ElseIf x < MousePos.x And y < MousePos.y Then
mdMouseDirection = MouseDirectionLeftUp
ElseIf x < MousePos.x And y > MousePos.y Then
mdMouseDirection = MouseDirectionLeftDown
ElseIf x > MousePos.x And y < MousePos.y Then
mdMouseDirection = MouseDirectionRightDown
ElseIf x < MousePos.x And y > MousePos.y Then
mdMouseDirection = MouseDirectionRightUp
End If
MousePos.x = x
MousePos.y = y
mbMouseButton = Button
skShift = Shift
With UserControl
If GetCapture <> .hWnd Then SetCapture .hWnd
If ((x < 0 Or y < 0 Or x > .ScaleWidth Or y > .ScaleHeight) Or IIf(traTransparent = TransparentAutomatic Or traTransparent = TransparentManualy, GetPixel(UserControl.hDC, MousePos.x, MousePos.y) = UserControl.Backcolor, GetPixel(UserControl.hDC, MousePos.x, MousePos.y) = -1)) Then ' we're off the form
ReleaseCapture
blnEnter = False
MouseOverControl = 0
RaiseEvent MouseExit(mbMouseButton, skShift, CLng(MousePos.x), CLng(MousePos.y), mdMouseDirection)
mdMouseDirection = MouseDirectionNone
RestoreLastCursor
Else
If blnEnter = False Then
blnEnter = True
lngOldMouseX = MousePos.x
lngOldMouseY = MousePos.y
MouseOverControl = UserControl.hWnd
RaiseEvent MouseEnter(mbMouseButton, skShift, x, y, mdMouseDirection)
If UCase(strMouseIcon) Like "*.ANI" = True And UserControl.MousePointer = 99 Then
StartAnimatedCursor strMouseIcon
End If
End If
End If
End With
RaiseEvent MouseMove(mbMouseButton, skShift, x, y, mdMouseDirection)
End Sub
-
Jan 3rd, 2010, 12:53 PM
#10
Re: i'm tryng clean a string without sucess:(
Using Debug.Print, keep in mind that if you have multiple controls and the strMouseIcon value you are getting may not be for the control you think you are debugging? Just a thought. Maybe change your debug.print statement to:
Debug.Print strMouseIcon, Ambient.DisplayName
-
Jan 3rd, 2010, 01:00 PM
#11
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
 Originally Posted by LaVolpe
Using Debug.Print, keep in mind that if you have multiple controls and the strMouseIcon value you are getting may not be for the control you think you are debugging? Just a thought. Maybe change your debug.print statement to:
Debug.Print strMouseIcon, Ambient.DisplayName
but way i recibe the strvalue with debug, but not in property get part?
my objective is show the anime cursor, when the mouse is in UC, but in these case the porperty don't have any value. then why with Debug key word i can get the value(but not right value)?
-
Jan 3rd, 2010, 01:02 PM
#12
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
i try what you said, and yes it's the control name, that i know where is the error(where i change(before) the mouseicon value.
-
Jan 3rd, 2010, 01:22 PM
#13
Re: i'm tryng clean a string without sucess:(
When the mouse is in the UC when? At design time, at runtime? There are no mousemove events when form is in design time.
Again, search your project to see if you are resetting strMouseIcon elsewhere. Are you changing the property in your form? Maybe in the MouseEnter event or other events? Those are places to check too.
-
Jan 3rd, 2010, 01:25 PM
#14
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
"When the mouse is in the UC when? At design time, at runtime? There are no mousemove events when form is in design time."
in run-time. and after change the property, the icon is only showed in run-time.
-
Jan 3rd, 2010, 01:35 PM
#15
Re: i'm tryng clean a string without sucess:(
Ok, are you saying that when you pass vNewValue as "", strMouseIcon keeps its original value? That isn't possible, and this should prove it.
Change: Debug.Print strMouseIcon
To: Debug.Print ">"; strMouseIcon; "<", ">"; vNewValue; "< Equal? "; (strMouseIcon = vNewValue)
-
Jan 3rd, 2010, 01:40 PM
#16
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
 Originally Posted by LaVolpe
Ok, are you saying that when you pass vNewValue as "", strMouseIcon keeps its original value? That isn't possible, and this should prove it.
Change: Debug.Print strMouseIcon
To: Debug.Print ">"; strMouseIcon; "<", ">"; vNewValue; "< Equal? "; (strMouseIcon = vNewValue)
the result is true.. confuse i'm
-
Jan 3rd, 2010, 01:44 PM
#17
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
something isn't right
i delete the control and i build anotherone with same name. and when i move the mouse the animated cursor is showed
-
Jan 3rd, 2010, 01:50 PM
#18
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
i belive that i'm resolve the problem
-
Jan 3rd, 2010, 01:50 PM
#19
Re: i'm tryng clean a string without sucess:(
Logic errors are sometimes the hardest to find 
Syntax errors are the easiest.
-
Jan 3rd, 2010, 01:56 PM
#20
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
 Originally Posted by LaVolpe
Logic errors are sometimes the hardest to find 
Syntax errors are the easiest.
yes, that true. and sometimes can give n "headheck".
sorry, if i bored you with my code problems
and thank you for help me
-
Jan 3rd, 2010, 02:07 PM
#21
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
at leats i can delete the string value. now i must do the animater cursor be show, only when the mouse is in uc
-
Jan 3rd, 2010, 02:14 PM
#22
Thread Starter
PowerPoster
Re: i'm tryng clean a string without sucess:(
finally i resolve the problem
Code:
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If x > MousePos.x Then
mdMouseDirection = MouseDirectionRight
ElseIf x < MousePos.x Then
mdMouseDirection = MouseDirectionLeft
ElseIf y < MousePos.y Then
mdMouseDirection = MouseDirectionUp
ElseIf y > MousePos.y Then
mdMouseDirection = MouseDirectionDown
ElseIf x < MousePos.x And y < MousePos.y Then
mdMouseDirection = MouseDirectionLeftUp
ElseIf x < MousePos.x And y > MousePos.y Then
mdMouseDirection = MouseDirectionLeftDown
ElseIf x > MousePos.x And y < MousePos.y Then
mdMouseDirection = MouseDirectionRightDown
ElseIf x < MousePos.x And y > MousePos.y Then
mdMouseDirection = MouseDirectionRightUp
End If
MousePos.x = x
MousePos.y = y
mbMouseButton = Button
skShift = Shift
With UserControl
If GetCapture <> .hWnd Then SetCapture .hWnd
If ((x < 0 Or y < 0 Or x > .ScaleWidth Or y > .ScaleHeight) Or IIf(traTransparent = TransparentAutomatic Or traTransparent = TransparentManualy, GetPixel(UserControl.hDC, MousePos.x, MousePos.y) = UserControl.Backcolor, GetPixel(UserControl.hDC, MousePos.x, MousePos.y) = -1)) Then ' we're off the form
ReleaseCapture
blnEnter = False
MouseOverControl = 0
RaiseEvent MouseExit(mbMouseButton, skShift, CLng(MousePos.x), CLng(MousePos.y), mdMouseDirection)
mdMouseDirection = MouseDirectionNone
If UCase(strMouseIcon) Like "*.ANI" = True And UserControl.MousePointer = 99 Then
RestoreLastCursor
End If
Else
If blnEnter = False Then
blnEnter = True
lngOldMouseX = MousePos.x
lngOldMouseY = MousePos.y
MouseOverControl = UserControl.hWnd
RaiseEvent MouseEnter(mbMouseButton, skShift, x, y, mdMouseDirection)
If UCase(strMouseIcon) Like "*.ANI" = True Then
SaveLastCursor
StartAnimatedCursor strMouseIcon
End If
End If
End If
End With
RaiseEvent MouseMove(mbMouseButton, skShift, x, y, mdMouseDirection)
End Sub
Public Property Get MouseIcon() As String
MouseIcon = strMouseIcon
End Property
Public Property Let MouseIcon(ByVal vNewValue As String)
strMouseIcon = vNewValue
If ValidMouse(UCase(strMouseIcon)) = False Then
UserControl.MousePointer = 0
UserControl.MouseIcon = Nothing
Exit Property
End If
If UCase(strMouseIcon) Like "*.ANI" = True Then
UserControl.MousePointer = 99
Else
UserControl.MousePointer = 99
UserControl.MouseIcon = LoadPicture(strMouseIcon)
End If
PropertyChanged "MouseIcon"
End Property
nothing better that reduce some lines
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|