mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 23:36:45 +00:00
compatibility changes for correct start menu subentries on Windows 9x
svn path=/trunk/; revision=6094
This commit is contained in:
parent
e125705217
commit
b0665e94ab
6 changed files with 170 additions and 83 deletions
|
@ -32,3 +32,5 @@
|
||||||
28.08.2003 m. fuchs control panel window in cabinet view mode
|
28.08.2003 m. fuchs control panel window in cabinet view mode
|
||||||
29.09.2003 m. fuchs Now we handle start menu popups via StartMenuRoot::TrackStartmenu().
|
29.09.2003 m. fuchs Now we handle start menu popups via StartMenuRoot::TrackStartmenu().
|
||||||
30.09.2003 m. fuchs compatibility to building as Winelib application
|
30.09.2003 m. fuchs compatibility to building as Winelib application
|
||||||
|
10.09.2003 m. fuchs compatibility changes for correct desktop windows size on Windows NT
|
||||||
|
19.09.2003 m. fuchs compatibility changes for correct start menu subentries on Windows 9x
|
||||||
|
|
|
@ -159,6 +159,12 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
||||||
// the first explorer instance
|
// the first explorer instance
|
||||||
BOOL startup_desktop = !IsAnyDesktopRunning();
|
BOOL startup_desktop = !IsAnyDesktopRunning();
|
||||||
|
|
||||||
|
bool autostart = true;
|
||||||
|
|
||||||
|
#ifdef _DEBUG //MF: disabled for debugging
|
||||||
|
autostart = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// If there is given the command line option "-desktop", create desktop window anyways
|
// If there is given the command line option "-desktop", create desktop window anyways
|
||||||
if (!lstrcmp(lpCmdLine,TEXT("-desktop")))
|
if (!lstrcmp(lpCmdLine,TEXT("-desktop")))
|
||||||
startup_desktop = TRUE;
|
startup_desktop = TRUE;
|
||||||
|
@ -171,6 +177,14 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
||||||
startup_desktop = TRUE;
|
startup_desktop = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!lstrcmp(lpCmdLine,TEXT("-noautostart")))
|
||||||
|
autostart = false;
|
||||||
|
|
||||||
|
//REMOTE DBG
|
||||||
|
startup_desktop = TRUE;
|
||||||
|
nShowCmd = SW_HIDE;
|
||||||
|
|
||||||
|
|
||||||
g_Globals._hInstance = hInstance;
|
g_Globals._hInstance = hInstance;
|
||||||
|
|
||||||
HWND hwndDesktop = 0;
|
HWND hwndDesktop = 0;
|
||||||
|
@ -179,12 +193,11 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
||||||
{
|
{
|
||||||
hwndDesktop = DesktopWindow::Create();
|
hwndDesktop = DesktopWindow::Create();
|
||||||
|
|
||||||
#ifndef _DEBUG //MF: disabled for debugging
|
if (autostart)
|
||||||
{
|
{
|
||||||
char* argv[] = {""};
|
char* argv[] = {""};
|
||||||
startup(1, argv);
|
startup(1, argv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = explorer_main(hInstance, hwndDesktop, nShowCmd);
|
int ret = explorer_main(hInstance, hwndDesktop, nShowCmd);
|
||||||
|
|
|
@ -777,8 +777,7 @@ void StartMenuRoot::ShowLaunchDialog(HWND hwndDesktopBar)
|
||||||
static LPCSTR szTitle = "Create New Task";
|
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.";
|
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"));
|
static DynamicFct<RUNFILEDLG> RunFileDlg(_T("SHELL32"), 61);
|
||||||
RUNFILEDLG RunFileDlg = (RUNFILEDLG)GetProcAddress(hShell32, (LPCSTR)61);
|
|
||||||
|
|
||||||
// Show "Run..." dialog
|
// Show "Run..." dialog
|
||||||
if (RunFileDlg) {
|
if (RunFileDlg) {
|
||||||
|
@ -789,47 +788,43 @@ void StartMenuRoot::ShowLaunchDialog(HWND hwndDesktopBar)
|
||||||
MultiByteToWideChar(CP_ACP, 0, szTitle, -1, wTitle, 40);
|
MultiByteToWideChar(CP_ACP, 0, szTitle, -1, wTitle, 40);
|
||||||
MultiByteToWideChar(CP_ACP, 0, szText, -1, wText, 256);
|
MultiByteToWideChar(CP_ACP, 0, szText, -1, wText, 256);
|
||||||
|
|
||||||
RunFileDlg(hwndDesktopBar, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
|
(*RunFileDlg)(hwndDesktopBar, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RunFileDlg(hwndDesktopBar, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
|
(*RunFileDlg)(hwndDesktopBar, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuRoot::ShowExitWindowsDialog(HWND hwndOwner)
|
void StartMenuRoot::ShowExitWindowsDialog(HWND hwndOwner)
|
||||||
{
|
{
|
||||||
HMODULE hShell32 = GetModuleHandle(_T("SHELL32"));
|
static DynamicFct<EXITWINDOWSDLG> ExitWindowsDlg(_T("SHELL32"), 60);
|
||||||
EXITWINDOWSDLG ExitWindowsDlg = (EXITWINDOWSDLG)GetProcAddress(hShell32, (LPCSTR)60);
|
|
||||||
|
|
||||||
if (ExitWindowsDlg)
|
if (ExitWindowsDlg)
|
||||||
ExitWindowsDlg(hwndOwner);
|
(*ExitWindowsDlg)(hwndOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuRoot::ShowRestartDialog(HWND hwndOwner, UINT flags)
|
void StartMenuRoot::ShowRestartDialog(HWND hwndOwner, UINT flags)
|
||||||
{
|
{
|
||||||
HMODULE hShell32 = GetModuleHandle(_T("SHELL32"));
|
static DynamicFct<RESTARTWINDOWSDLG> RestartDlg(_T("SHELL32"), 59);
|
||||||
RESTARTWINDOWSDLG RestartDlg = (RESTARTWINDOWSDLG)GetProcAddress(hShell32, (LPCSTR)59);
|
|
||||||
|
|
||||||
if (RestartDlg)
|
if (RestartDlg)
|
||||||
RestartDlg(hwndOwner, (LPWSTR)L"You selected <Log Off>.\n\n", flags); //TODO: ANSI string conversion if needed
|
(*RestartDlg)(hwndOwner, (LPWSTR)L"You selected <Log Off>.\n\n", flags); //TODO: ANSI string conversion if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuRoot::ShowSearchDialog()
|
void StartMenuRoot::ShowSearchDialog()
|
||||||
{
|
{
|
||||||
HMODULE hShell32 = GetModuleHandle(_T("SHELL32"));
|
static DynamicFct<SHFINDFILES> SHFindFiles(_T("SHELL32"), 90);
|
||||||
SHFINDFILES SHFindFiles = (SHFINDFILES)GetProcAddress(hShell32, (LPCSTR)90);
|
|
||||||
|
|
||||||
if (SHFindFiles)
|
if (SHFindFiles)
|
||||||
SHFindFiles(NULL, NULL);
|
(*SHFindFiles)(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuRoot::ShowSearchComputer()
|
void StartMenuRoot::ShowSearchComputer()
|
||||||
{
|
{
|
||||||
HMODULE hShell32 = GetModuleHandle(_T("SHELL32"));
|
static DynamicFct<SHFINDCOMPUTER> SHFindComputer(_T("SHELL32"), 91);
|
||||||
SHFINDCOMPUTER SHFindComputer = (SHFINDCOMPUTER)GetProcAddress(hShell32, (LPCSTR)91);
|
|
||||||
|
|
||||||
if (SHFindComputer)
|
if (SHFindComputer)
|
||||||
SHFindComputer(NULL, NULL);
|
(*SHFindComputer)(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,31 @@
|
||||||
#pragma comment(lib, "shell32") // link to shell32.dll
|
#pragma comment(lib, "shell32") // link to shell32.dll
|
||||||
|
|
||||||
|
|
||||||
|
// helper functions for string copying
|
||||||
|
|
||||||
|
LPSTR strcpyn(LPSTR dest, LPCSTR source, size_t count)
|
||||||
|
{
|
||||||
|
LPCSTR s;
|
||||||
|
LPSTR d = dest;
|
||||||
|
|
||||||
|
for(s=source; count&&(*d++=*s++); )
|
||||||
|
count--;
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPWSTR wcscpyn(LPWSTR dest, LPCWSTR source, size_t count)
|
||||||
|
{
|
||||||
|
LPCWSTR s;
|
||||||
|
LPWSTR d = dest;
|
||||||
|
|
||||||
|
for(s=source; count&&(*d++=*s++); )
|
||||||
|
count--;
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Exception Handler for COM exceptions
|
// Exception Handler for COM exceptions
|
||||||
|
|
||||||
void HandleException(COMException& e, HWND hwnd)
|
void HandleException(COMException& e, HWND hwnd)
|
||||||
|
@ -240,26 +265,83 @@ String ShellFolder::get_name(LPCITEMIDLIST pidl, SHGDNF flags) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// helper function for string copying
|
void ShellPath::split(ShellPath& parent, ShellPath& obj) const
|
||||||
|
|
||||||
LPSTR strcpyn(LPSTR dest, LPCSTR source, size_t count)
|
|
||||||
{
|
{
|
||||||
LPCSTR s;
|
SHITEMID *piid, *piidLast;
|
||||||
LPSTR d = dest;
|
int size = 0;
|
||||||
|
|
||||||
for(s=source; count&&(*d++=*s++); )
|
// find last item-id and calculate total size of pidl
|
||||||
count--;
|
for(piid=piidLast=&_p->mkid; piid->cb; ) {
|
||||||
|
piidLast = piid;
|
||||||
|
size += (piid->cb);
|
||||||
|
piid = (SHITEMID*)((LPBYTE)piid + (piid->cb));
|
||||||
|
}
|
||||||
|
|
||||||
return dest;
|
// copy parent folder portion
|
||||||
|
size -= piidLast->cb; // don't count "object" item-id
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
parent.assign(_p, size);
|
||||||
|
|
||||||
|
// copy "object" portion
|
||||||
|
obj.assign((ITEMIDLIST*)piidLast, piidLast->cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR wcscpyn(LPWSTR dest, LPCWSTR source, size_t count)
|
void ShellPath::GetUIObjectOf(REFIID riid, LPVOID* ppvOut, HWND hWnd, ShellFolder& sf)
|
||||||
{
|
{
|
||||||
LPCWSTR s;
|
ShellPath parent, obj;
|
||||||
LPWSTR d = dest;
|
|
||||||
|
|
||||||
for(s=source; count&&(*d++=*s++); )
|
split(parent, obj);
|
||||||
count--;
|
|
||||||
|
|
||||||
return dest;
|
LPCITEMIDLIST idl = obj;
|
||||||
|
|
||||||
|
if (parent && parent->mkid.cb)
|
||||||
|
// use the IShellFolder of the parent
|
||||||
|
CheckError(ShellFolder((IShellFolder*)sf,parent)->GetUIObjectOf(hWnd, 1, &idl, riid, 0, ppvOut));
|
||||||
|
else // else use desktop folder
|
||||||
|
CheckError(sf->GetUIObjectOf(hWnd, 1, &idl, riid, 0, ppvOut));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __MINGW32__ // ILCombine() is currently missing in MinGW.
|
||||||
|
|
||||||
|
// convert an item id list from relative to absolute (=relative to the desktop) format
|
||||||
|
LPITEMIDLIST ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const
|
||||||
|
{
|
||||||
|
return ILCombine(parent_pidl, _p);
|
||||||
|
|
||||||
|
/* seems to work only for NT upwards
|
||||||
|
// create a new item id list with _p append behind parent_pidl
|
||||||
|
int l1 = _malloc->GetSize((void*)parent_pidl) - sizeof(USHORT/ SHITEMID::cb /);
|
||||||
|
int l2 = _malloc->GetSize(_p);
|
||||||
|
|
||||||
|
LPITEMIDLIST p = (LPITEMIDLIST) _malloc->Alloc(l1+l2);
|
||||||
|
|
||||||
|
memcpy(p, parent_pidl, l1);
|
||||||
|
memcpy((LPBYTE)p+l1, _p, l2);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
LPITEMIDLIST ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const
|
||||||
|
{
|
||||||
|
static DynamicFct<LPITEMIDLIST(WINAPI*)(LPCITEMIDLIST, LPCITEMIDLIST)> ILCombine(_T("SHELL32"), 25);
|
||||||
|
|
||||||
|
if (ILCombine.found())
|
||||||
|
return ILCombine(parent_pidl, _p);
|
||||||
|
|
||||||
|
// create a new item id list with _p append behind parent_pidl
|
||||||
|
int l1 = _malloc->GetSize((void*)parent_pidl) - sizeof(USHORT/*SHITEMID::cb*/);
|
||||||
|
int l2 = _malloc->GetSize(_p);
|
||||||
|
|
||||||
|
LPITEMIDLIST p = (LPITEMIDLIST) _malloc->Alloc(l1+l2);
|
||||||
|
|
||||||
|
memcpy(p, parent_pidl, l1);
|
||||||
|
memcpy((LPBYTE)p+l1, _p, l2);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -555,42 +555,9 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
|
||||||
_malloc->Free(h);
|
_malloc->Free(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void split(ShellPath& parent, ShellPath& obj) const
|
void split(ShellPath& parent, ShellPath& obj) const;
|
||||||
{
|
|
||||||
SHITEMID *piid, *piidLast;
|
|
||||||
int size = 0;
|
|
||||||
|
|
||||||
// find last item-id and calculate total size of pidl
|
|
||||||
for(piid=piidLast=&_p->mkid; piid->cb; ) {
|
|
||||||
piidLast = piid;
|
|
||||||
size += (piid->cb);
|
|
||||||
piid = (SHITEMID*)((LPBYTE)piid + (piid->cb));
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy parent folder portion
|
|
||||||
size -= piidLast->cb; // don't count "object" item-id
|
|
||||||
|
|
||||||
if (size > 0)
|
void GetUIObjectOf(REFIID riid, LPVOID* ppvOut, HWND hWnd=0, ShellFolder& sf=Desktop());
|
||||||
parent.assign(_p, size);
|
|
||||||
|
|
||||||
// copy "object" portion
|
|
||||||
obj.assign((ITEMIDLIST*)piidLast, piidLast->cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetUIObjectOf(REFIID riid, LPVOID* ppvOut, HWND hWnd=0, ShellFolder& sf=Desktop())
|
|
||||||
{
|
|
||||||
ShellPath parent, obj;
|
|
||||||
|
|
||||||
split(parent, obj);
|
|
||||||
|
|
||||||
LPCITEMIDLIST idl = obj;
|
|
||||||
|
|
||||||
if (parent && parent->mkid.cb)
|
|
||||||
// use the IShellFolder of the parent
|
|
||||||
CheckError(ShellFolder((IShellFolder*)sf,parent)->GetUIObjectOf(hWnd, 1, &idl, riid, 0, ppvOut));
|
|
||||||
else // else use desktop folder
|
|
||||||
CheckError(sf->GetUIObjectOf(hWnd, 1, &idl, riid, 0, ppvOut));
|
|
||||||
}
|
|
||||||
|
|
||||||
ShellFolder get_folder()
|
ShellFolder get_folder()
|
||||||
{
|
{
|
||||||
|
@ -602,21 +569,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
|
||||||
return ShellFolder(parent, _p);
|
return ShellFolder(parent, _p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// convert an item id list from relative to absolute (=relative to the desktop) format
|
// convert an item id list from relative to absolute (=relative to the desktop) format
|
||||||
LPITEMIDLIST create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const
|
LPITEMIDLIST create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const;
|
||||||
{
|
|
||||||
// create a new item id list with _p append behind parent_pidl
|
|
||||||
int l1 = _malloc->GetSize((void*)parent_pidl) - sizeof(USHORT/*SHITEMID::cb*/);
|
|
||||||
int l2 = _malloc->GetSize(_p);
|
|
||||||
|
|
||||||
LPITEMIDLIST p = (LPITEMIDLIST) _malloc->Alloc(l1+l2);
|
|
||||||
|
|
||||||
memcpy(p, parent_pidl, l1);
|
|
||||||
memcpy((LPBYTE)p+l1, _p, l2);
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -397,6 +397,47 @@ struct String
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// link dynamicly to functions by using GetModuleHandle() and GetProcAddress()
|
||||||
|
template<typename FCT> struct DynamicFct
|
||||||
|
{
|
||||||
|
DynamicFct(LPCTSTR moduleName, UINT ordinal)
|
||||||
|
{
|
||||||
|
HMODULE hModule = GetModuleHandle(moduleName);
|
||||||
|
|
||||||
|
_fct = (FCT) GetProcAddress(hModule, (LPCSTR)ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
FCT operator*() const {return _fct;}
|
||||||
|
operator bool() const {return _fct? true: false;}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FCT _fct;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// link dynamicly to functions by using LoadLibrary() and GetProcAddress()
|
||||||
|
template<typename FCT> struct DynamicLoadLibFct
|
||||||
|
{
|
||||||
|
DynamicLoadLibFct(LPCTSTR moduleName, UINT ordinal)
|
||||||
|
{
|
||||||
|
_hModule = LoadLibrary(moduleName);
|
||||||
|
|
||||||
|
_fct = (FCT) GetProcAddress(_hModule, (LPCSTR)ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
~DynamicLoadLibFct()
|
||||||
|
{
|
||||||
|
FreeLibrary(_hModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
FCT operator*() const {return _fct;}
|
||||||
|
operator bool() const {return _fct? true: false;}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
HMODULE _hModule;
|
||||||
|
FCT _fct;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue