mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Added patch by Martain Fuchs for mulitple explorer instances.
svn path=/trunk/; revision=5122
This commit is contained in:
parent
3364b9cc5f
commit
8434cb67a9
5 changed files with 107 additions and 81 deletions
|
@ -75,68 +75,72 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
int Width, Height;
|
||||
WNDCLASSEX wc;
|
||||
HWND Desktop;
|
||||
HWND hwndDesktop = 0;
|
||||
|
||||
STARTUPINFO startupinfo;
|
||||
int nCmdShow = SW_SHOWNORMAL;
|
||||
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
HWND hwndExplorerBar;
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_DBLCLKS;
|
||||
wc.lpfnWndProc = &DeskWndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground= (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName= DesktopClassName;
|
||||
wc.hIconSm = NULL;
|
||||
|
||||
if (!RegisterClassEx(&wc))
|
||||
return 1; // error
|
||||
|
||||
|
||||
Width = GetSystemMetrics(SM_CXSCREEN);
|
||||
Height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
Desktop = CreateWindowEx(0, DesktopClassName, TEXT("Desktop"),
|
||||
WS_VISIBLE | WS_POPUP | WS_CLIPCHILDREN,
|
||||
0, 0, Width, Height,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
|
||||
if (! Desktop)
|
||||
// create desktop window and task var only, if we are the first explorer instance
|
||||
if (!find_window_class(DesktopClassName))
|
||||
{
|
||||
fprintf(stderr,"FATAL: Desktop window could not be initialized properly - Exiting.\n");
|
||||
return 1; // error
|
||||
}
|
||||
HWND hwndExplorerBar;
|
||||
|
||||
// call winefile startup routine
|
||||
startupinfo.wShowWindow = SW_SHOWNORMAL;
|
||||
GetStartupInfo(&startupinfo);
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_DBLCLKS;
|
||||
wc.lpfnWndProc = &DeskWndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground= (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName= DesktopClassName;
|
||||
wc.hIconSm = NULL;
|
||||
|
||||
if (startupinfo.dwFlags & STARTF_USESHOWWINDOW)
|
||||
nCmdShow = startupinfo.wShowWindow;
|
||||
if (!RegisterClassEx(&wc))
|
||||
return 1; // error
|
||||
|
||||
// Initializing the Explorer Bar !
|
||||
if (!(hwndExplorerBar=InitializeExplorerBar(hInstance, nCmdShow)))
|
||||
{
|
||||
fprintf(stderr,"FATAL: Explorer bar could not be initialized properly ! Exiting !\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Load plugins
|
||||
if (!ExplorerLoadPlugins(hwndExplorerBar))
|
||||
{
|
||||
fprintf(stderr,"WARNING: No plugin for desktop bar could be loaded.\n");
|
||||
}
|
||||
Width = GetSystemMetrics(SM_CXSCREEN);
|
||||
Height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
hwndDesktop = CreateWindowEx(0, DesktopClassName, TEXT("Desktop"),
|
||||
WS_VISIBLE | WS_POPUP | WS_CLIPCHILDREN,
|
||||
0, 0, Width, Height,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
|
||||
if (!hwndDesktop)
|
||||
{
|
||||
fprintf(stderr,"FATAL: Desktop window could not be initialized properly - Exiting.\n");
|
||||
return 1; // error
|
||||
}
|
||||
|
||||
// call winefile startup routine
|
||||
GetStartupInfo(&startupinfo);
|
||||
|
||||
if (startupinfo.dwFlags & STARTF_USESHOWWINDOW)
|
||||
nCmdShow = startupinfo.wShowWindow;
|
||||
|
||||
// Initializing the Explorer Bar
|
||||
if (!(hwndExplorerBar=InitializeExplorerBar(hInstance, nCmdShow)))
|
||||
{
|
||||
fprintf(stderr,"FATAL: Explorer bar could not be initialized properly ! Exiting !\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Load plugins
|
||||
if (!ExplorerLoadPlugins(hwndExplorerBar))
|
||||
{
|
||||
fprintf(stderr,"WARNING: No plugin for desktop bar could be loaded.\n");
|
||||
}
|
||||
|
||||
#ifndef _DEBUG //MF: disabled for debugging
|
||||
startup(argc, argv); // invoke the startup groups
|
||||
startup(argc, argv); // invoke the startup groups
|
||||
#endif
|
||||
}
|
||||
|
||||
return winefile_main(hInstance, Desktop, nCmdShow);
|
||||
return winefile_main(hInstance, hwndDesktop, nCmdShow);
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ SOURCE=.\De.rc
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\drivebar.bmp
|
||||
SOURCE=.\res\drivebar.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -230,6 +230,14 @@ SOURCE=.\En.rc
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\images.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
|
||||
!IF "$(CFG)" == "explorer - Win32 Release"
|
||||
|
@ -259,13 +267,33 @@ SOURCE=.\resource.rc
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\winefile.ico
|
||||
SOURCE=.\res\toolbar.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\winefile.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\winefile.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "include"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\explorer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\license.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\winefile.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\desktop.c
|
||||
|
@ -276,18 +304,6 @@ SOURCE=.\ex_bar.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\explorer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\license.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\splitpath.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -298,9 +314,5 @@ SOURCE=.\startup.c
|
|||
|
||||
SOURCE=.\winefile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\winefile.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
|
@ -5,6 +5,9 @@ extern int startup( int argc, char *argv[] );
|
|||
// winefile main routine
|
||||
extern int winefile_main(HINSTANCE hinstance, HWND hwndParent, int cmdshow);
|
||||
|
||||
// search for windows of a specific clasname
|
||||
extern int find_window_class(LPCTSTR classname);
|
||||
|
||||
// display file manager window
|
||||
extern void ShowFileMgr(HWND hWndParent, int cmdshow);
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ typedef struct
|
|||
HANDLE hInstance;
|
||||
HACCEL haccel;
|
||||
ATOM hframeClass;
|
||||
HWND hwndParent;
|
||||
|
||||
HWND hMainWnd;
|
||||
HMENU hMenuFrame;
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
|
||||
WINEFILE_GLOBALS Globals;
|
||||
|
||||
extern void WineLicense(HWND hWnd);
|
||||
extern void WineWarranty(HWND hWnd);
|
||||
extern void WineLicense(HWND hwnd);
|
||||
extern void WineWarranty(HWND hwnd);
|
||||
|
||||
typedef struct _Entry {
|
||||
struct _Entry* next;
|
||||
|
@ -1068,9 +1068,9 @@ LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam
|
|||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
#ifndef _ROS_ // dont't exit desktop when closing file manager window
|
||||
PostQuitMessage(0);
|
||||
#endif
|
||||
// dont't exit desktop when closing file manager window
|
||||
if (!Globals.hwndParent)
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_COMMAND: {
|
||||
|
@ -2820,7 +2820,7 @@ static void InitInstance(HINSTANCE hinstance)
|
|||
}
|
||||
|
||||
|
||||
void ShowFileMgr(HWND hWndParent, int cmdshow)
|
||||
void ShowFileMgr(HWND hwndParent, int cmdshow)
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
ChildWnd* child;
|
||||
|
@ -2831,6 +2831,8 @@ void ShowFileMgr(HWND hWndParent, int cmdshow)
|
|||
if (Globals.hMainWnd)
|
||||
return;
|
||||
|
||||
Globals.hwndParent = hwndParent;
|
||||
|
||||
hMenuFrame = LoadMenu(Globals.hInstance, MAKEINTRESOURCE(IDM_WINEFILE));
|
||||
hMenuWindow = GetSubMenu(hMenuFrame, GetMenuItemCount(hMenuFrame)-2);
|
||||
|
||||
|
@ -2845,7 +2847,7 @@ void ShowFileMgr(HWND hWndParent, int cmdshow)
|
|||
/* create main window */
|
||||
Globals.hMainWnd = CreateWindowEx(0, (LPCTSTR)(int)Globals.hframeClass, _T("Wine File"), WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hWndParent, Globals.hMenuFrame, Globals.hInstance, 0/*lpParam*/);
|
||||
hwndParent, Globals.hMenuFrame, Globals.hInstance, 0/*lpParam*/);
|
||||
|
||||
|
||||
Globals.hmdiclient = CreateWindowEx(0, _T("MDICLIENT"), NULL,
|
||||
|
@ -2960,8 +2962,6 @@ void ExitInstance()
|
|||
}
|
||||
|
||||
|
||||
#ifdef _NO_EXTENSIONS
|
||||
|
||||
/* search for already running win[e]files */
|
||||
|
||||
static int g_foundPrevInstance = 0;
|
||||
|
@ -2980,7 +2980,16 @@ static BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lparam)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
int find_window_class(LPCTSTR classname)
|
||||
{
|
||||
/* allow only one running instance */
|
||||
EnumWindows(EnumWndProc, (LPARAM)classname);
|
||||
|
||||
if (g_foundPrevInstance)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int winefile_main(HINSTANCE hinstance, HWND hwndParent, int cmdshow)
|
||||
|
@ -3022,10 +3031,7 @@ int APIENTRY WinMain(HINSTANCE hinstance,
|
|||
int cmdshow)
|
||||
{
|
||||
#ifdef _NO_EXTENSIONS
|
||||
/* allow only one running instance */
|
||||
EnumWindows(EnumWndProc, (LPARAM)WINEFILEFRAME);
|
||||
|
||||
if (g_foundPrevInstance)
|
||||
if (find_window_class(WINEFILEFRAME))
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue