Hi all,
I have a little problem with the GetOpenFileName API. I have to make a multiple files selection and, as reported on MS web site, I use the dialog hook intercepting selection changes and adjusting allocated memory to store all selected file's names. Till now it seems to work (well, I have a little problem with VERY large number of selected files, but I will investigate this bug in a second time), but if I set the OFN_ENABLEHOOK flag in the OPENFILENAME structure the dialog will not have the shortcut sidebar (I use win 2000) like in the image below. This is the code I use to fill the structure in:
Am I doing something wronk? (I soppose I do, if not all would work well :grin: )
I have a little problem with the GetOpenFileName API. I have to make a multiple files selection and, as reported on MS web site, I use the dialog hook intercepting selection changes and adjusting allocated memory to store all selected file's names. Till now it seems to work (well, I have a little problem with VERY large number of selected files, but I will investigate this bug in a second time), but if I set the OFN_ENABLEHOOK flag in the OPENFILENAME structure the dialog will not have the shortcut sidebar (I use win 2000) like in the image below. This is the code I use to fill the structure in:
[...]
ZeroMemory(&ofn, sizeof(OPENFILENAME));
if(GetModuleFileName(NULL, szInitialDir, MAX_PATH))
{
PathRemoveFileSpec(szInitialDir);
ofn.lpstrInitialDir = szInitialDir;
}
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = NULL;
ofn.lpstrFilter = TEXT("All Files (*.*)\0*.*\0\0");
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 1;
/* memory allocation will be dinamically adjusted during file selection */
ofn.lpstrFile = (LPTSTR) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, MAX_PATH * sizeof(TCHAR));
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_ENABLEHOOK | OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_FILEMUSTEXIST;
ofn.lpfnHook = GetOpenFileHook;
if(!GetOpenFileName(&ofn))
{
HeapFree(GetProcessHeap(), 0, ofn.lpstrFile);
ofn.lpstrFile = NULL;
ofn.nMaxFile = 0;
return 0;
}
[...]
Am I doing something wronk? (I soppose I do, if not all would work well :grin: )
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/commdlg_1hma.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/commdlg_3cbp.asp
Strange, everything at MSN would suggest it should work?
Does the hook work still?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/commdlg_3cbp.asp
Strange, everything at MSN would suggest it should work?
Does the hook work still?
I cannot find where I'm doing something wrong... The hook seems to work well, I put a breakpoint inside the WM_INITDIALOG of the hook procedure and the debugger pops up as soon as I click on my "Open" button.
Anyway thakyou.
Anyway thakyou.
Maybe I have found a possible explanation. This is what MS reports on its web site:
I use ofn.lStructSize = sizeof(OPENFILENAME), but I have an old SDK (the one which comes with Visual C++ 6.0, withot the new three fields defined in OPENFILENAME:
So my sizeof(OPENFILENAME) should be equal to the new sizeof(OPENFILENAME_SIZE_VERSION_400). Is this possible?
Remarks
For compatibility reasons, the Places Bar is hidden if Flags is set to OFN_ENABLEHOOK and lStructSize is OPENFILENAME_SIZE_VERSION_400.
For compatibility reasons, the Places Bar is hidden if Flags is set to OFN_ENABLEHOOK and lStructSize is OPENFILENAME_SIZE_VERSION_400.
I use ofn.lStructSize = sizeof(OPENFILENAME), but I have an old SDK (the one which comes with Visual C++ 6.0, withot the new three fields defined in OPENFILENAME:
typedef struct tagOFN {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
#if (_WIN32_WINNT >= 0x0500)
void * pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
#endif // (_WIN32_WINNT >= 0x0500)
} OPENFILENAME, *LPOPENFILENAME;
So my sizeof(OPENFILENAME) should be equal to the new sizeof(OPENFILENAME_SIZE_VERSION_400). Is this possible?
LuHa,
I already wrote some code for GetOpenFileName with multiple selection:
http://www.asmcommunity.net/board/index.php?topic=2651&highlight=getopenfilename
Hope that helps!
I already wrote some code for GetOpenFileName with multiple selection:
http://www.asmcommunity.net/board/index.php?topic=2651&highlight=getopenfilename
Hope that helps!
bAZiK (please note that I always write your name correctly :grin: ),
I looked at your code some days ago, when I wrote my multiple files open routine, but it seems that you use a statically sized buffer to store path and files' names (tell me if I'm wrong, I use C, not assembly), while I need a dinamically allocated buffer, since I don't know how many files the user will select.
I looked at your code some days ago, when I wrote my multiple files open routine, but it seems that you use a statically sized buffer to store path and files' names (tell me if I'm wrong, I use C, not assembly), while I need a dinamically allocated buffer, since I don't know how many files the user will select.
I use ofn.lStructSize = sizeof(OPENFILENAME), but I have an old SDK (the one which comes with Visual C++ 6.0, withot the new three fields defined in OPENFILENAME.
So my sizeof(OPENFILENAME) should be equal to the new sizeof(OPENFILENAME_SIZE_VERSION_400). Is this possible?