|
Did you see msdn its loop for finditem now what do you need?
|
|
|
|
|
Where in msdn i don t find the example ! ?
Bravoone
|
|
|
|
|
|
no,no,no the documentation msdn library doesn t help me so mutch because what is there i have just done , what i need is something else a more detailed structure for this : FindItem or CListCtrl ,examples included for me to see how its works ! and if i want this in my project ! you understand me now ? all i want is to search from a CEdit in CListCtrl (Report view) for items and subitems and the rezult must be fill in another CEdit !
WhiteSky ... maybe you don t understand me i don t know so mutch code and i need some help if is someone in this world who want to help me! ok i will be gone from this site if you tell me : nobody want to help you ! ok i will wait your answer !
Bravoone
|
|
|
|
|
//i write this example for you i hope its helpful for you
//in this example we have a CEdit and in this control we have a string(test) now we want to search this item in listctrl first we get this string from Editbox//and set it find1.psz = str22; in the loop we have a search and return value to index and convert(itoa) for show location these items in this list 0,3,6 and you get a -1 when it doesnt find any items//instead messagebox you can insert this value to another editbox
-----------------------------------------------
<br />
USES_CONVERSION;<br />
CEdit m_Edit;<br />
CString str22;<br />
TCHAR buffer[100];<br />
LVFINDINFO find1={0};<br />
<br />
m_Ctrl1.InsertItem(0,"test");<br />
m_Ctrl1.InsertItem(1,"test1");<br />
m_Ctrl1.InsertItem(0,"a"); <br />
m_Ctrl1.InsertItem(0,"b"); <br />
m_Ctrl1.InsertItem(0,"test"); <br />
m_Ctrl1.InsertItem(0,"a1"); <br />
m_Ctrl1.InsertItem(0,"b1"); <br />
m_Ctrl1.InsertItem(0,"test"); <br />
<br />
m_Edit.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,100,23),this,1);<br />
m_Edit.SetWindowText("test");<br />
m_Edit.GetWindowText(str22);<br />
int index=-1;<br />
<br />
<br />
find1.psz = str22;<br />
find1.flags = LVFI_STRING;<br />
do<br />
{<br />
index=m_Ctrl1.FindItem(&find1,index);<br />
MessageBox(itoa(index,buffer,10));<br />
<br />
}while(index!=-1);<br />
<br />
|
|
|
|
|
Thank you so mutch for your help , now i will try to see ...
Thanks !!!!!!!!!!!!!!!!!
Bravoone
|
|
|
|
|
ok i am very close - its working but i have one more problem to rezolv : with | LVFI_PARTIAL | works but i have subItems very close to the search for ex : i search "6021" my list include this : 6000,6001,6002,6003...6021 and the answer he given to me is :"6000"
i have tried with |LVFI_STRING| but is not find anyting because i have spaces in my database (visual fox 6.0.) and i don t now wath to do its someone how have an ideea ?!
Thank you WhiteSky for your help !!!! Thank you !!!!!!!!!!!!!!!!!!!!!!
Please help !
Bravoone
|
|
|
|
|
Flaviu_2006 wrote: ...because i have spaces in my database...
So why don't you remove the spaces prior to adding the items to the list control?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You can remove space from your string then insert to listctrl
|
|
|
|
|
How can I remove spaces from my string ? i don t now how ? how ?The spaces become from the database and when i loaded ... in list ctrl ....?
How can i : FindItem in the second column and the 3- column ...etc.?
Because my string searches only in the first column and GetItemText from second column , 3 column etc . this is my code the code from yesterday is not good for me :
void CMyList::OnOK()
{
UpdateData();
m_list2.RedrawItems(0,m_list2.GetItemCount());
CString sName = _T("Name");
m_name.GetWindowText(sName);
LVFINDINFO stInfo = {0};
stInfo.flags = LVFI_PARTIAL;
stInfo.psz = sName;
int nItem = m_list2.FindItem( &stInfo );
if( nItem != -1 )
{
// the item is in the list control
CString sSecondColumnText = m_list2.GetItemText( nItem, 1 );
// set the text to the second edit box
m_rezult.SetWindowText( sSecondColumnText );
}
}
Only this code works !
I remind you :
0 1 2
----------------------------------
| Name | City | Country |
-----------------------------------
-----------------------------------
| George | London | England |
-----------------------------------
|George | NewYork | USA |
-----------------------------------
|George | Madrid | Spain |
-----------------------------------
all i want is to find in my list the country from example from my both edit boxes : m_name (sName) , m_city (sCity) , m_rezult(sRezult)
Please help me with my code ....!!!!(The data are from a database fox pro and have spaces when i loaded )is works only with (LVFI_PARTIAL) and is not so good!
I promise you when i finish my program i will loaded on codeproject !
and will be very usefull for many things !
Thanks for your help ! And i will wait your answer because i dont now how to continue i will try something but ...
Bravoone
|
|
|
|
|
I see your reply now did you get your answer?
|
|
|
|
|
ok i remouve spaces !... works ! but my same problem remain how to find in the other columns FindItem column 1,2 how when i find this my problems , i thing ... will be solved !
My code find only in first column (0) and give me the text from others all i wanth is to search in others columns 1,2 ... and thank you so mutch for your help ,you have no ideea what is that for me !Thanks again !!!!
Bravoone
|
|
|
|
|
CListCtrl::GetItemText has two items or four items index of item(one parameter) and nSubItem(two parameter)
now if you used this function in the loop you can find your item in another colunms and need to check this string with your string
(like InsertColumn or InsertItem that you can see two parameter)
|
|
|
|
|
you can give an example ? please !!!!!!!
Bravoone
|
|
|
|
|
Did you see reply Viorel.
|
|
|
|
|
Hi all,
I need to disable an Item in a CListBox By Double clicking on it .
How can I achieve it .
Please Help me
Thanks in Advance
George K Jolly
|
|
|
|
|
georgekjolly wrote: I need to disable an Item
how do expect the disabled item in the list box to behave
nave
|
|
|
|
|
if you dont need to this item you can delete it from listbox
|
|
|
|
|
I Just Need to make it Disable and After that I will Enable it , This is my need
|
|
|
|
|
It seems the CListBox class does not support "enabled/disabled" state of items.
I think instead of CListBox you have to try another class -- CCheckListBox -- and deal with the state of checkboxes.
I hope it helps.
|
|
|
|
|
Hello friends,
I have insert a active-x control in my dialog based application.
Through which i got the class caapi aapi.cpp and aapi.h
And i am able to call all the function which are in aapi.cpp thruogh wDlg.cpp by declare a object of aapi.
When i right click in active-x button it display all the events of function which are present in aapi.h/.cpp.
I dont know how to make use of that events or how to make connection between these events and my application.
Can u help me or any link .Thanks
|
|
|
|
|
Hi!!
I have a doubt regarding SendMessage() function. According to MSDN SendMessage syntax is as follow;
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
But I am not getting what wparam and lparam are erally used for. Its given in MSDN that they are jst for additional information about the msg.
Thx,
|
|
|
|
|
SendMessage(..) is mainly for user messages.
Say in one class you have two numbers and you have addition method in another class, now you can use the SendMessage as
SendMessage(AddtionMethodHWND, User_Msg, 5, 10)
you can send a structure or class as the Param values, but those have to be as pointers and the destination methos have to take care of deleting the allocated memory
PostMessage(..) also act as SendMessage(..),
PostMessage just send the message and continue executing the next line but SendMessage will wait untill the methos returns
Do your Duty and Don't expect the Result
|
|
|
|
|
Hi!
Thx for the reply.
Actually I am facing a problem where I am trying to port a VC6 code to VC8. In My VC6 code I was passing an iterator to the SendMessage just by typecasting it to WPARAM. But VC8 compiler is allowing to do this and giving me error saying..
error C2440: 'type cast' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'WPARAM'<br />
with<br />
[<br />
_Ty=KPUnprotectedFileCmd_s,<br />
_Alloc=std::allocator<KPUnprotectedFileCmd_s><br />
]<br />
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
can u suggest me solution tio this peoblem.
Thx again!
|
|
|
|
|
Hi...
Windows have message driven architecture basically. Messages are nothing but events (in VB). For every action a window will get a message like, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL etc., The above said messages are mouse click events that will be sent to a window if user clicks on it. Say, if a user clicks on a window... that window will get WM_LBUTTONDOWN message first and WM_LBUTTONUP when he release it. With this message additional information like X,Y positions where the user clicked also will be sent to that window.
Ok... now come to SendMessage() function. SendMessage function is having as u said four parameters,
LRESULT SendMessage(HWND hWnd,UINT Msg,WPARAM wParam, LPARAM lParam);
here hWnd is the handle to the window where you want to send the message
Msg is the Message as above said WM_LBUTTONDOWN or WM_LBUTTONUP (see msdn for all messages starting with WM_XXXXXXX)
wParam additional information
lParam additional information
for example, let us send a message to a window like user ctrl+clicks on it...
::SendMessage(hWnd,WM_LBUTTONDOWN,MK_CONTROL,MAKELPARAM(x,y));
::SendMessage(hWnd,WM_LBUTTONUP,MK_CONTROL,MAKELPARAM(x,y));
wParam and lParam will vary depends on the message you send. For WM_CLOSE, no need for wParam and lParam, so ::SendMessage(hWnd,WM_CLOSE,0,0); will close the window.
As our Friend Parthi said, difference between SendMessage and PostMessage is, SendMessage will send message and wait till the window process the message. PostMessage will post the message in the message queue and wont wait anymore.
I think the reply is pretty long, but clear enough.
with regards,
Naren Neelamegam
|
|
|
|