Make sure that when building with MSVC, a Release build will launch without an annoying, floating console window
This commit is contained in:
parent
09d5d7f26b
commit
4336f75d3b
@ -2,9 +2,9 @@
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="Mixbus3"
|
||||
Name="Ardour3"
|
||||
ProjectGUID="{94B9EA5B-1D83-4573-9F02-29A2E33E6D1F}"
|
||||
RootNamespace="Mixbus3"
|
||||
RootNamespace="Ardour3"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
@ -150,7 +150,8 @@
|
||||
AdditionalLibraryDirectories="F:\pthread-win32\Pre-built.2\lib"
|
||||
GenerateManifest="true"
|
||||
IgnoreDefaultLibraryNames="libboost_regex-vc80-mt-1_40.lib;dsound.lib"
|
||||
SubSystem="1"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
@ -1229,6 +1230,10 @@
|
||||
RelativePath="..\gtk2_ardour\window_manager.cc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gtk2_ardour\msvc\winmain.cc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -1623,10 +1628,6 @@
|
||||
RelativePath="..\gtk2_ardour\lv2_plugin_ui.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gtk2_ardour\lxvst_plugin_ui.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gtk2_ardour\main_clock.h"
|
||||
>
|
||||
@ -2179,18 +2180,10 @@
|
||||
RelativePath="..\gtk2_ardour\volume_controller.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gtk2_ardour\vst_plugin_ui.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gtk2_ardour\window_manager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\gtk2_ardour\windows_vst_plugin_ui.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
|
@ -138,24 +138,26 @@ sigpipe_handler (int /*signal*/)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WINDOWS_VST_SUPPORT
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#if (defined(LXVST_SUPPORT) || (defined(COMPILER_MSVC) && defined(NDEBUG) && !defined(RDC_BUILD)))
|
||||
|
||||
#ifdef LXVST_SUPPORT
|
||||
extern int windows_vst_gui_init (int* argc, char** argv[]);
|
||||
#endif
|
||||
|
||||
/* this is called from the entry point of a wine-compiled
|
||||
executable that is linked against gtk2_ardour built
|
||||
as a shared library.
|
||||
*/
|
||||
extern "C" {
|
||||
#endif
|
||||
int ardour_main (int argc, char *argv[])
|
||||
|
||||
#else
|
||||
int main (int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
fixup_bundle_environment (argc, argv, &localedir);
|
||||
|
||||
load_custom_fonts(); /* needs to happend before any gtk and pango init calls */
|
||||
load_custom_fonts(); /* needs to happen before any gtk and pango init calls */
|
||||
|
||||
if (!Glib::thread_supported()) {
|
||||
Glib::thread_init();
|
||||
@ -165,17 +167,15 @@ int main (int argc, char *argv[])
|
||||
gtk_set_locale ();
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS_VST_SUPPORT
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#ifdef LXVST_SUPPORT
|
||||
/* this does some magic that is needed to make GTK and Wine's own
|
||||
X11 client interact properly.
|
||||
*/
|
||||
windows_vst_gui_init (&argc, &argv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
cerr << "bnd txt domain [" << PACKAGE << "] to " << localedir << endl;
|
||||
cerr << "bind txt domain [" << PACKAGE << "] to " << localedir << endl;
|
||||
|
||||
(void) bindtextdomain (PACKAGE, localedir);
|
||||
/* our i18n translations are all in UTF-8, so make sure
|
||||
@ -263,7 +263,6 @@ int main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
#ifdef WINDOWS_VST_SUPPORT
|
||||
} // end of extern C block
|
||||
#ifdef LXVST_SUPPORT
|
||||
} // end of extern "C" block
|
||||
#endif
|
||||
|
||||
|
133
gtk2_ardour/msvc/winmain.cc
Normal file
133
gtk2_ardour/msvc/winmain.cc
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
Copyright (C) 2001-2012 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
int ardour_main (int argc, char *argv[]);
|
||||
|
||||
#if (defined(LXVST_SUPPORT) || (defined(COMPILER_MSVC) && defined(NDEBUG) && !defined(RDC_BUILD)))
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
bool IsAConsolePort (HANDLE handle)
|
||||
{
|
||||
DWORD mode;
|
||||
|
||||
return (GetConsoleMode(handle, &mode) != 0);
|
||||
}
|
||||
|
||||
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
int ret = (-1);
|
||||
char szPathToProgram[768];
|
||||
char* argv[256];
|
||||
|
||||
// Essential!! Make sure that any files used by Ardour
|
||||
// will be created or opened in BINARY mode!
|
||||
_fmode = O_BINARY;
|
||||
|
||||
GetModuleFileName (NULL, (LPSTR)szPathToProgram, (DWORD)sizeof(szPathToProgram));
|
||||
argv[0] = new char[(strlen(szPathToProgram) + 1)];
|
||||
|
||||
if (argv[0])
|
||||
{
|
||||
LPWSTR lpwCmdLine = 0;
|
||||
int count, nArgs, argc = 1;
|
||||
size_t argStringLen = strlen(lpCmdLine);
|
||||
|
||||
// Copy the program path to argv[0]
|
||||
strcpy (argv[0], szPathToProgram);
|
||||
|
||||
// Parse the user's command line and add any parameters to argv
|
||||
if (argStringLen)
|
||||
{
|
||||
lpwCmdLine = new wchar_t[argStringLen+1];
|
||||
mbstowcs (lpwCmdLine, lpCmdLine, argStringLen+1);
|
||||
|
||||
LPWSTR* pwArgv = CommandLineToArgvW ((LPCWSTR)lpwCmdLine, &nArgs);
|
||||
|
||||
if (pwArgv && nArgs)
|
||||
{
|
||||
for (count = 1; count <= nArgs; count++)
|
||||
{
|
||||
int argChars = wcslen (pwArgv[count-1]);
|
||||
if (0 != (argv[count] = new char[(argChars+1)]))
|
||||
{
|
||||
argc++;
|
||||
wcstombs (argv[count], pwArgv[count-1], argChars+1);
|
||||
|
||||
// Append a NULL to the argv vector
|
||||
if (argc < 255)
|
||||
argv[count+1] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pwArgv)
|
||||
LocalFree (pwArgv);
|
||||
}
|
||||
|
||||
// If the user started Mixbus from a console, re-attach
|
||||
// to the console so we can see 'printf()' output etc.
|
||||
FILE *pStdOut = 0, *pStdErr = 0;
|
||||
BOOL bConsole = AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
if ((bConsole) && (IsAConsolePort(hStdOut)))
|
||||
{
|
||||
pStdOut = freopen( "CONOUT$", "w", stdout );
|
||||
pStdErr = freopen( "CONOUT$", "w", stderr );
|
||||
}
|
||||
|
||||
ret = ardour_main (argc, argv);
|
||||
|
||||
if (pStdOut)
|
||||
fclose (pStdOut);
|
||||
if (pStdErr)
|
||||
fclose (pStdErr);
|
||||
|
||||
if (bConsole)
|
||||
{
|
||||
// Detach and free the console from our application
|
||||
INPUT_RECORD input_record;
|
||||
|
||||
input_record.EventType = KEY_EVENT;
|
||||
input_record.Event.KeyEvent.bKeyDown = TRUE;
|
||||
input_record.Event.KeyEvent.dwControlKeyState = 0;
|
||||
input_record.Event.KeyEvent.uChar.UnicodeChar = VK_RETURN;
|
||||
input_record.Event.KeyEvent.wRepeatCount = 1;
|
||||
input_record.Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
|
||||
input_record.Event.KeyEvent.wVirtualScanCode = MapVirtualKey( VK_RETURN, 0 );
|
||||
|
||||
DWORD written = 0;
|
||||
WriteConsoleInput( GetStdHandle( STD_INPUT_HANDLE ), &input_record, 1, &written );
|
||||
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
for (count = 0; count < argc; count++)
|
||||
delete[] argv[count];
|
||||
|
||||
if (lpwCmdLine)
|
||||
delete[] lpwCmdLine;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user