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
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
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
invoke SendMessage,hListviewHandle,LVM_INSERTITEM,0,addr lvi
Yes, I have handle, but I thought I could work directly - without the handle. So what am I supposed to do?
/siddhartha
/siddhartha
GetDlgItem or SendDlgItemMessage
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
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
GetDlgItem also needs the handle of the dialog box (or whatever parent window) of the ListView control.
Raymond
Raymond
Thanks everybody! You helped me a lot! And Raymond, now I'm sure that I need to read win32.hlp more carefully! :)
/siddhartha
/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
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
Sooo, any suggestions? Please!
/siddhartha
/siddhartha
I was wondering why you use the following
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
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
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 ;)
Thanks guys, I appreciate your help, but I think that both of you are wrong. So here I attach the source:
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
Clicking on Add user does a damn thing - brings up the second dialog!
/siddhartha
/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
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
/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.
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.
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
/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
Thanks for the invaluable help, donkey!
/siddhartha
/siddhartha