|
SyamlalS wrote: ,,,But can U explain the 4th parameter in particular..
Its handle to tree item.
Its can be obtained using any of CTreeCtrl functions(GetNextItem,GetChildItem etc,).
|
|
|
|
|
Even GETITEM,GETNEXTITEM etc requires a TVITEM parameter, which again contains a handle to tree item(hItem field),So how can I get the first item???
If I get handle to the first item I can apply GETNEXTITEM and reach at the particular(C item...
Pls do reply
Thanx to Prasad_som and Frank K and all others who are willing to reply for showing interest in my request,,,,
SYAMLAL
|
|
|
|
|
You already told in original post, that you have window handle,
This snippet may help you to understand traversing tree control. It gets first child of root item and traverse its children.
HTREEITEM hRoot = pCtrl->GetRootItem();
if (hRoot == NULL)
MessageBox(_T("some problem"));
else
{
}
HTREEITEM hChild = pCtrl->GetNextItem(hRoot,TVGN_CHILD)
if (pmyTreeCtrl->ItemHasChildren(hChild))
{
HTREEITEM hNextItem;
HTREEITEM hChildItem = pmyTreeCtrl->GetChildItem(hmyItem);
while (hChildItem != NULL)
{
hNextItem = pmyTreeCtrl->GetNextItem(hChildItem, TVGN_NEXT);
hChildItem = hNextItem;
}
}
|
|
|
|
|
Dear Prasad,,
I have the handle to the tree view and not a pointer
So I can't invoke the GetRootItem function
Expect ur reply..
SYAMLAL
|
|
|
|
|
SyamlalS wrote: I have the handle to the tree view and not a pointer
CTreeCtrl *pTreeCtrl = dynamic_cast<CTreeCtrl*> (CWnd::FromHandle(hWndYouHave));
|
|
|
|
|
Thanx a lot ,,Prasad...
dynamic cast was not required
This is enough:
CTreeCtrl* pCtrl = (CTreeCtrl*)(CWnd::FromHandle(HandleToTreeView));
NeWay thaks a lot again.....
SYAMLAL
|
|
|
|
|
SyamlalS wrote: dynamic cast was not required
This is enough:
CTreeCtrl* pCtrl = (CTreeCtrl*)(CWnd::FromHandle(HandleToTreeView));
This works, but C++ standard encourages using dynamic_cast or other operators(reinterpre_cast,static_cast ) . And old function style casts should be avoided wherever possible.
|
|
|
|
|
Hi!!!
I have one simple question..
How i can compare strin..
code is
if(x1.compareNocase(s1 || s2)
{
do something
}
Here if x1 is equal to s1 or s2 then do something in my code..
How i can compare..??
as in || is right or wrong??
Shah Satish
|
|
|
|
|
Hi,
You trying to be too fast
if ( x1.CompareNoCase( s1 ) || x1.CompareNoCase( s2 ) )
{
...
}
-----------
Mila
|
|
|
|
|
I have code..
If(Loopname.CompareNocase(x1)==0 || Loopname.CompareNocase(mytext->contents)==0).
but its not working
|
|
|
|
|
Hi,
hm... interesting - and what type are x1 and mytext->contents -> is it CString too ? (I'm thinking about e.g. you use VS2005 where default is UNICODE defined and you try to compare default CString with char *)
Besides you can check what exactly return particular comparing functions (if equal should returns NULL)
-----------
Mila
|
|
|
|
|
Shah Satish wrote: but its not working
What is this supposed to mean? If one of the calls to CompareNocase() is returning a non-zero value, which you have yet to verify, that indicates the strings do not match. Whether the strings match or not, your code is syntactically correct.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Shah Satish wrote: if(x1.compareNocase(s1 || s2)
{
do something
}
if ((x1.CompareNoCase(s1)== 0) || (x1.CompareNoCase(s2)== 0))
{
}
Shah Satish wrote: as in || is right or wrong??
Here it is wrong, using your way.
|
|
|
|
|
I have code..
If(Loopname.CompareNocase(x1)==0 || Loopname.CompareNocase(mytext->contents)==0).
but its not working..
|
|
|
|
|
Shah Satish wrote: but its not working..
Means what ?
Can you try modifying it to,
If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))
{
}
|
|
|
|
|
No..Not modified..This is my actual code..But i dont know its not working.
|
|
|
|
|
ie only one case is wroking properly..Both together is not working..
If( (Loopname.CompareNocase(x1)==0)---This is working
(Loopname.CompareNocase(mytext->contents)==0))--This is working
If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))--But together is not working..
|
|
|
|
|
you are using a logical OR operator, which returns TRUE if one of the 2 operands is TRUE. so if its 1st part (1st comparison) is TRUE, then the 2nd one is not executed...
are you sure you want to use a OR ? don't you need a AND ( && ) instead ?
|
|
|
|
|
Ya..I have to use only "or" function..
but among them one is pointer and one is string..
mytext->contents is a pointer..
as in
AcDbMtext *mytext ;
mytext->Contents;
If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))
x1 is cstring and (mytext->contents)is a pointer..
what to do?? How t compare it?
|
|
|
|
|
Loopname is a CString, right ?
then look at the signature of CString::CompareNoCase(). it gets a PCXSTR parameter (so, pointer to char).
so ther's no problem in doing so.
if your code doesn't work, it is because of what i notified you previously. have you tried inverting the two statements in the OR operation (C-style string compared first) ?
|
|
|
|
|
Shah Satish wrote: But together is not working..
What does this mean ?
Remember, Loopname.CompareNocase(mytext->contents) will not be called if Loopname.CompareNocase(x1) returns 0. (or rule)
|
|
|
|
|
mytext->contents is a pointer..
as in
AcDbMtext *mytext ;
mytext->Contents;
what to do?? How t compare it?
|
|
|
|
|
you didn't read the answers
|
|
|
|
|
What you've shown in now way indicates that contents is a pointer. While mytext is indeed a pointer, you've shown nothing of its contents member. If contents is indeed a pointer, what's it a pointer to?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Ya..I have to use only "or" function..
but among them one is pointer and one is string..
mytext->contents is a pointer..
as in
AcDbMtext *mytext ;
mytext->Contents;
If( (Loopname.CompareNocase(x1)==0) || (Loopname.CompareNocase(mytext->contents)==0))
x1 is cstring and (mytext->contents)is a pointer..
what to do?? How t compare it?
|
|
|
|