|
That's weird behavior.
I don't have a proven workaround, but here's what I'd do:
1. Set the lpstrDefExt member to NULL.
2. After DoModal, check the file name for a period. If it doesn't have one, append your default extension (.mydoc) to it.
Regards,
Alvaro
Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein
|
|
|
|
|
Does anyone know how to display the copy progress dialog box? Chris Maunder and Michael Dunn's dialog wrapper both look very good:
http://www.codeproject.com/miscctrl/#Progress Controls
But I do not know how to implement it with progress... I am using CFileFind and CFileFind::FindNextFile( ) to find the source files. I use ::CopyFile( ) to copy files, which can only copies 1 file at a time. Thus I have no way of finding out total # of files or total copying size.
Help!??
Thanks.
|
|
|
|
|
You can use SHFileOperation. It'll not only show the copy-progress bar, but is also recycle-bin-aware
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
You can also use CopyFileEx which accepts a callback function as an argument.
|
|
|
|
|
How can I use a dialog box that browse FOLDER in my program?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Take a look at the SHBrowseForFolder function of the shell API.
|
|
|
|
|
Thank you Tak.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
hi friend ,
char szFolderPath[MAX_PATH];
LPBROWSEINFO pBrowseInfo;
pBrowseInfo=new BROWSEINFO ;
pBrowseInfo->hwndOwner=m_hWnd;
pBrowseInfo->pidlRoot=NULL;
pBrowseInfo->pszDisplayName=szFolderPath;
pBrowseInfo->lpszTitle="the text u enter here is appeared in the top of the dialog ";
pBrowseInfo->ulFlags=BIF_RETURNONLYFSDIRS;
pBrowseInfo->lpfn =NULL;
pBrowseInfo->lParam=0;
pBrowseInfo->iImage =0;
LPITEMIDLIST pIdList;
pIdList=SHBrowseForFolder(pBrowseInfo);
SHGetPathFromIDList(pIdList,szFolderPath);
//Now u get the foder path in szFolderPath...
delete pBrowseInfo;
OK???
-Renjith
Trace The Bugs...
|
|
|
|
|
Thank you.
|
|
|
|
|
I'm getting an "Unhandled exeption" when running this function. I get it when it comes to the pBrowse->Next line. I have already tested if pBrowse is null and it isn't, neihter is pIdl. Here's the code
void OnOpenFolder()
{
BROWSEINFO bi = {0};
IShellFolder *pSf;
LPMALLOC pMalloc;
DWORD pActual = 0;
bi.hwndOwner = ghWnd;
bi.pidlRoot = NULL;
bi.lpszTitle = "Locate MP3 Folder";
bi.ulFlags = BIF_DONTGOBELOWDOMAIN;
bi.lpfn = NULL;
SHGetDesktopFolder (&pSf);
if (pSf)
{
LPITEMIDLIST pIdl;
pIdl = SHBrowseForFolder(&bi);
if (pIdl)
{
IEnumIDList *pBrowse;
SHGetMalloc(&pMalloc);
pSf->BindToObject(pIdl, NULL, IID_IShellFolder, (LPVOID*)&pBrowse);
pBrowse->AddRef();
if (pBrowse)
{
while (pBrowse->Next(1, &pIdl, &pActual) == S_OK)
{
LVITEM Lvi = {0};
char szPath[MAX_PATH+1];
SHGetPathFromIDList(pIdl, szPath);
Lvi.mask = LVIF_TEXT;
Lvi.pszText = szPath;
Lvi.iItem = SendMessage(DlgItems[7], LVM_GETITEMCOUNT, 0, 0);
ListView_InsertItem(DlgItems[7], &Lvi);
}
}
pBrowse->Release();
}
pMalloc->Free(pIdl);
pMalloc->Release();
}
pSf->Release();
}
ghWnd is the hanlde to my window (yes, it's valid)
DlgItems[7] is the handle to a listview control, also valid.
Here's the exact error: "Unhandled exeption in app.exe (SHELL32.DLL): 0xC0000005: Access Violation."
Any help greatly appreciated
Thanks.
|
|
|
|
|
Just a clue:
There are some mistakes in your code. For example you have:
if(pBrowe)
{
...
...
}
pBrowse->Release();
Where as it should be:
if(pBrowse)
{
...
pBrowse->Release();
}
|
|
|
|
|
pSf->BindToObject(pIdl, NULL, IID_IShellFolder, (LPVOID*)&pBrowse); Shouldn't you be asking for a IID_IEnumIDList ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm not quite sure, but here's my code now, with the IID_IShellFolder parameter in BindToObjet it works, but with the IID_IEnumIDList i get that unhandled exception.
void OnOpenFolder()
{
BROWSEINFO bi = {0};
IShellFolder *pSf;
LPMALLOC pMalloc;
LPENUMIDLIST pFolder = NULL;
DWORD pActual = 0;
LVITEM Lvi = {0};
char szFolderPath[MAX_PATH+1];
bi.hwndOwner = ghWnd;
bi.pidlRoot = NULL;
bi.lpszTitle = "Locate MP3 Folder";
bi.ulFlags = BIF_DONTGOBELOWDOMAIN;
bi.lpfn = NULL;
SHGetDesktopFolder (&pSf);
if (pSf)
{
LPITEMIDLIST pIdl;
pIdl = SHBrowseForFolder(&bi);
SHGetPathFromIDList(pIdl, szFolderPath);
Lvi.mask = LVIF_TEXT;
Lvi.pszText = szFolderPath;
Lvi.iItem = SendMessage(DlgItems[7], LVM_GETITEMCOUNT, 0, 0);
ListView_InsertItem(DlgItems[7], &Lvi);
if (pIdl)
{
IShellFolder *pBrowse = NULL;
SHGetMalloc(&pMalloc);
pSf->BindToObject(pIdl, NULL, IID_IEnumIDList, (LPVOID*)&pBrowse);
pSf->Release();
pBrowse->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pFolder);
if (pBrowse)
{
while (pFolder->Next(1, &pIdl, &pActual) == S_OK)
{
SHGetPathFromIDList(pIdl, szFolderPath);
Lvi.pszText = szFolderPath;
Lvi.iItem = SendMessage(DlgItems[7], LVM_GETITEMCOUNT, 0, 0);
ListView_InsertItem(DlgItems[7], &Lvi);
}
}
pBrowse->Release();
}
pMalloc->Free(pIdl);
pMalloc->Release();
}
pSf->Release();
}
Although there still is a problem. The SHGetPathFromIDList(pIdl, szFolderPath); sets the szFolderPath to <desktop folder="">\<one of="" the="" subfolders="" in="" folder="" i="" chose="" via="" shbrowseforfolder="">
Thanks
|
|
|
|
|
I might be totally wrong, but I think there's still a mismatch problem: if pBrowse is now an IShellFolder * , you should retrieve it using IID_IShellFolder ; if you make it a IEnumIDList * , use IID_IEnumIDList . Just keep types straight.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I spoke to soon and thought that deleting the .clw file cleared up my problems with going into the wizzard.
If it isn't in the .clw file where is this error coming from? how do I clear it up.
Thanks again.
|
|
|
|
|
if you have added any code to the AFX_DATA_MAP section of a DoDataExchange, or if you've changed AFX_DATA_INIT in a window constructor, you may have added something that the classwizard doesn't understand.
so, if you have done any of that, try moving your code outside the AFX_DATA_INIT or AFX_DATA_MAP blocks.
-c
ABSURDITY:
A statement or belief manifestly inconsistent with one's own opinion.
|
|
|
|
|
manually editing wizard code causes parsing problems.specially with the classwizard .
|
|
|
|
|
Chris, Right on! That put me in the right place where I found a ; with no code around it.
Thanks.
|
|
|
|
|
Hi,
how to detect the main (primary) thread out of several threads without the toolhelp functions from Win9X respective Win2K, and without MFC's AfxGetMainThread ?
Thanks in advance
|
|
|
|
|
The easiest way is to save the ThreadID in a global before you create the other threads.
Good luck,
Bill
|
|
|
|
|
Recapping the situation: I have an app compiled for Debug which while running under the debugger is fine. If I execute the same app stand-alone it appears to have a memory leak. As suggested earlier, the stand-alone platform was configured for remote debugging.
Under Debug, Task Manager reports the application using around 7MB of memory. Task Manager also reports the overall memory usage of the system to be around 110MB. While the app memory usage varies more than I would have expected, it has not gone over 10MB that I have observed while running in debug mode.
Running standalone Task Manager initially reports the application using the same 7MB amount of memory. After 8 hours of operation the memory usage of the application has increased around to around 10MB, and after 48 hours it is around 14MB. The overall memory usage reported after 8 hours though has increased by 30MB! and this value continues to increase linearly with time. After 48 hours the overall memory usage has exceeded 300MB.
I have placed memory leak detection code around the entire app and inside the app around the core functions. The inside code reports an occassional change in memory, but reports a reciprocal change later on. As noted, it doesn't leak under debug, so dumping statistics to the debug output window is not helping resolve the problem.
Any further suggestions for locating the cause of this problem would be appreciated. FYI, the stand-alone platform is XP though I do not know if this is significant.
>>>-----> MikeO
|
|
|
|
|
Do your app have an UI? Then you might also want to check for GDI or USER handle leaks in your drawing code (using e.g. perfmon or task manager). It wouldn't be the first time handles were left unreleased from a WM_TIMER or WM_PAINT.
|
|
|
|
|
From Task Manager there is already an indication that memory is being consumed, so any suggestions what should be monitored by PerfMon? I've been studying the options this morning. None of them look promising.
Is there something else in Task Manager to check? For instance, when looking at the process list I see the app is using more memory than before, but not nearly as much more as the overall change in memory. The last time I stopped the stand-alone app, Task Manager also showed memory being released gradually instead of all at once. What do these symptoms indicate?
Details if you're interested:
The UI is very simple. Text is either output to a CListBox of limited size which is displayed by the View, or the status bar text is changed. Every few hours the window's caption is changed.
Once every 12 hours a second process is launched which takes about 30 minutes to complete. During this process is the only period when there are multiple timers running.
>>>-----> MikeO
|
|
|
|
|
Mike Osbahr wrote:
when looking at the process list I see the app is using more memory than before, but not nearly as much more as the overall change in memory.
Then it's a handle leak.
Mike Osbahr wrote:
The last time I stopped the stand-alone app, Task Manager also showed memory being released gradually instead of all at once. What do these symptoms indicate?
That you have a lot (a lot) of objects that gets cleaned up at destruction. Are you putting some objects in some container?
Once every 12 hours a second process is launched which takes about 30 minutes to complete. During this process is the only period when there are multiple timers running.
Are your app launching this process? Is it using CreateProcess? You are closing both the process and the thread handle?
|
|
|
|
|
Hi Friend
I am sure you allocate some memeory within your program and u forget to release them properly..so the program allocated memory when it runs...take a close look upon you code..lile new and malloc() or such functions.find it out..!!!
oK??
Trace The Bugs...
|
|
|
|