Results 1 to 18 of 18

Thread: [RESOLVED] Code works in VB, but not when compiled

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Resolved [RESOLVED] Code works in VB, but not when compiled

    I already posted this in API (sorry to double post).. I am not sure if its an API issue tho.. and I am in desperate need of answers

    http://vbforums.com/showthread.php?t=488348 is my thread, it has all the info in it...
    Last edited by penagate; Sep 24th, 2007 at 04:09 AM. Reason: removed offer of payment

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: [RESOLVED] Code works in VB, but not when compiled

    i downloaded your code and click test button. but the cursor does not move. you sad your code is working in the IDE ?

  3. #3
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: [RESOLVED] Code works in VB, but not when compiled

    OK bail. i got some more infor from http://vbforums.com/showpost.php?p=3003430&postcount=7

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Re: Code works in VB, but not when compiled

    Did you see my pcode / native code post? know anything about that ?

    After reading up on pcode and native code, i really want to continue to compile it in native code

  5. #5
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Code works in VB, but not when compiled

    You need to use the LVNI_SELECTED and Not LVIS_FOCUSED

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Re: Code works in VB, but not when compiled

    Hold up well I test this on my external application

  7. #7
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Code works in VB, but not when compiled

    SO change it like this
    Code:
    For i = 0 To numofItems - 1
        If SendMessage(listhwnd, LVM_GETITEMSTATE, i, LVNI_SELECTED) = 2 Then
            curPosition = i
            Exit For
        End If
    Next i
    Reply me with the results

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399
    LVNI_SELECTED doesnt even work for me in the example i made, if i just switch lvis_focused with it, and declare LVNI_SELECTED, it does the same thing.. works in VB, but not when compiled

    also i am not sure if selected will work the same as focus for what i am doing.. i am trying to test it on the external app i want to use it on, but their servers are down! lol

    It does work on 1 program , once this server comes up, I will test it on where i actually need it to work, and see if selected does the same job as focus.. do you knwo what the difference is?
    Last edited by penagate; Sep 24th, 2007 at 04:09 AM. Reason: merged

  9. #9
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Code works in VB, but not when compiled

    ok ok, i checked it with my own application and was working. i check it with your application in the IDE working. ok. i found it seems not woking out side. let me check the problem.

  10. #10
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Code works in VB, but not when compiled

    LVIS_SELECTED means that the item is selected. The appearance of a selected item depends on whether it has the focus and also on the system colors used for selection.

    LVIS_FOCUSED means that the item has the focus, so it is surrounded by a standard focus rectangle. Although more than one item may be selected, only one item can have the focus.

    LVIS_FOCUSED state is used for keyboard navigation in the list view control. In a single-selection control the selection follows the keyboard focus. In your situation the second item has the selection, but does not have the focus.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Re: Code works in VB, but not when compiled

    I think the problem is because when you click the button, the listview loses its selection, this is my concern, because it doesnt lose its focus, so the focus thing would work better then selected. However focus doesnt seem to work when compiled in native code haha

  12. #12
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Code works in VB, but not when compiled

    i manage to track the problem. it worked in your project in the IDE and in the OUt side of IDE. you need to put a ByVal key word infront of the lparam.
    Code:
    If SendMessage(listhwnd, LVM_GETITEMSTATE, i, ByVal LVIS_FOCUSED) > 0 Then

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Re: Code works in VB, but not when compiled

    dude if that works fazi, you are the man!!!!, i am half asleep right now, i will test int he morning
    Last edited by bail3yz; Sep 13th, 2007 at 04:03 AM.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Re: Code works in VB, but not when compiled

    Fazi, that worked great on ListView20WndClass but not SysListView32 , which one did you test yours on?

    Anyways, I am testing the selected option you suggested, so far it seems to work great, ive only seen one downside

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Re: Code works in VB, but not when compiled

    Also, i am a bit confused about the ByVal thing, any idea when for Focus it changes from returning 2 when it has focus to returning one when byval is used?
    Last edited by penagate; Sep 24th, 2007 at 04:10 AM. Reason: removed offer of payment

  16. #16
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Code works in VB, but not when compiled

    Hai bail3yz, focosing is not a matter here. ByVal / ByRef is the thing. There are tons of tutorials on ByVal & ByRef. It is a very important concept in API Programming. Please searh google for 'Passing ByVal and Passing ByRef'.

    actually i am working here as a volanteer. i never expect anything but Sharing knowledge. Thank you for the offer. but a rating to my post would be well enough

    Cheers !

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    399

    Re: Code works in VB, but not when compiled

    Alright cool, thanks for all the help!

    I tried to rate you, but i rated you recently so I have to go rate other people

    I will make sure to come back here and rate all your posts when I can

  18. #18
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: [RESOLVED] Code works in VB, but not when compiled

    Your Wellcome Bail3yz

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