|
The simple answer is that you can't. The standard tree view control does not support multiple selection. I think your only solution will be to use some kind of custom control. One possibility involves using a list control instead, and manipulating the item indents, but things get quite complicated.
You could have a look here in CodeProject at the tree control section and see if any support multiple selection, but if they're based on SysTreeView32 they won't. The tree/list hybrids might be more useful.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Undoubtedly,it can.
But you should derive a class from CTreeCtrl,and override each function related to multiple select,e.g.,OnKeyDown,OnClick,and use SetItemState() to
achieve multiple select,it is a complex work,and you should think over many things.If you do well,you will fullfill a multiple select tree like the one in VC's ClassView window.
|
|
|
|
|
You can see this topic
http://www.codeguru.com/treeview/multiple_sel.shtml
But it is not ferfect,for multiple select in tree view is a very complex
work.
Cherrs
|
|
|
|
|
You can see this topic
http://www.codeguru.com/treeview/multiple_sel.shtml
But it is not perfect,for multiple select in tree view is a very complex
work.
Cherrs
|
|
|
|
|
i use +- http://www.techsoft.no/bendik/
t!
|
|
|
|
|
hi all,
can u please help me in finding out how to write the code for downloading a file(http: protocol not FTP) using API's
|
|
|
|
|
URLDownloadToCacheFile is what you want
- Roman -
|
|
|
|
|
i have used that but it is working only in intranet
|
|
|
|
|
I like the MFC WININET classes.
Here's how I generally write a simple download routine:
#include <afxinet.h>
#include <memory>
#include <stdexcept>
using namespace std;
typedef auto_ptr<CHttpConnection> apCHttpConnection;
typedef auto_ptr<CHttpFile> apCHttpFile;
typedef auto_ptr<CFtpConnection> apCFtpConnection;
typedef auto_ptr<CInternetFile> apCInternetFile;
void Download(CFile& Out,CString Agent,CString URL,CString Usr,CString Pwd,const char* PostData,HANDLE hTermRequestEvent)
{
CInternetSession Session(Agent,0);
int nTries=MAXNUMTRIES_HTTP_DOWNLOAD;
CString ErrorMsg;
_RetryDL:
try
{
CString Server,Object;
INTERNET_PORT Port;
DWORD ServiceType;
apCHttpConnection apConnection(0);
try
{
VERIFY(::AfxParseURL(URL,ServiceType,Server,Object,Port) && ServiceType==AFX_INET_SERVICE_HTTP);
apConnection=apCHttpConnection(Session.GetHttpConnection(Server,Port));
}
catch(CInternetException* pe)
{
DWORD err=pe->m_dwError;
pe->Delete();
if (err!=ERROR_SUCCESS)
ErrorMsg.ReleaseBuffer(::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,err,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),ErrorMsg.GetBuffer(1024),1024,NULL)?-1 );
apConnection=apCHttpConnection(0);
}
if (!apConnection.get())
throw runtime_error(LPCSTR("Can't connect online: "+(ErrorMsg.IsEmpty()?"check your connection.":ErrorMsg)));
apCHttpFile apFile(apConnection->OpenRequest(PostData?CHttpConnection::HTTP_VERB_POST:CHttpConnection::HTTP_VERB_GET,Object,0,1,0,0,INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE));
if (!apFile.get())
throw runtime_error("Unable to create HTTP request. (is memory low?)");
CString Headers="";
if (PostData)
Headers="Content-Type: application/x-www-form-urlencoded";
_ReSendRequest:
if (!Usr.IsEmpty())
VERIFY(apFile->SetOption(INTERNET_OPTION_USERNAME,(void*)(LPCSTR)Usr,Usr.GetLength()));
if (!Pwd.IsEmpty())
VERIFY(apFile->SetOption(INTERNET_OPTION_PASSWORD,(void*)(LPCSTR)Pwd,Pwd.GetLength()));
if (hTermRequestEvent && WaitForSingleObject(hTermRequestEvent,0)==WAIT_OBJECT_0)
return;
if (!apFile->SendRequest(Headers,Headers.GetLength(),(LPVOID)PostData,PostData?strlen(PostData) ))
throw runtime_error("Unable to send HTTP request. (is connection ok?)");
DWORD Status=0;
if (!apFile->QueryInfoStatusCode(Status))
{
DWORD err=::GetLastError();
if (err!=ERROR_SUCCESS)
ErrorMsg.ReleaseBuffer(::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,err,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),ErrorMsg.GetBuffer(1024),1024,NULL)?-1 );
throw runtime_error(ErrorMsg.IsEmpty()?"Can't query status.":LPCSTR(ErrorMsg));
}
switch (Status)
{
case HTTP_STATUS_PROXY_AUTH_REQ:
if (apFile->ErrorDlg(0,ERROR_INTERNET_INCORRECT_PASSWORD,FLAGS_ERROR_UI_FILTER_FOR_ERRORS|FLAGS_ERROR_UI_FLAGS_GENERATE_DATA|FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS)!=ERROR_INTERNET_FORCE_RETRY)
throw runtime_error("Can't connect through proxy server.");
goto _ReSendRequest;
case HTTP_STATUS_OK:
break;
case HTTP_STATUS_NOT_MODIFIED:
case HTTP_STATUS_DENIED:
default:
{
CString S;
S.Format("HTTP STATUS CODE=%u",Status);
throw runtime_error(LPCSTR(S));
}
}
DWORD ContentLength=0,D=sizeof(DWORD);
apFile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH|HTTP_QUERY_FLAG_NUMBER,&ContentLength,&D);
BYTE Buf[1024];
unsigned Bytes;
Out.SeekToBegin();
while (Bytes=apFile->Read(Buf,1024))
{
if (hTermRequestEvent && WaitForSingleObject(hTermRequestEvent,0)==WAIT_OBJECT_0)
return;
Out.Write(Buf,Bytes);
// Update Progress Bar or what have you
}
}
catch(CException* e)
{
if (--nTries>0)
{
e->Delete();
goto _RetryDL;
}
throw;
}
catch(...)
{
if (--nTries>0)
goto _RetryDL;
throw;
}
}
|
|
|
|
|
|
the app code is below .i could find any problem, why it isn't work.
BOOL AppFileOperator(LPCSTR lpszSrc, LPCSTR lpszDest, int op)
{
SHFILEOPSTRUCT stFileOP;
string strsrc = lpszSrc;
string strDesc = lpszDest;
stFileOP.pFrom = strsrc.c_str();
stFileOP.pTo = strDesc.c_str();
stFileOP.wFunc = op;
stFileOP.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
printf("Start to file operator. \n src file : %s\n, desc file is %s\n",
strsrc.c_str(), strDesc.c_str());
return SHFileOperation(&stFileOP) == 0 ? TRUE : FALSE;
}
|
|
|
|
|
If you have a look in the documentation for SHFILEOPSTRUCT, you'll see that pFrom and pTo both need to be double null terminated strings, which the std::string::c_str() operator won't give you.
A couple of minor points too - you should really initialise the entire SHFILEOPSTRUCT structure, and your code isn't UNICODE safe (but I'm assuming that's not an issue for you).
So, one possible version of this code would be (N.B. code is untested):
BOOL AppFileOperator(LPCSTR lpszSrc, LPCSTR lpszDest, int op)
{
SHFILEOPSTRUCT stFileOP={0};
char* pFrom = new char[strlen(lpszSrc)+2];
char* pTo = new char[strlen(lpszDest)+2];
strncpy(pFrom, lpszSrc, strlen(lpszSrc)+2);
strncpy(pTo, lpszDest, strlen(lpszDest)+2);
stFileOP.pFrom = pFrom;
stFileOP.pTo = pTo;
stFileOP.wFunc = op;
stFileOP.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
printf("Start to file operator.\n src file : %s,\n dest file is %s\n", lpszSrc, lpszDest);
BOOL bSuccess = (SHFileOperation(&stFileOP) == 0);
delete[] pFrom;
delete[] pTo;
return bSuccess;
}
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
thanks, a good man. ..... i'm a lazy boy
|
|
|
|
|
hi all,
i have to insert some voice data in existing wave file
for that
1.i opend the wave file by using mmioOpen in ReadWrite mode then
2.Read all the header to conform the wave file then
3.i tried to move the cursur position to particular portion in a wave file by using mmioSeek with SET_SEEK( it is failing ) then
4.i am getting the data by using wave functions then
5.i am using mmiowrite function to write the collected data in a particular portion of existing wave file
can any one help me why the mmioseek function fails
and is there good procedure to do this
thanks in advance
anju
|
|
|
|
|
hi All
I want to display text in a window (with scroll bars). I need to trap the user mouse clicks inside the control (line number where mouse was clicked ...like that).
how can i do it...
thanx
|
|
|
|
|
easy.
inherited from CEdit (if u use) to i.e. MyEdit
change member var from CEdit to MyEdit (even u use data exchange)
handle all messages in MyEdit.
includeh10
|
|
|
|
|
hi All
I want to display text in a window (with scroll bars). I need to trap the user mouse clicks inside the control (line number where mouse was clicked ...like that).
how can i do it...
thanx
|
|
|
|
|
handle WM_LBUTTONDOWN (use the class wizard to set up the function for you). this will tell you when a click happens, and where it happened.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
thanx chris
but can i handle this event in Edit Control?
harish
|
|
|
|
|
Can i use CSocket in thread? If so how?
i wana to use many instance of CSocket in thread in my program to send email.
i try the MSDN way of Attach() and then Detach(),but that method do not work.
help me and thank you!
|
|
|
|
|
|
to Nishant S
thanks for your advice!but i really want to know how to use CSocket with threads!;)
|
|
|
|
|
yes, you can, no problem.
Just don't use the same instance in multiple thread contexts. A CSocket or CAsyncSocket instance can only used in one thread context... compile in debug version and you will get asserts if you brake this rule.
|
|
|
|
|
Hello, the codegurus around the world.;)
Technically possible to use the thread in CSocket program, but
it might be conflicted to the process of GUI stuff.
CAsynSocket class is more flexiable than CSocket, and CAsynSocket
can deal with the socket process asyncriouly. This means that CAsynSocket
can deal with the mutiple sockets without thread.
At the same time, the timer process can check some socket statuses more
easily without thread.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
I need a user interface for my program which is simple yet useful. The program is an editing program where there are many parameters each of which the user needs to edit. I've made a a page that descrives 3 ideas that I've come up with so far. Sorry about the many spelling mistakes. Also keep in mind that the average user will probably be 12-18 years of age so it needs to be simple. The site is [here]. Thanks.
-Raffi
|
|
|
|
|