implemented 'run...' dialog by using shell32 functionality (taken from taskmgr/run.c)

svn path=/trunk/; revision=5789
This commit is contained in:
Martin Fuchs 2003-08-23 09:26:57 +00:00
parent ea2e4b1c26
commit 43fa5d1ab2
2 changed files with 53 additions and 3 deletions

View file

@ -438,11 +438,10 @@ void StartMenu::CloseStartMenu(int id)
int StartMenuButton::GetTextWidth(LPCTSTR title)
{
RECT rect = {0, 0, 0, 0};
HDC hdc = GetDC(0);
SelectedFont font(hdc, GetStockFont(DEFAULT_GUI_FONT));
FontSelection font(hdc, GetStockFont(DEFAULT_GUI_FONT));
RECT rect = {0, 0, 0, 0};
DrawText(hdc, title, -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
ReleaseDC(0, hdc);
@ -539,6 +538,7 @@ StartMenuRoot::StartMenuRoot(HWND hwnd)
_dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // dont't add subfolders
}
HWND StartMenuRoot::Create(HWND hwndDesktopBar)
{
WindowRect pos(hwndDesktopBar);
@ -547,6 +547,7 @@ HWND StartMenuRoot::Create(HWND hwndDesktopBar)
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, pos.left, pos.top-4, STARTMENU_WIDTH_MIN, 4, hwndDesktopBar);
}
LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs)
{
// add buttons for entries in _entries
@ -578,6 +579,7 @@ LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs)
return 0;
}
int StartMenuRoot::Command(int id, int code)
{
switch(id) {
@ -590,6 +592,12 @@ int StartMenuRoot::Command(int id, int code)
CloseStartMenu(id);
break;
case IDC_LAUNCH: {
HWND hwndDesktopBar = GetWindow(_hwnd, GW_OWNER);
CloseStartMenu(id);
ShowLaunchDialog(hwndDesktopBar);
break;}
case IDC_DOCUMENTS:
CreateSubmenu(id, CSIDL_PERSONAL);
break;
@ -634,6 +642,32 @@ int StartMenuRoot::Command(int id, int code)
}
void StartMenuRoot::ShowLaunchDialog(HWND hwndDesktopBar)
{
//TODO: All text phrases should be put into the resources.
static LPCSTR szTitle = "Create New Task";
static LPCSTR szText = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you.";
HMODULE hShell32 = GetModuleHandle(_T("SHELL32"));
RUNFILEDLG RunFileDlg = (RUNFILEDLG)GetProcAddress(hShell32, (LPCSTR)61);
// Show "Run..." dialog
if (RunFileDlg) {
#define W_VER_NT 0
if ((HIWORD(GetVersion())>>14) == W_VER_NT) {
WCHAR wTitle[40], wText[256];
MultiByteToWideChar(CP_ACP, 0, szTitle, -1, wTitle, 40);
MultiByteToWideChar(CP_ACP, 0, szText, -1, wText, 256);
RunFileDlg(hwndDesktopBar, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
}
else
RunFileDlg(hwndDesktopBar, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
}
}
RecentStartMenu::RecentStartMenu(HWND hwnd, const StartMenuFolders& info)
: super(hwnd, info)
{

View file

@ -168,6 +168,20 @@ protected:
};
// declare shell32's "Run..." dialog export function
typedef void (WINAPI* RUNFILEDLG)(HWND hwndOwner, HICON hIcon, LPCSTR lpstrDirectory, LPCSTR lpstrTitle, LPCSTR lpstrDescription, UINT uFlags);
//
// Flags for RunFileDlg
//
#define RFF_NOBROWSE 0x01 // Removes the browse button.
#define RFF_NODEFAULT 0x02 // No default item selected.
#define RFF_CALCDIRECTORY 0x04 // Calculates the working directory from the file name.
#define RFF_NOLABEL 0x08 // Removes the edit box label.
#define RFF_NOSEPARATEMEM 0x20 // Removes the Separate Memory Space check box (Windows NT only).
// Startmenu root window
struct StartMenuRoot : public StartMenu
{
@ -180,6 +194,8 @@ struct StartMenuRoot : public StartMenu
protected:
LRESULT Init(LPCREATESTRUCT pcs);
int Command(int id, int code);
void ShowLaunchDialog(HWND hwndDesktopBar);
};