]> Creatis software - clitk.git/commitdiff
Changed entry point of application on Windows to remove background console
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 17 May 2011 17:18:18 +0000 (19:18 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 17 May 2011 17:18:18 +0000 (19:18 +0200)
vv/CMakeLists.txt
vv/vv.cxx

index d38a79e8c4287349b3a50ddd78ce1155c20c5456..e9cd2d260b858ebed1333bb12ecd458d7c5266c2 100644 (file)
@@ -181,10 +181,6 @@ INCLUDE_DIRECTORIES(
   ../segmentation
   )
 
-IF(WIN32)
-  SET(EXE_ICON vvIcon.rc)
-ENDIF(WIN32)
-
 LINK_DIRECTORIES(${QT_LIBRARY_DIR})
 #=========================================================
 #Add each tool's dependencies
@@ -203,7 +199,12 @@ SET(vvExternalLibs clitkSegmentationGgoLib clitkDicomRTStruct ${toolLibs} ${foun
 ADD_LIBRARY(vvLib ${vv_SRCS} ${vv_UI_CXX})
 TARGET_LINK_LIBRARIES(vvLib ${vvExternalLibs})
 
-ADD_EXECUTABLE(vv vv.cxx ${EXE_ICON})
+IF(WIN32)
+  ADD_EXECUTABLE(vv WIN32 vv.cxx vvIcon.rc)
+ELSE(WIN32)
+  ADD_EXECUTABLE(vv vv.cxx)
+ENDIF(WIN32)
+
 TARGET_LINK_LIBRARIES(vv vvLib)
 
 
index 2a68f3384e3e330c39fcc7dd4b171addb9d9478f..0bfc01ef97084ea2bc695dc0eaee10421ada610c 100644 (file)
--- a/vv/vv.cxx
+++ b/vv/vv.cxx
@@ -38,7 +38,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include  <errno.h>
+#include <errno.h>
 
 void load_image_first_error()
 {
@@ -61,8 +61,16 @@ std::string create_timed_string()
 }
 
 //------------------------------------------------------------------------------
+#ifdef _WIN32
+int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+  int argc = __argc;
+  char **argv = __argv;
+#else
 int main( int argc, char** argv )
 {
+#endif
+
   CLITK_INIT;
 
   QApplication app( argc, argv );
@@ -129,9 +137,11 @@ int main( int argc, char** argv )
 
           if(itksys::SystemTools::FileExists(log_dir.c_str()) &&
               !itksys::SystemTools::FileIsDirectory(log_dir.c_str())) {
-            itkGenericExceptionMacro(<< "Error creating log directory, file exists and is not a directory.");
+            std::cerr << "Error creating log directory, file exists and is not a directory." << std::endl;
+            exit(1);
           } else if(!itksys::SystemTools::MakeDirectory(log_dir.c_str())) {
-            itkGenericExceptionMacro(<< "Error creating log directory.");
+            std::cerr << "Error creating log directory." << std::endl;
+            exit(1);
           }
 
           std::string log_file = log_dir + "/" + create_timed_string() + ".log";