Winfile: use command line for initial directory selection

Martin Fuchs martin-fuchs at gmx.net
Wed Nov 16 17:17:28 CST 2005


Changelog:
- use command line for initial directory selection
- remove useless hwndParent variable


Index: winefile.c
===================================================================
RCS file: /home/wine/wine/programs/winefile/winefile.c,v
retrieving revision 1.62
diff -u -p -d -r1.62 winefile.c
--- winefile.c	6 Oct 2005 11:38:45 -0000	1.62
+++ winefile.c	16 Nov 2005 23:16:56 -0000
@@ -2143,9 +2143,7 @@ static LRESULT CALLBACK FrameWndProc(HWN
 			break;
 
 		case WM_DESTROY:
-			 /* don't exit desktop when closing file manager window */
-			if (!Globals.hwndParent)
-				PostQuitMessage(0);
+			PostQuitMessage(0);
 			break;
 
 		case WM_INITMENUPOPUP: {
@@ -4654,11 +4652,11 @@ static void InitInstance(HINSTANCE hinst
 }
 
 
-static void show_frame(HWND hwndParent, int cmdshow)
+static void show_frame(HWND hwndParent, int cmdshow, LPCTSTR path)
 {
 	static const TCHAR sMDICLIENT[] = {'M','D','I','C','L','I','E','N','T','\0'};
 
-	TCHAR path[MAX_PATH], b1[BUFFER_LEN];
+	TCHAR buffer[MAX_PATH], b1[BUFFER_LEN];
 	ChildWnd* child;
 	HMENU hMenuFrame, hMenuWindow;
 
@@ -4667,8 +4665,6 @@ static void show_frame(HWND hwndParent, 
 	if (Globals.hMainWnd)
 		return;
 
-	Globals.hwndParent = hwndParent;
-
 	hMenuFrame = LoadMenu(Globals.hInstance, MAKEINTRESOURCE(IDM_WINEFILE));
 	hMenuWindow = GetSubMenu(hMenuFrame, GetMenuItemCount(hMenuFrame)-2);
 
@@ -4723,7 +4719,11 @@ static void show_frame(HWND hwndParent, 
 					Globals.hMainWnd, (HMENU)IDW_STATUSBAR, hinstance, 0);*/
 
 	/*TODO: read paths and window placements from registry */
-	GetCurrentDirectory(MAX_PATH, path);
+
+	if (!path || !*path) {
+		GetCurrentDirectory(MAX_PATH, buffer);
+		path = buffer;
+	}
 
 	ShowWindow(Globals.hMainWnd, cmdshow);
 
@@ -4797,7 +4797,7 @@ static int find_window_class(LPCTSTR cla
 
 #endif
 
-static int winefile_main(HINSTANCE hinstance, HWND hwndParent, int cmdshow)
+static int winefile_main(HINSTANCE hinstance, int cmdshow, LPCTSTR path)
 {
 	MSG msg;
 
@@ -4807,7 +4807,7 @@ static int winefile_main(HINSTANCE hinst
 	        /*TODO: read window placement from registry */
 		cmdshow = SW_MAXIMIZE;
 
-	show_frame(hwndParent, cmdshow);
+	show_frame(0, cmdshow, path);
 
 	while(GetMessage(&msg, 0, 0, 0)) {
 		if (Globals.hmdiclient && TranslateMDISysAccel(Globals.hmdiclient, &msg))
@@ -4826,17 +4826,26 @@ static int winefile_main(HINSTANCE hinst
 }
 
 
-int APIENTRY WinMain(HINSTANCE hinstance,
-					 HINSTANCE previnstance,
-					 LPSTR	   cmdline,
-					 int	   cmdshow)
+#if defined(UNICODE) && defined(_MSC_VER)
+int APIENTRY wWinMain(HINSTANCE hinstance, HINSTANCE previnstance, LPWSTR cmdline, int cmdshow)
+#else
+int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE previnstance, LPSTR cmdline, int cmdshow)
+#endif
 {
 #ifdef _NO_EXTENSIONS
 	if (find_window_class(sWINEFILEFRAME))
 		return 1;
 #endif
 
-	winefile_main(hinstance, 0, cmdshow);
+#if defined(UNICODE) && !defined(_MSC_VER)
+	{ /* convert ANSI cmdline into WCS path string */
+	TCHAR buffer[MAX_PATH];
+	MultiByteToWideChar(CP_ACP, 0, cmdline, -1, buffer, MAX_PATH);
+	winefile_main(hinstance, cmdshow, buffer);
+	}
+#else
+	winefile_main(hinstance, cmdshow, cmdline);
+#endif
 
 	return 0;
 }
Index: winefile.h
===================================================================
RCS file: /home/wine/wine/programs/winefile/winefile.h,v
retrieving revision 1.16
diff -u -p -d -r1.16 winefile.h
--- winefile.h	7 Jul 2005 12:00:17 -0000	1.16
+++ winefile.h	16 Nov 2005 23:16:56 -0000
@@ -113,7 +113,6 @@ typedef struct
   HANDLE    hInstance;
   HACCEL    haccel;
   ATOM      hframeClass;
-  HWND      hwndParent;
 
   HWND      hMainWnd;
   HMENU     hMenuFrame;




More information about the wine-patches mailing list