|
Bingo!
Thanks i'll try it.
|
|
|
|
|
your data are like this...?
key text
--- ----
1 item1
2 item2
if i might probably just insert in this way like, item1 as a label of ctreectrl item and 1 (key) as item data.
the function might look like
<br />
TV_INSERTSTRUCT treeStruct<br />
memset (&treeStruct,0,sizeof(treeStruct));<br />
<br />
HTREEITEM parent = NULL;<br />
parent = AddToTree(key,text,treeStruct,parent);<br />
<br />
AddToTree(key,text,treeStruct,parent);<br />
<br />
HTREEITEM AddToTree(int key,char text[_MAX_FNAME], TV_INSERTSTRUCT treeStruct, HTREEITEM Parent)<br />
{<br />
<br />
treeStruct.hParent = Parent;<br />
treeStruct.hInsertAfter = TVI_SORT;<br />
treeStruct.item.mask = TVIF_TEXT | TVIF_PARAM;<br />
treeStruct.item.cchTextMax = 500;<br />
treeStruct.item.pszText = text;
treeStruct.item.lParam = (DWORD)key;<br />
Parent= m_TreeCtrl.InsertItem(&treeStruct);
return Parent;<br />
}<br />
<br />
hope it will help
|
|
|
|
|
No my data like this
node type 1 = Buildings
node type 2 = Employees
node type 3 = Department
I need to store in TreeItem, for example
BuildingID, BuildingName, NodeType1
EmployeeID, EmployeeName, NadeType2
NodeType need to resolve what type of node cliked by user
and what type of child node insert to current node
i have few collection of this objects(Buildings, Employees)
couse node type use to resolve in what collection search appropriate
object
|
|
|
|
|
I've used the item image for this kind of thing before. Have a different image for different node types (one for Buildings, one for Employees, etc). Then you do a check for the image of the selected node, which gives you the node type
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
yes i think about this too
that's my back up
but may by some ideas of using cChildren in TV_ITEM structure
thank you for your answer
|
|
|
|
|
hmm.. i can't help i . i'm having my own trouble with sorting my file tree .
dont' mind if i ask you?? or any of you since you guys knows more about treectrl than me.
|
|
|
|
|
how can i use CArray.
i have class called FileInfo
<br />
class FileInfo<br />
{<br />
public : <br />
int status;<br />
CString path;<br />
CString name;<br />
CString size;<br />
CString createdTime;<br />
CString lastWrite;<br />
CString lastAccess;<br />
CString type;<br />
};<br />
and i want to put FileInfo into CArray. so I declear like this
<br />
CArray <' FileInfo*,FileInfo* '> *fileArray;
<br />
FileInfo *fileinfo = new FileInfo();<br />
fileinfo->name = "hi hi";<br />
fileArray->Add(fileinfo);<br />
<br />
i got run time error. no error for compile time
how can i fix that?
|
|
|
|
|
CArray <FileInfo, FileInfo &> fileArray;
|
|
|
|
|
Or, alternatively, use CTypedPtrArray to store pointers.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
would it be the way to use CTypedPrtArray??
<br />
CTypedPtrArray <FileInfo,FileInfo*> *a;<br />
FileInfo *fileinfo = new FileInfo();<br />
FileInfo *fileinf = new FileInfo();<br />
<br />
fileinfo->name = "he ha";<br />
a->Add(fileinfo);<br />
<br />
fileinf = a->GetAt(0);<br />
MessageBox(fileinf->name);<br />
|
|
|
|
|
Not quite. CTypedPtrArray is, like CArray, a template class. You can get more info from MSDN, but in a nutshell:
CTypedPtrArray<CPtrArray, FileInfo *> a;
Then do the rest like you had there. Note that since it is an array of pointers, you are responsible for deleteing the pointers when necessary.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
i got it. now.
<br />
CTypedPtrArray <CPtrArray,FileInfo*> a;<br />
FileInfo *fileinfo = new FileInfo();<br />
FileInfo *fileinf = new FileInfo();<br />
<br />
fileinfo->name = "he ha";<br />
a.Add(fileinfo);<br />
<br />
fileinf = a.GetAt(0);<br />
MessageBox(fileinf->name);<br />
rose! thanks
|
|
|
|
|
uh... i dont' know how to use it.. coz i get run time error again..
please tell me how.
this is what i did
<br />
CArray <FileInfo,FileInfo &>*a;<br />
FileInfo fileinfo;;<br />
<br />
fileinfo.name = "testing... testing....";<br />
a->Add(fileinfo);<br />
FileInfo fileInfo;<br />
<br />
fileInfo = a->GetAt(0);<br />
MessageBox(fileInfo.name);<br />
|
|
|
|
|
I am sorry, I should be more specific. Do this:
CArray <FileInfo, FileInfo &> fileArray;
FileInfo fileinfo;
fileinfo.name = ...
fileArray.Add(fileinfo);
...
fileinfor = fileArray[0];
MessageBox(fileInfo.name);
|
|
|
|
|
thanks...
rose!
|
|
|
|
|
do you have demos using this ocx ?
I need to make a program that can send video/sounds to anypersons sometime
Tks
|
|
|
|
|
New VC++ source code demo "AV ICQ" is included in avphone3 control:
http://www.banasoft.net/avphone3/avphone3.htm
|
|
|
|
|
I have the following function to receive all the applications running on the desktop:
BOOL CALLBACK AddWinsList(HWND hWnd, LPARAM lParam)
{
if (!IsWindowVisible(hWnd) || GetWindow(hWnd, GW_OWNER) != NULL)
return TRUE;
TCHAR szClassName[80];
GetClassName(hWnd, szClassName, 80);
if (lstrcmpi(szClassName, _T("Progman")) == 0)
return TRUE;
char szWndText[556];
GetWindowText(hWnd, szWndText, 556);
if (strlen(szWndText) > 0)
AfxMessageBox(szWndText);//just print at moment
return TRUE;
}
void CCommunicatorView::ReadApplications()
{
EnumWindows((WNDENUMPROC)AddWinsList, (LPARAM)NULL);
}
The above returns all running windows. How can I retrieve the applications filename from the 'hWnd' variable above? If Visual c++ was running i would receive the file name MSDEV.EXE.
Its has to run on Windows 95(second edition),ME,NT,2000,XP
Thanks
Neil
|
|
|
|
|
There may be an easier way, but you could
1) Call GetWindowThreadProcessId to get the ProcessID which owns the window.
2) Call OpenProcess to get a HANLDE for the process
3) Call GetModuleFileName
4) Close CloseHandle.
I haven't tried this, but I think this will work for you.
|
|
|
|
|
This is exactly how you have to do it, except in step 3, I believe that you meant GetModuleFileNameEx .
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I though GetModuleFileNameEx would only work under NT,2000. Isn't a part of the PSAPI?
|
|
|
|
|
Matt Gullett wrote:
I though GetModuleFileNameEx would only work under NT,2000. Isn't a part of the PSAPI?
You are right about that.
The problem with GetModuleFileName though, is that it queries a module for the current process, it does not let you specify the process handle that you want to query. So I do not think that this solution will work.
Some how GetModuleFileName needs to be called from the process that owns the window.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Is there any other way of getting the filename from the 'hWnd' of an application?
|
|
|
|
|
What we just determined is that the function that you need to do it only exists on NT.
So if you want a portable way of doing it from the Win 9X series of operating systems you will need to find a way to execute the GetModuleFileName function from inside of that process. One way to do this is to load a dll into that process, and that DLL can then call that function. If you are interested in this method I can find you some more details about it.
If I think of any other methods I will post them as well.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
This article may not directly answer your question, but is worth looking at if you haven't already.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|