[NOTEPAD]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 1 Dec 2013 14:22:29 +0000 (14:22 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 1 Dec 2013 14:22:29 +0000 (14:22 +0000)
Improve print argument flag. Patch by Lee Schroeder.
CORE-7514 #resolve

svn path=/trunk/; revision=61173

reactos/base/applications/notepad/main.c

index 24d2458..9a4daed 100644 (file)
@@ -462,9 +462,9 @@ static int AlertFileDoesNotExist(LPCTSTR szFileName)
    return(nResult);
 }
 
-static void HandleCommandLine(LPTSTR cmdline)
+static BOOL HandleCommandLine(LPTSTR cmdline)
 {
-    int opt_print=0;
+    int opt_print = 0;
 
     while (*cmdline == _T(' ') || *cmdline == _T('-') || *cmdline == _T('/'))
     {
@@ -480,7 +480,7 @@ static void HandleCommandLine(LPTSTR cmdline)
         {
             case 'p':
             case 'P':
-                opt_print=1;
+                opt_print = 1;
                 break;
         }
     }
@@ -526,7 +526,10 @@ static void HandleCommandLine(LPTSTR cmdline)
             DoOpenFile(file_name);
             InvalidateRect(Globals.hMainWnd, NULL, FALSE);
             if (opt_print)
+            {
                 DIALOG_FilePrint();
+                return FALSE;
+            }
         }
         else
         {
@@ -539,7 +542,9 @@ static void HandleCommandLine(LPTSTR cmdline)
                 break;
             }
         }
-     }
+    }
+
+    return TRUE;
 }
 
 /***********************************************************************
@@ -554,10 +559,10 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int sh
     HMONITOR    monitor;
     MONITORINFO info;
     INT         x, y;
-       
+
     static const TCHAR className[] = _T("NPClass");
     static const TCHAR winName[]   = _T("Notepad");
-       
+
     switch (GetUserDefaultUILanguage())
   {
     case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
@@ -626,7 +631,10 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int sh
 
     DIALOG_ViewStatusBar();
 
-    HandleCommandLine(cmdline);
+    if (!HandleCommandLine(cmdline))
+    {
+        return 0;
+    }
 
     hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) );