|
YaronNir wrote:
any1 knows a style of list to fix my problem?
There isn't one. You will have to do this yourself whenever the user clicks on an item. Use GetSelectedCount() and GetNextItem() to loop through the selected items and set them all to the state you want.
If you're not using MFC, use the LVM_GETSELECTEDCOUNT and LVM_GETNEXTITEM mesages.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
thanks for the reply!
i am not using MFC, so i will use the LVM_ messages you've mentioned.
you said to catch the user clicks on the item. but what if the user select the item via the keyboard???
is there a certain message that item was selected? no matter how (keyboard or mouse?)
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
YaronNir wrote:
is there a certain message that item was selected?
LVN_ITEMCHANGED , which will detect if an item has been selected/unselected by either mouse or keyboard, but I'm not sure if it works when an item is checked or unchecked. Perhaps you could test it
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi, thanks again for the reply.
i am using ATL/WTL, i have a dialog that correspond to the:
NOTIFY_HANDLER(IDC_MY_LIST_CTRL, LVN_ITEMCHANGED, OnListItemChanged)
and in the implementation:
LRESULT CAddContentDlg::OnListItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pnmh;
return 0;
}
can u show me some code to handle the multiple selection and checking cause i'm kinda having trouble of writing it correctly.......
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi, thanks again for the reply.
i am using ATL/WTL, i have a dialog that correspond to the:
NOTIFY_HANDLER(IDC_MY_LIST_CTRL, LVN_ITEMCHANGED, OnListItemChanged)
and in the implementation:
LRESULT CMyDlg::OnListItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pnmh;
return 0;
}
can u show me some code to handle the multiple selection and checking cause i'm kinda having trouble of writing it correctly.......
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I'll have a go
LRESULT CMyDlg::OnListItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pnmh;
HWND hwndLV = pnmh->hwndFrom;
int iState = ListView_GetCheckState(hwndLV, pNMListView->iItem);
int iItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
while(iItem >= 0)
{
ListView_SetItemState(hwndLV, iItem, INDEXTOSTATEIMAGEMASK(iState+1), LVIS_STATEIMAGEMASK);
iItem = ListView_GetNextItem(hwndLV, iItem, LVNI_SELECTED);
}
return 0;
} Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Excellent man! works perfectly! many thanks!
keep up the good help work....
cheers
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
You're welcome
YaronNir wrote:
Excellent man! works perfectly!
Cool! I didn't actually test that - just wrote it straight from the docs, so I'm happy that it works that well
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I'm trying to learn the alternative way of writing an IF statement. The code below returns a 0, it should be an 8 since 3<5, what am I doing wrong?
Thanks
<br />
<br />
#include <iostream><br />
<br />
using namespace std;<br />
<br />
int main()<br />
<br />
{<br />
int a = 3;<br />
int b (5);<br />
int x(0);<br />
<br />
a < b ? x == a + b : x == 9;<br />
<br />
cout<<x<<"\n\n";<br />
<br />
return 0;<br />
}<br />
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
You use the comparison operator (==) insted of the assignement operator.
Replace
a < b ? x == a + b : x == 9;<br />
<br /> by
a < b ? x = a + b : x = 9;<br />
<br />
|
|
|
|
|
DaveE9th wrote:
a < b ? x == a + b : x == 9;
[...] what am I doing wrong?
The result is false , whichever clause is executed:
x is neither equal to a+b (that is 8) nor is x equal to 9.
If you want to assign x a value, you need to write
a < b ? x = a + b : x = 9;
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, your both right. I'm glad it's working now.
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
DaveE9th wrote:
a < b ? x == a + b : x == 9;
You could also do this:
x = ( a < b ? a + b : 9 );
There are 10 kinds of people - those that get binary and those that don't.
|
|
|
|
|
x = ( a < b ? a + b : 9 );
This is the right way.
|
|
|
|
|
hi
Is possible to use C++ to wirte a promgram to transfer the data from Pc to the ir then tramit to the reciever the RS232
|
|
|
|
|
Que?...
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi,
I have often seen concept of callback funtion used in MFC.Can any body please explain What is a callback function and what is its use ?
Thanks
Rohit
|
|
|
|
|
it is your function pointer to what you enter f.e. like argument to other function
that (other) function will call yours (call-back) if necessary
classic example is qsort - sorts array by by you defined criteria
you just need to enter data to sort and your callback function what will compare two items
the rest makes qsort not knowing about any data details
see qsort msdn example
t!
(http://www.codeproject.com/info/search.asp?target=callback&Submit1=+Search+&st=tt&qm=all[^])
|
|
|
|
|
I explained this a day or two ago. Search back a bit and you should find the information.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
In the code below, I'm curious about the "!" in front of the strcmp function. I'm confused on this. In my understanding, the !strcmp is saying that IF str and Info do NOT compare, then cout the number. What am I missing hear? Thanks
#include "iostream.h"<br />
#include "string.h"<br />
<br />
int main()<br />
{<br />
int x;<br />
int i;<br />
char str[80];<br />
bool isfinished=false;<br />
char Info [] [300] = <br />
{<br />
"3030-02-000-5287" , "Here is the information for this number." ,<br />
"3030-03-000-0029" , "Here is the information for this number." ,<br />
};<br />
while(isfinished==false)<br />
{<br />
cout<<"\nPlease enter a number:\n";<br />
cin>>str;<br />
for(i=0; i < 4; i += 2)<br />
if(!strcmp(str, Info[i]))<br />
{<br />
cout<<"\nInformation:"<<Info[i+1]<<"\n";<br />
break;<br />
}<br />
if(i == 4)<br />
{<br />
cout<<"Number not found.\n";<br />
}<br />
<br />
cout<<"\nWould you like to check another?\n";<br />
<br />
{<br />
cout<<"Enter 1 for yes, 0 for no.\n";<br />
(cin>>x).get(); <br />
<br />
}<br />
if (x==0) isfinished=true;<br />
}<br />
<br />
return 0;<br />
}<br />
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
if(!something)
is equal to
if(something == 0)
our strcmp is executed, its return value is negated and if solution is not zero (false) than gets into if())
t!
|
|
|
|
|
The strcmp function returns 0 when string1 is identical to string2. The application writes the info to screen when string1 is identical to string2.
|
|
|
|
|
So would strcmp (without the "!") return a 1(TRUE) if the two variables are equal?
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
Oh no, sorry. The function returns 0 when the strings are equal. That would make:
if (!0)
So only when the strings are not equal, the code in the if statement gets executed, and the next in the info array is printed to screen (Info[i+1]).
I'm sorry, it's very early in the morning (in Holland) , and I hadn’t finished my coffee.
|
|
|
|
|