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...
Printable View
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...
i downloaded your code and click test button. but the cursor does not move. you sad your code is working in the IDE ?
OK bail. i got some more infor from http://vbforums.com/showpost.php?p=3003430&postcount=7
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
You need to use the LVNI_SELECTED and Not LVIS_FOCUSED :D
Hold up well I test this on my external application
SO change it like this
Reply me with the results :)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
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?
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.
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.
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
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
dude if that works fazi, you are the man!!!!, i am half asleep right now, i will test int he morning
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
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?
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 :D
Cheers !
:) 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 :)
Your Wellcome Bail3yz :D