OSDN Git Service

ckw-0.8.10-mod4-20100508 by craftware
[ckw/ckw.git] / main.cpp
index 5696df8..08ab045 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -885,6 +885,7 @@ static BOOL create_font(const char* name, int height)
 /*----------*/
 static void __hide_alloc_console()
 {
+       bool bResult = false;
        /*
         * Open Console Window
         * hack StartupInfo.wShowWindow flag
@@ -902,6 +903,7 @@ static void __hide_alloc_console()
        if(si.dwFlags == backup_flags && si.wShowWindow == backup_show) {
                *pflags |= STARTF_USESHOWWINDOW;
                *pshow  = SW_HIDE;
+               bResult = true;
        }
 
        AllocConsole();
@@ -909,6 +911,21 @@ static void __hide_alloc_console()
        /* restore */
        *pflags = backup_flags;
        *pshow  = backup_show;
+
+       while((gConWnd = GetConsoleWindow()) == NULL) {
+               Sleep(10);
+       }
+
+       if (!bResult){
+               ShowWindow(gConWnd, SW_SHOW);
+               while (!IsWindowVisible(gConWnd)) {
+                       Sleep(10);
+               }
+               while(IsWindowVisible(gConWnd)) {
+                       ShowWindow(gConWnd, SW_HIDE);
+                       Sleep(10);
+               }
+       }
 }
 
 /*----------*/
@@ -933,17 +950,6 @@ static BOOL create_console(ckOpt& opt)
 
        __hide_alloc_console();
 
-       while((gConWnd = GetConsoleWindow()) == NULL) {
-               Sleep(10);
-       }
-       ShowWindow(gConWnd, SW_SHOW);
-       while (!IsWindowVisible(gConWnd)) {
-               Sleep(10);
-       }
-       while(IsWindowVisible(gConWnd)) {
-               ShowWindow(gConWnd, SW_HIDE);
-               Sleep(10);
-       }
        SetConsoleTitle(title);
 
        SetConsoleCtrlHandler(sig_handler, TRUE);
@@ -1097,9 +1103,11 @@ static BOOL initialize()
                return(FALSE);
        }
 
+       /*
        wchar_t path[MAX_PATH+1];
        GetSystemDirectory(path, MAX_PATH);
        SetCurrentDirectory(path);
+       */
        return(TRUE);
 }