📄 dialogs.c
字号:
/*
* common shell dialogs
*
* Copyright 2000 Juergen Schmied
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wingdi.h"
#include "winuser.h"
#include "commdlg.h"
#include "wine/debug.h"
#include "shellapi.h"
#include "shlobj.h"
#include "shell32_main.h"
#include "shresdef.h"
#include "undocshell.h"
typedef struct
{
HWND hwndOwner ;
HICON hIcon ;
LPCSTR lpstrDirectory ;
LPCSTR lpstrTitle ;
LPCSTR lpstrDescription ;
UINT uFlags ;
} RUNFILEDLGPARAMS ;
typedef BOOL (*LPFNOFN) (OPENFILENAMEA *) ;
WINE_DEFAULT_DEBUG_CHANNEL(shell);
INT_PTR CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM) ;
void FillList (HWND, char *) ;
/*************************************************************************
* PickIconDlg [SHELL32.62]
*
*/
BOOL WINAPI PickIconDlg(
HWND hwndOwner,
LPSTR lpstrFile,
DWORD nMaxFile,
LPDWORD lpdwIconIndex)
{
FIXME("(%p,%s,%08lx,%p):stub.\n",
hwndOwner, lpstrFile, nMaxFile,lpdwIconIndex);
return 0xffffffff;
}
/*************************************************************************
* RunFileDlg [SHELL32.61]
*
* NOTES
* Original name: RunFileDlg (exported by ordinal)
*/
void WINAPI RunFileDlg(
HWND hwndOwner,
HICON hIcon,
LPCSTR lpstrDirectory,
LPCSTR lpstrTitle,
LPCSTR lpstrDescription,
UINT uFlags)
{
RUNFILEDLGPARAMS rfdp;
HRSRC hRes;
LPVOID template;
TRACE("\n");
rfdp.hwndOwner = hwndOwner;
rfdp.hIcon = hIcon;
rfdp.lpstrDirectory = lpstrDirectory;
rfdp.lpstrTitle = lpstrTitle;
rfdp.lpstrDescription = lpstrDescription;
rfdp.uFlags = uFlags;
if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_RUN_DLG", (LPSTR)RT_DIALOG)))
{
MessageBoxA (hwndOwner, "Couldn't find dialog.", "Nix", MB_OK) ;
return;
}
if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
{
MessageBoxA (hwndOwner, "Couldn't load dialog.", "Nix", MB_OK) ;
return;
}
DialogBoxIndirectParamA((HINSTANCE)GetWindowLongPtrW( hwndOwner,
GWLP_HINSTANCE ),
template, hwndOwner, RunDlgProc, (LPARAM)&rfdp);
}
/* Dialog procedure for RunFileDlg */
INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int ic ;
char *psz, szMsg[256] ;
static RUNFILEDLGPARAMS *prfdp = NULL ;
switch (message)
{
case WM_INITDIALOG :
prfdp = (RUNFILEDLGPARAMS *)lParam ;
SetWindowTextA (hwnd, prfdp->lpstrTitle) ;
SetClassLongPtrW (hwnd, GCLP_HICON, (LPARAM)prfdp->hIcon) ;
SendMessageW (GetDlgItem (hwnd, 12297), STM_SETICON,
(WPARAM)LoadIconW (NULL, (LPCWSTR)IDI_WINLOGO), 0);
FillList (GetDlgItem (hwnd, 12298), NULL) ;
SetFocus (GetDlgItem (hwnd, 12298)) ;
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
{
HWND htxt = NULL ;
if ((ic = GetWindowTextLengthA (htxt = GetDlgItem (hwnd, 12298))))
{
psz = HeapAlloc( GetProcessHeap(), 0, (ic + 2) );
GetWindowTextA (htxt, psz, ic + 1) ;
if (ShellExecuteA(NULL, "open", psz, NULL, NULL, SW_SHOWNORMAL) < (HINSTANCE)33)
{
char *pszSysMsg = NULL ;
FormatMessageA (
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError (),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&pszSysMsg, 0, NULL
) ;
sprintf (szMsg, "Error: %s", pszSysMsg) ;
LocalFree ((HLOCAL)pszSysMsg) ;
MessageBoxA (hwnd, szMsg, "Nix", MB_OK | MB_ICONEXCLAMATION) ;
HeapFree(GetProcessHeap(), 0, psz);
SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
SetFocus(htxt);
return TRUE ;
}
FillList (htxt, psz) ;
HeapFree(GetProcessHeap(), 0, psz);
EndDialog (hwnd, 0) ;
}
}
case IDCANCEL :
EndDialog (hwnd, 0) ;
return TRUE ;
case 12288 :
{
HMODULE hComdlg = NULL ;
LPFNOFN ofnProc = NULL ;
static char szFName[1024] = "", szFileTitle[256] = "", szInitDir[768] = "" ;
static OPENFILENAMEA ofn =
{
sizeof (OPENFILENAMEA),
NULL,
NULL,
"Executable Files\0*.exe\0All Files\0*.*\0\0\0\0",
NULL,
0,
0,
szFName,
1023,
szFileTitle,
255,
(LPCSTR)szInitDir,
"Browse",
OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
0,
0,
NULL,
0,
(LPOFNHOOKPROC)NULL,
NULL
} ;
ofn.hwndOwner = hwnd ;
if (NULL == (hComdlg = LoadLibraryExA ("comdlg32", NULL, 0)))
{
MessageBoxA (hwnd, "Unable to display dialog box (LoadLibraryEx) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ;
return TRUE ;
}
if ((LPFNOFN)NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameA")))
{
MessageBoxA (hwnd, "Unable to display dialog box (GetProcAddress) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ;
return TRUE ;
}
if(ofnProc (&ofn))
{
SetFocus (GetDlgItem (hwnd, IDOK)) ;
SetWindowTextA (GetDlgItem (hwnd, 12298), szFName) ;
SendMessageA (GetDlgItem (hwnd, 12298), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
SetFocus (GetDlgItem (hwnd, IDOK)) ;
}
else
{
SetFocus(GetDlgItem(hwnd, 12288));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -