|
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
|
|
|
|
|
hi Naren!!
Thx a lot. That was really very helpful.
I am newbie in VC++. Ur reply erally helped me clear some basic things.
Thx again!!
|
|
|
|
|
hi!!
Iterator has a member called _MyPtr. Can I use that to get a pointer and then convert it to wparam??
thx
|
|
|
|
|
What iterator that was.. I mean map, list, vector..
anyway i hope the below approach will help you and i sorry 4 the delay..
Allocate memory of your type using new and copy the content from the iterator to the allocated memory and typecaste it...
say, the iterator has string valur then..
char *pStr = new char[..];
strcpy(pStr, (*it).c_str());
SendMessage(hWnd, USER_MSG, NULL, (LPARAM)(LPVOID)pStr);
the pStr memory should be freed in the handler of the message
Do your Duty and Don't expect the Result
|
|
|
|
|
|
Thx Whitesky!!
I already gone throught this article. I am clear now with the usage of SendMessage. My actual problem is how to convert an Iterator to WPARAM.
Typecasting was working in VC6. But it is not supported in VC8. can u suggest something. Also can i use _MyPtr member of iterator to get the pointer??
Thx again!
|
|
|
|
|
hi all,
I have Created a an Ellipse/Circle in mouse move, But after creating the Circle/Ellipse in the View i am trying to Drag the Circle what i have created.
But before Dragging the Circle what i have created. I am not able to see the dragged circle from the point what i am dragging. the Dragging is starting from the slight different position.
here is the Code.
void CPaintingView::OnLButtonDown(UINT nFlags, CPoint point)
{
Anchor = point;
OldPoint = Anchor;
int nTime = GetDoubleClickTime();
SetTimer(1,nTime,0);
if((nFlags && MK_LBUTTON) && circleDrawn == false) // For First Time
{
CString strReadBuffer,strTokenizer;
int index = -1,ind=0;
for(int i =0; i < strCollect.GetSize(); i++)
{
strReadBuffer = strCollect.GetAt(i);
index = strReadBuffer.Find(",");
do
{
strTokenizer = strReadBuffer.Left(index);
strReadBuffer = strReadBuffer.Mid(index+1);
index = strReadBuffer.Find(",");
array[ind++]= atoi(strTokenizer.GetBuffer(0));
}while(index != -1);
if(index == -1) array[ind++] = atoi(strReadBuffer.GetBuffer(0));
array[ind++] = '\0';
ind =0;
CRgn rgn;
rgn.CreateEllipticRgn(array[0],array[1],array[2],array[3]);
if(rgn.PtInRegion(point)== TRUE) insidepoint = true;
}
}
CScrollView::OnLButtonDown(nFlags, point);
}
void CPaintingView::OnLButtonUp(UINT nFlags, CPoint point)
{
CClientDC dc(this);
DrawTo = point;
CPen one,*old;
if(bEllipseFlag && insidepoint == true)
{
dc.SetROP2(R2_NOT);
dc.SelectStockObject(NULL_BRUSH);
dc.SetBkMode(TRANSPARENT);
dc.Ellipse(array[0],array[1],array[2],array[3]);
}
else if(bEllipseFlag && insidepoint == false)
{
CRect rect;
GetClientRect(&rect);
ScreenToClient(&rect);
one.CreatePen(PS_DASH,1,RGB(200,100,50));
old = dc.SelectObject(&one);
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
dc.SelectStockObject(NULL_BRUSH);
dc.Ellipse(Anchor.x, Anchor.y, point.x, point.y);
dc.SelectObject(old);
CString strCordinates;
strCordinates.Format("%d,%d,%d,%d",Anchor.x,Anchor.y,point.x,point.y);
strCollect.Add(strCordinates);
}
CScrollView::OnLButtonUp(nFlags, point);
}
void CPaintingView::OnMouseMove(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CPen one,*old;
if((insidepoint == true ) && (nFlags & MK_LBUTTON))
{
CRect rect;
GetClientRect(&rect);
ScreenToClient(&rect);
dc.SetROP2(R2_NOT);
one.CreatePen(PS_DASH,1,RGB(200,100,50));
old = dc.SelectObject(&one);
dc.SelectStockObject(NULL_BRUSH);
dc.Ellipse(OldPoint.x+ array[0],OldPoint.y+array[1],(point.x + array[2]),(point.y + array[3])); // Here the Position is not getting Correctly
dc.Ellipse(OldPoint.x+ array[0],OldPoint.y+array[1],(point.x + array[2]),(point.y + array[3])); //A slight Difference in Position I cant Understand why this happens. please help me out.
OldPoint = point;
dc.SelectObject(old);
showCordinates(point);
}
if((nFlags && MK_LBUTTON) && bEllipseFlag && circleDrawn == true)
{
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
dc.SetROP2(R2_NOT);
dc.SelectStockObject(NULL_BRUSH);
one.CreatePen(PS_DASH,1,RGB(200,100,50));
old = dc.SelectObject(&one);
dc.Ellipse(OldPoint.x, OldPoint.y, Anchor.x, Anchor.y);
dc.Ellipse(Anchor.x, Anchor.y, point.x, point.y);
OldPoint= point;
dc.SelectObject(old);
showCordinates(point);
}
CScrollView::OnMouseMove(nFlags, point);
}
// what shall i do for getting the Circle Dragged exacltly and at the Point where i have dragged.
please help me out.
Uday kiran
-- modified at 2:09 Tuesday 8th August, 2006
|
|
|
|
|
whats problem in this code?you show your code but can you show declare variables (array,...)
|
|
|
|
|