I am irked over the items in my listview is never selected when i click on them. And also In the following code:


mov eax, [lparam]
virtual at eax
end virtual
cmp [.NMHDR.code], NM_DBLCLK
jz nmdblclk
jmp processed
;Open chat window
invoke SendMessage,[hList],LVM_GETNEXTITEM,-1, LVNI_FOCUSED

The SendMessage will also return -1.

The listview is created with

xor ebx, ebx
invoke CreateWindowEx,0,listview,ebx,WS_CHILD or WS_VISIBLE or LVS_LIST or LVS_SINGLESEL or LVS_SORTASCENDING,\
mov [hList], eax

I have attached my source code for those that want further examination. To add item to the list you would need to login with your icq uin and password.
Posted on 2004-04-11 08:17:20 by roticv
i'm probably wrong, but is it that you are refering the handle as a pointer or sumthin ( with the [] around it)

like rather than "mov , eax" shouldnt it be "mov hList, eax"
invoke SendMessage,hList,LVM_GETNEXTITEM,-1, LVNI_FOCUSED

i use masm, so it's probably different to yours

if your searching for the selected item, shouldn't you be searching for LVNI_SELECTED instead of LVNI_FOCUSED
anyway, hope this helps
Posted on 2004-04-11 09:37:45 by someone
Hi roticv,

It is difficult to tell where the problem is, I could not add an item to the listview to look at it so... But I could not see anything obviously wrong with the code. Have you tried setting the LVS_EX_SHOWSELALWAYS extended flag ?


MASM hides alot of things from the programmer, one of them is the exact nature of what a label is. In reality it must always be enclosed in [], even in MASM, but MASM will just do it for you. and hlist are the same thing in MASM, however most other assemblers require that you are more explicit when dealing with memory operands.
Posted on 2004-04-11 10:03:42 by donkey
Hi donkey,

I have added 2 items to show you what I mean. I did not include the source code because it is almost the same as before. Also what is the values of LVS_EX_SHOWSELALWAYS ? I could not find in windows.inc of masm32.

Posted on 2004-04-11 10:36:57 by roticv
To add, it works fine when the listview is part of a dialogbox. However when the listview is created using CreateWindowEx, the problem arises. I cannot select any of the items. Do tell me where I am wronged.

To add, do you guys have any idea why my application cannot be resized? I tried adding WS_POPUP when creating the window, but i still cannot resize it. However if I force my application to have WS_POPUP set by using Winspy, my window can resize.
Posted on 2004-04-12 09:50:36 by roticv
Hi Roticv,

I'm stumped. I created the listview myself with the same style as you used and it resizes and works fine. I don't see and apparent reason it doesn't work in your application. I am still going through the code, it is not really vertically and horizontally tabbed so it's a bit hard to read but I still hope to find the problem.
Posted on 2004-04-12 14:28:06 by donkey
Thanks for your help donkey. Actually I have coded and tested out the CreateWindowEx for the listview and it works perfectly in my codes. At least I fixed the resize issue and is now working on finding out why I cannot select any of the items in the listview.

Seems like I have a tendenercy to create hard to find and rare bugs in my codes. oh well.. *sigh*
Posted on 2004-04-13 07:39:28 by roticv
I tried to create the same dialog box with the same list view control and it worked fine. There's obviously something wrong with the code. Try ripping off all the cool stuff, just leave the dialog box creation. If it doen't work, then it's kinda....bad. The list view might not get the input focus for some reason. Check the WM_INITDIALOG message processing. You should return TRUE to let windows set the input focus for you.
Don't sigh. :grin: Coding is a WAR. Don't let the bugs win ;)
Good luck.
Posted on 2004-04-14 02:41:08 by Vaxon
Hi Vaxon,

Huh? I am not using a dialogbox in my codes.
Posted on 2004-04-15 04:07:08 by roticv
Nevermind. I think I finally found the problem. Thanks to those that have helped me.
Posted on 2004-04-15 04:23:49 by roticv
I had only a quick look at your code and didn't notice that, sorry.
Why do you hold the dialog box in your resource file then? Did you try to use it? Try to create your main window with DialogBox.
Posted on 2004-04-15 04:24:52 by Vaxon
I switched to window from dialogbox, because I could not get modeless dialogbox to work in modal dialogbox and since no one replied to my previous thread on that question, I had no choice. I just did not change/edit the resouce file.
Posted on 2004-04-15 04:26:35 by roticv
What was it? Just curious...
Posted on 2004-04-15 04:41:46 by Vaxon
It had something to do with my handling with WM_NOTIFY, though I do not know what is exactly the problem. Any explanation would be greatly welcomed.
Posted on 2004-04-15 04:44:46 by roticv
well i see why you cant resize the window. you need to change your lines of code to this:

invoke RegisterClass,wc
invoke CreateWindowEx, WS_EX_TOPMOST or WS_EX_TOOLWINDOW, ClassName, AppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 125, 300, ebx, ebx, hInstance, NULL

also there isnt a extended listview style named LVS_EX_SHOWSELALWAYS. only a normal listview style named:

Posted on 2004-04-15 06:44:28 by smurf