Results 1 to 22 of 22

Thread: [RESOLVED] i'm tryng clean a string without sucess:(

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Resolved [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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    i don't understand
    VB6 2D Sprite control

    To live is difficult, but we do it.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    Quote Originally Posted by LaVolpe View Post
    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    Quote Originally Posted by LaVolpe View Post
    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: i'm tryng clean a string without sucess:(

    Maybe you should show us your Property Get MouseIcon routine?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    Quote Originally Posted by LaVolpe View Post
    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  9. #9

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #11

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    Quote Originally Posted by LaVolpe View Post
    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)?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  12. #12

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    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.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  13. #13
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #14

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    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.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  15. #15
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  16. #16

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    Quote Originally Posted by LaVolpe View Post
    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  17. #17

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  18. #18

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    i belive that i'm resolve the problem
    VB6 2D Sprite control

    To live is difficult, but we do it.

  19. #19
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: i'm tryng clean a string without sucess:(

    Logic errors are sometimes the hardest to find
    Syntax errors are the easiest.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  20. #20

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    Re: i'm tryng clean a string without sucess:(

    Quote Originally Posted by LaVolpe View Post
    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  21. #21

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  22. #22

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,962

    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width