📄 filedlg.c
字号:
(LPARAM)fodInfos->ofnInfos);
else
hChildDlg = CreateDialogIndirectParamA(hinst, template, hwnd,
IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
(LPARAM)fodInfos->ofnInfos);
if(hChildDlg)
{
ShowWindow(hChildDlg,SW_SHOW);
return hChildDlg;
}
}
else if( IsHooked(fodInfos))
{
RECT rectHwnd;
struct {
DLGTEMPLATE tmplate;
WORD menu,class,title;
} temp;
GetClientRect(hwnd,&rectHwnd);
temp.tmplate.style = WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | DS_CONTROL | DS_3DLOOK;
temp.tmplate.dwExtendedStyle = 0;
temp.tmplate.cdit = 0;
temp.tmplate.x = 0;
temp.tmplate.y = 0;
temp.tmplate.cx = 0;
temp.tmplate.cy = 0;
temp.menu = temp.class = temp.title = 0;
hChildDlg = CreateDialogIndirectParamA(COMDLG32_hInstance, &temp.tmplate,
hwnd, (DLGPROC)fodInfos->ofnInfos->lpfnHook, (LPARAM)fodInfos->ofnInfos);
return hChildDlg;
}
return NULL;
}
/***********************************************************************
* SendCustomDlgNotificationMessage
*
* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
*/
LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
{
LRESULT hook_result = 0;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
TRACE("%p 0x%04x\n",hwndParentDlg, uCode);
if(!fodInfos) return 0;
if(fodInfos->DlgInfos.hwndCustomDlg)
{
TRACE("CALL NOTIFY for %x\n", uCode);
if(fodInfos->unicode)
{
OFNOTIFYW ofnNotify;
ofnNotify.hdr.hwndFrom=hwndParentDlg;
ofnNotify.hdr.idFrom=0;
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
}
else
{
OFNOTIFYA ofnNotify;
ofnNotify.hdr.hwndFrom=hwndParentDlg;
ofnNotify.hdr.idFrom=0;
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
}
TRACE("RET NOTIFY\n");
}
TRACE("Retval: 0x%08lx\n", hook_result);
return hook_result;
}
static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
{
UINT sizeUsed = 0, n, total;
LPWSTR lpstrFileList = NULL;
WCHAR lpstrCurrentDir[MAX_PATH];
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("CDM_GETFILEPATH:\n");
if ( ! (fodInfos->ofnInfos->Flags & OFN_EXPLORER ) )
return -1;
/* get path and filenames */
COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrCurrentDir);
n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
TRACE("path >%s< filespec >%s< %d files\n",
debugstr_w(lpstrCurrentDir),debugstr_w(lpstrFileList),n);
if( fodInfos->unicode )
{
LPWSTR bufW = buffer;
total = lstrlenW(lpstrCurrentDir) + 1 + sizeUsed;
/* Prepend the current path */
n = lstrlenW(lpstrCurrentDir) + 1;
memcpy( bufW, lpstrCurrentDir, min(n,size) * sizeof(WCHAR));
if(n<size)
{
/* 'n' includes trailing \0 */
bufW[n-1] = '\\';
memcpy( &bufW[n], lpstrFileList, (size-n)*sizeof(WCHAR) );
}
TRACE("returned -> %s\n",debugstr_wn(bufW, total));
}
else
{
LPSTR bufA = buffer;
total = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1,
NULL, 0, NULL, NULL);
total += WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
NULL, 0, NULL, NULL);
/* Prepend the current path */
n = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1,
bufA, size, NULL, NULL);
if(n<size)
{
/* 'n' includes trailing \0 */
bufA[n-1] = '\\';
WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
&bufA[n], size-n, NULL, NULL);
}
TRACE("returned -> %s\n",debugstr_an(bufA, total));
}
MemFree(lpstrFileList);
return total;
}
static INT_PTR FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
{
UINT sizeUsed = 0;
LPWSTR lpstrFileList = NULL;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("CDM_GETSPEC:\n");
FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
if( fodInfos->unicode )
{
LPWSTR bufW = buffer;
memcpy( bufW, lpstrFileList, sizeof(WCHAR)*sizeUsed );
}
else
{
LPSTR bufA = buffer;
sizeUsed = WideCharToMultiByte( CP_ACP, 0, lpstrFileList, sizeUsed,
NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
bufA, size, NULL, NULL);
}
MemFree(lpstrFileList);
return sizeUsed;
}
/***********************************************************************
* FILEDLG95_HandleCustomDialogMessages
*
* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages
*/
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
WCHAR lpstrPath[MAX_PATH];
INT_PTR retval;
if(!fodInfos) return FALSE;
switch(uMsg)
{
case CDM_GETFILEPATH:
retval = FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam);
break;
case CDM_GETFOLDERPATH:
TRACE("CDM_GETFOLDERPATH:\n");
COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);
if (lParam)
{
if (fodInfos->unicode)
lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
else
WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
(LPSTR)lParam, (int)wParam, NULL, NULL);
}
retval = lstrlenW(lpstrPath);
break;
case CDM_GETSPEC:
retval = FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);
break;
case CDM_SETCONTROLTEXT:
TRACE("CDM_SETCONTROLTEXT:\n");
if ( lParam )
{
if( fodInfos->unicode )
SetDlgItemTextW( hwnd, (UINT) wParam, (LPWSTR) lParam );
else
SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
}
retval = TRUE;
break;
case CDM_HIDECONTROL:
/* MSDN states that it should fail for not OFN_EXPLORER case */
if (fodInfos->ofnInfos->Flags & OFN_EXPLORER)
{
HWND control = GetDlgItem( hwnd, wParam );
if (control) ShowWindow( control, SW_HIDE );
retval = TRUE;
}
else retval = FALSE;
break;
default:
if (uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
FIXME("message CDM_FIRST+%04x not implemented\n", uMsg - CDM_FIRST);
return FALSE;
}
SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, retval);
return TRUE;
}
/***********************************************************************
* FileOpenDlgProc95
*
* File open dialog procedure
*/
INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
#if 0
TRACE("0x%04x 0x%04x\n", hwnd, uMsg);
#endif
switch(uMsg)
{
case WM_INITDIALOG:
{
FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam;
/* Adds the FileOpenDlgInfos in the property list of the dialog
so it will be easily accessible through a GetPropA(...) */
SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
FILEDLG95_InitControls(hwnd);
fodInfos->DlgInfos.hwndCustomDlg =
CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
FILEDLG95_ResizeControls(hwnd, wParam, lParam);
FILEDLG95_FillControls(hwnd, wParam, lParam);
SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
return 0;
}
case WM_COMMAND:
return FILEDLG95_OnWMCommand(hwnd, wParam, lParam);
case WM_DRAWITEM:
{
switch(((LPDRAWITEMSTRUCT)lParam)->CtlID)
{
case IDC_LOOKIN:
FILEDLG95_LOOKIN_DrawItem((LPDRAWITEMSTRUCT) lParam);
return TRUE;
}
}
return FALSE;
case WM_GETISHELLBROWSER:
return FILEDLG95_OnWMGetIShellBrowser(hwnd);
case WM_DESTROY:
RemovePropA(hwnd, FileOpenDlgInfosStr);
return FALSE;
case WM_NOTIFY:
{
LPNMHDR lpnmh = (LPNMHDR)lParam;
UINT stringId = -1;
/* set up the button tooltips strings */
if(TTN_GETDISPINFOA == lpnmh->code )
{
LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
switch(lpnmh->idFrom )
{
/* Up folder button */
case FCIDM_TB_UPFOLDER:
stringId = IDS_UPFOLDER;
break;
/* New folder button */
case FCIDM_TB_NEWFOLDER:
stringId = IDS_NEWFOLDER;
break;
/* List option button */
case FCIDM_TB_SMALLICON:
stringId = IDS_LISTVIEW;
break;
/* Details option button */
case FCIDM_TB_REPORTVIEW:
stringId = IDS_REPORTVIEW;
break;
/* Desktop button */
case FCIDM_TB_DESKTOP:
stringId = IDS_TODESKTOP;
break;
default:
stringId = 0;
}
lpdi->hinst = COMDLG32_hInstance;
lpdi->lpszText = MAKEINTRESOURCEA(stringId);
}
return FALSE;
}
default :
if(uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
return FILEDLG95_HandleCustomDialogMessages(hwnd, uMsg, wParam, lParam);
return FALSE;
}
}
/***********************************************************************
* FILEDLG95_InitControls
*
* WM_INITDIALOG message handler (before hook notification)
*/
static LRESULT FILEDLG95_InitControls(HWND hwnd)
{
int win2000plus = 0;
int win98plus = 0;
int handledPath = FALSE;
OSVERSIONINFOW osVi;
static const WCHAR szwSlash[] = { '\\', 0 };
static const WCHAR szwStar[] = { '*',0 };
static const TBBUTTON tbb[] =
{
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
{VIEW_PARENTFOLDER, FCIDM_TB_UPFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
{VIEW_NEWFOLDER+1, FCIDM_TB_DESKTOP, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
{VIEW_NEWFOLDER, FCIDM_TB_NEWFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
{VIEW_LIST, FCIDM_TB_SMALLICON, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
{VIEW_DETAILS, FCIDM_TB_REPORTVIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
};
TBADDBITMAP tba[2];
RECT rectTB;
RECT rectlook;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
tba[0].hInst = HINST_COMMCTRL;
tba[0].nID = IDB_VIEW_SMALL_COLOR;
tba[1].hInst = COMDLG32_hInstance;
tba[1].nID = 800;
TRACE("%p\n", fodInfos);
/* Get windows version emulating */
osVi.dwOSVersionInfoSize = sizeof(osVi);
GetVersionExW(&osVi);
if (osVi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
win98plus = ((osVi.dwMajorVersion > 4) || ((osVi.dwMajorVersion == 4) && (osVi.dwMinorVersion > 0)));
} else if (osVi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
win2000plus = (osVi.dwMajorVersion > 4);
if (win2000plus) win98plus = TRUE;
}
TRACE("Running on 2000+ %d, 98+ %d\n", win2000plus, win98plus);
/* Get the hwnd of the controls */
fodInfos->DlgInfos.hwndFileName = GetDlgItem(hwnd,IDC_FILENAME);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -