|
Will this help. [^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Okay, I figured it out. Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Hi,
i'm using the classes from Barretto VN http://www.codeproject.com/KB/tree/enumdeskclones.aspx to build a Win32ExplorerTreeView & ListView and it works very good.
Now i want to load and view an (in the Listview)doubleclicked file in another view, so i need to get the full path name and extension of a file when it is double clicked in a listview for example :
F:\WORKING\MISC\OpenGL C++\OGL\MilkshapeModel.cpp
I think a need a shell function or something like that?
Could you help me with this?
Best regards Croc
|
|
|
|
|
You are not showing the full path of the file obviously, otherwise it would have been too easy to get it from there , but when you get the file name intially (from whatsoever method by extracting string from the selected path or finding files from a directory) do you store the rest of the path and extension of the file in some variable. May be a vector or something? if yes, then when the user clicks on the selected file you can map the entry in the list view to that in your data structure, prepend the path to the file name and do a ShellExecute ( not very sure that you would be needing ShellExecute.)???
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Tkanks for your quick replies, perhaps you have the time to look a bit closer to the example, becuse i tried to get these information from the file for 2 days now and it wouldn't ! . Perhaps you could help me with some details specified to this example !
Best regards
croc
|
|
|
|
|
I didn't have a look at the code as of now. Did you try what I suggested?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Yes i tried it, but
Here is the code of the function, it's a lot but i hope it will help!
void CShellListView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
CString text;
char szBuff[MAX_PATH];
CString ptrPath[5];
int i = 0;
LVHITTESTINFO lvhInf;
GetCursorPos(&lvhInf.pt);
ScreenToClient(&lvhInf.pt);
int item = ListView_HitTest(GetListCtrl().m_hWnd, &lvhInf);
if((LVHT_ONITEMLABEL & lvhInf.flags ) || (LVHT_ONITEMICON & lvhInf.flags))
{
LPTVITEMDATA* lptvid = NULL;
lptvid = (LPTVITEMDATA*) m_pMalloc->Alloc (sizeof (LPTVITEMDATA));
LVITEM lvi;
lvi.mask = LVIF_PARAM;
lvi.iItem = lvhInf.iItem;
ListView_GetItem(GetListCtrl().m_hWnd, &lvi);
lptvid = (LPTVITEMDATA*)lvi.lParam;
ULONG uAttr = SFGAO_FOLDER;
lptvid->lpsfParent->GetAttributesOf(1, (LPCITEMIDLIST *) &lptvid->lpi, &uAttr);
if(uAttr & SFGAO_FOLDER)
{
CShellClass csc;
csc.GetName(lptvid->lpsfParent , lptvid->lpi , SHGDN_NORMAL, szBuff);
this->m_pShellTreeView->SelectThisItem(szBuff);
IShellFolder *psfProgFiles = NULL;
HRESULT hr = lptvid->lpsfParent->BindToObject(lptvid->lpi, NULL, IID_IShellFolder, (LPVOID *) &psfProgFiles);
if(FAILED(hr))
return;
lptvid->lpsfParent = psfProgFiles;
LVPopulateFiles(lptvid);
text = szBuff;
ptrPath[i] = text;
AfxMessageBox(ptrPath[i]);
i++;
}
else
{
AfxMessageBox(ptrPath[0]+ptrPath[1]+ptrPath[2]+ptrPath[3]);
}
}
*pResult = 0;
}
Best regards
Croc
|
|
|
|
|
I have not looked at these classes but why don't you just add a handler and/or a member variable for your purpose?
|
|
|
|
|
CrocodileBuck wrote: I think a need a shell function or something like that?
Sounds like SHGetPathFromIDList() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi Mr.Crow,
yes i tried it with this function, but i didn't manage to get the file path, name and extension.
Could you perhaps explain me how to use this function in the right way?
Best regards
Croc
|
|
|
|
|
Assuming you have a valid IDL pointer:
LPITEMIDLIST idl;
TCHAR szPath[MAX_PATH];
SHGetPathFromIDList(idl, szPath);
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
CrocodileBuck wrote: how to use this function
See here[^].
|
|
|
|
|
I am making web Crawler. I can get hard coded URL but not able to get dynamic generated URL (URL contain ? mark ). Can you tell me, how can i get this in C++.
|
|
|
|
|
sumit.durg wrote: but not able to get dynamic generated URL (URL contain ? mark ).
From where do you want to get this "dynamically generated URL"
and where do you get the hard code URL from?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
while parsing HTML code itself.
|
|
|
|
|
Hello I have a little big problem that drive me crazy for 3 hours.
I have a function that browse the content of a folder (with subfolders).
After that operation is done I want to delete the folder. The function is recursive.
All the files in the route folder are deleted ok. But I cannot delete the subFolders and their content.
I use this code for retrieve information about files and folders:
WIN32_FIND_DATA FindFileData;
HANDLE hFind=INVALID_HANDLE_VALUE;
hFind= FindFirstFile(aux,&FindFileData);
FindNextFile(hFind, &FindFileData);
I guess that it is us
How can I remove the file/folder in use tag?
I tried with
delete &FindFileData it doesn't work. There must be a way out there ...
I tried to delete the folder without browse it first and it works fine.
The weird thing is that I can delete the files that are in the root.
|
|
|
|
|
Did you use FindClose(hFind) ?
|
|
|
|
|
Why don't you use
DeleteFile(FindFileData.cFileName); ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Can you use of _rmdir or SHFileOperation without this code?
|
|
|
|
|
|
|
I used this to erased a folder and it works
SHFILEOPSTRUCT op;
op.pFrom = szStoreFolder;
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
op.fAnyOperationsAborted = false;
op.hNameMappings = NULL;
SHFileOperation(&op);
only if you do not have the files in that folder in used...
if you have that you should FindClose(handleFile) if you used previous a function that searched for file in that folder
|
|
|
|
|
I am capturing image and saving that to a file. it is working fine. But one of other requirement is when user presses clt+alt+del, i should be able to do that (saving the image in to a bitmap file). But bitblt is failing when i press ctl+alt+del. it is returing zero.
Any suggestions ?
Thanks, Subramanyeswari
|
|
|
|
|
subramanyeswari wrote: Any suggestions ?
Yes: post the relevant code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
This is my code
RECT rc;
HDC hdcMem, hdcOld;
BYTE* m_pDrawingSurfaceBits=NULL;
BITMAPINFOHEADER bmpInfoHeader = {0};;
HBITMAP hbmDIBSection = NULL;
HWND hParent,hChild=NULL;
char* szAppName = "view.exe";
BOOL bRet = IsProcessRunning(szAppName);
if (!bRet)
{
::MessageBox(hWnd,"Application is not running",NULL,NULL);
}
hParent = FindWindow("WindowViewer", NULL);
if (!hParent)
{
::MessageBox(hWnd,"not able to find WindowViewer class",NULL,NULL);
}
if(hParent)
hChild = FindWindowEx(hParent,NULL,"ViewPU",NULL);
if (!hChild)
{
::MessageBox(hWnd,"not able to find ViewPU class",NULL,NULL);
}
::SendMessage(hChild, WM_SYSCOMMAND, SC_HOTKEY, (LPARAM) hChild);
::SendMessage(hChild, WM_SYSCOMMAND, SC_RESTORE, (LPARAM) hChild);
GetWindowRect(hChild, &rc);
hdcOld = ::GetDC(hParent);
if(hdcOld == NULL)
::MessageBox(hWnd,"hdcOld null",NULL,NULL);
// Create a compatible DC.
hdcMem = CreateCompatibleDC(hdcOld);
if(hdcMem == NULL)
::MessageBox(hWnd,"hdcMem null",NULL,NULL);
// Create a DIBSection big enough for our client rectangle.
long width = rc.right-rc.left;
long height = rc.bottom-rc.top;
if(hdcMem != NULL)
{
bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfoHeader.biBitCount = 24;
bmpInfoHeader.biPlanes = 1;
bmpInfoHeader.biCompression = BI_RGB;
bmpInfoHeader.biWidth =width;
bmpInfoHeader.biHeight = height;
bmpInfoHeader.biSizeImage = ((((bmpInfoHeader.biWidth * bmpInfoHeader.biBitCount) + 31) & ~31) >> 3) * bmpInfoHeader.biHeight;
hbmDIBSection = CreateDIBSection(hdcMem, (CONST BITMAPINFO*)&bmpInfoHeader, DIB_RGB_COLORS, (void**)&m_pDrawingSurfaceBits, NULL, 0);
}
// Select the bitmap into the off-screen DC.
HBITMAP hbmOld = (HBITMAP) SelectObject(hdcMem, hbmDIBSection);
bRet = BitBlt(hdcMem,0,0,width,height,hdcOld,0,0,SRCCOPY);//here it saying invalid handle
if (bRet ==0)
{
DWORD d=::GetLastError();
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
::MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );}
BITMAPFILEHEADER bfh = {0};
bfh.bfType = 0X4D42;
bfh.bfOffBits = sizeof(BITMAPINFOHEADER)+sizeof(BITMAPFILEHEADER);
bfh.bfSize = bfh.bfOffBits+bmpInfoHeader.biSizeImage;
bRet = SetCurrentDirectory("c:\\testBitmap");
DWORD ret = GetLastError();
char filename[200];
char *dir= "c:\\testBitmap\\";
int j;
j = sprintf(filename,"%s",dir);
j+= sprintf(filename+j,"%s",temp);
j+= sprintf(filename+j,"%d",counter);
j+= sprintf(filename+j,"%s",".bmp");
HANDLE hFile = CreateFile(filename,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (!hFile)
{
return ;
}
DWORD dwWritten = 0;
bRet = WriteFile(hFile,&bfh,sizeof(bfh),&dwWritten,NULL);
bRet = WriteFile(hFile,&bmpInfoHeader,sizeof(bmpInfoHeader),&dwWritten,NULL);
bRet = WriteFile(hFile,m_pDrawingSurfaceBits,bmpInfoHeader.biSizeImage,&dwWritten,NULL);
bRet = CloseHandle(hFile);
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
Regards, Subramanyeswari
|
|
|
|
|