Hello! I have problem with the ListView control:


LOCAL lvi: LV_ITEM
mov lvi.imask,LVIF_TEXT+LVIF_PARAM
and lvi.iSubItem,0
mov lvi.pszText,offset Heading1
invoke SendMessage,IDC_LSV1,LVM_INSERTITEM,0,addr lvi


This won't insert item in my listview. I've created it the easier way - with the resource editor, but I doubt this is the problem. I haven't tried by the CreateWindowEx way, but anyway I don't know how to do it. Any suggestions?


/siddhartha
Posted on 2004-06-29 18:31:35 by siddhartha
do you have a handle to your listview? it looks like your using the ID "IDC_LSV1" instead of the handle.

invoke SendMessage,hListviewHandle,LVM_INSERTITEM,0,addr lvi
Posted on 2004-06-29 18:54:06 by smurf
Yes, I have handle, but I thought I could work directly - without the handle. So what am I supposed to do?



/siddhartha
Posted on 2004-06-29 19:01:49 by siddhartha
GetDlgItem or SendDlgItemMessage
Posted on 2004-06-29 19:16:38 by roticv
So, I tried GetDlgItem. I'm supposed to do mov hList, eax after it but it doesn't work! Tried SendDlgItemMessage too but it doesn't seem to work too... The code now looks like this:

LOCAL lvi: LV_ITEM
mov lvi.imask,LVIF_TEXT+LVIF_PARAM
and lvi.iSubItem,0
mov lvi.pszText,offset Heading1
invoke GetDlgItem,IDD_DIALOG1,IDC_LSV1
mov hList,eax
invoke SendMessage,hList,LVM_INSERTITEM,0,addr lvi


/siddhartha
Posted on 2004-06-29 19:36:06 by siddhartha
GetDlgItem also needs the handle of the dialog box (or whatever parent window) of the ListView control.

Raymond
Posted on 2004-06-29 21:15:09 by Raymond
Thanks everybody! You helped me a lot! And Raymond, now I'm sure that I need to read win32.hlp more carefully! :)



/siddhartha
Posted on 2004-06-29 22:15:10 by siddhartha
Now I've got the following situation: two dialogs - there's a listview in the first. In the second - a textbox and a button. When clicking on the button the following code is executed:

invoke GetDlgItemText,hWnd,IDC_EDT1,addr username,32
mov lvi.pszText,offset username
mov lvi.imask,LVIF_TEXT
and lvi.iSubItem,0
and lvi.cchTextMax,10
invoke GetParent,hWnd
mov hWin,eax
invoke GetDlgItem,hWin,IDC_LSV1
mov hList,eax
invoke SendMessage,hList,LVM_INSERTITEM,0,addr lvi


The problem is that sometimes clicking the button does nothing without an evident reason. And it should add an item to the listview... Where do you think the problem is?



/siddhartha
Posted on 2004-07-01 20:51:48 by siddhartha
Sooo, any suggestions? Please!



/siddhartha
Posted on 2004-07-02 18:05:31 by siddhartha
I was wondering why you use the following
and lvi.iSubItem,0

and lvi.cchTextMax,10
instead of
[b]mov[/b] lvi.iSubItem,0

[b]mov[/b] lvi.cchTextMax,10

If the current value of lvi.cchTextMax happens to be different from 10, ANDing it with 10 could result in just about anything, including 0.

Raymond
Posted on 2004-07-02 19:25:24 by Raymond
something about that getparent call doesnt seem right, assuming you're taking the hwnd within the msg loop hwnd = the handle of the dialog, so calling getparent gets the parent window of the dialog and not the window handle containing the listview, you'd probably be better off getting the handle of the listview in the first dialog by calling a getdlgitem in the wm_initdialog phase and storing it in the data section and using that instead of getparent etc.. course i may be totally wrong.. wouldnt be the 1st time ;)
Posted on 2004-07-02 19:26:16 by evlncrn8
Thanks guys, I appreciate your help, but I think that both of you are wrong. So here I attach the source:
Posted on 2004-07-02 21:14:55 by siddhartha

Thanks guys, I appreciate your help, but I think that both of you are wrong. So here I attach the source:


hmm exe runs, thought u said there were 2 dialogs, i see one, right click brings up a menu 'add user', 'voice call'.. doesnt do a damn thing
Posted on 2004-07-03 01:10:04 by evlncrn8
Clicking on Add user does a damn thing - brings up the second dialog!



/siddhartha
Posted on 2004-07-03 01:13:22 by siddhartha
No, it doesn't, not if you do not *properly* initialize the common controls, InitCommonControls has been superceded and does not initialize the SysIPAddress32 control as it is not part of the pre-4.71 set of CC's...

.data

icc DQ 3FFF00000008h
.code
invoke InitCommonControlsEx,offset icc
Posted on 2004-07-03 01:34:13 by donkey
So, donkey, you are saying that it doesn't bring up the second dialog on your computer? Strange, maybe it has something to do with the fact I'm using Windows 2003 Datacenter Edition? The Add user menu works fine for me and brings up the second dialog... I just can't imagine what's happening...



/siddhartha
Posted on 2004-07-03 01:45:51 by siddhartha
Hi,

XP and higher have them initialized all the time, or at least it seems so, on 95, 98, 98SE, ME, NT4 and 2K your second dialog will always generate the error "Cannot find window class" and the dialog will fail. You must read the docs and find out which version of CC is necessary for a particular control, classes that are only available as of 4.70 *must* be initialized with InitCommonControlsEx.
Posted on 2004-07-03 01:51:20 by donkey
OK, I'll read the documentation, but is it possible to make it compatible with 98, 2k, XP and 2003? Or I should compile different versions for different OS? Thanks for the fast answers, donkey!



/siddhartha
Posted on 2004-07-03 01:58:12 by siddhartha
Just replace InitCommonControls with InitCommonControlsEx as I posted, it will be compatible across the full range of Windows as long as they have common controls v4.71 or greater. Since I think that comes with IE3.0 it is pretty much for sure. Anyway there is no IP address control in earlier versions so it's nothing to worry about.

.data

icc DQ 3FFF00000008h ; All classes
.code
invoke InitCommonControlsEx,offset icc
Posted on 2004-07-03 02:02:06 by donkey
Thanks for the invaluable help, donkey!



/siddhartha
Posted on 2004-07-03 02:28:30 by siddhartha