Good evening, Ruurd. I wonder if you could help out a Windows novice --- me? My question concerns the way that Windows treats LyX --- as a Windows GUI app or as a console one. At the moment, Windows believes that LyX is a console app because it has a "main" function rather than a "WinMain".
You've added code in os_win32.C's init function to close down the console window that Windows helpfully displays for us: void os::init(int /* argc */, char * argv[]) { #ifdef _WIN32 // Close the console when run (probably) // not run from command prompt char WindowTitle[1024]; HWND hwndFound; GetConsoleTitle(WindowTitle,1024); if ((strcmp(WindowTitle, argv[0]) == 0) || (strcmp(WindowTitle,"LyX") == 0)) { // format a "unique" newWindowTitle wsprintf(WindowTitle,"%d/%d", GetTickCount(), GetCurrentProcessId()); // change current window title SetConsoleTitle(WindowTitle); // ensure window title has been updated Sleep(40); // look for newWindowTitle hwndFound=FindWindow(NULL, WindowTitle); // If found, hide it if ( hwndFound != NULL) ShowWindow( hwndFound, SW_HIDE); } #endif } Would it not be more elegant to tell Windows that LyX is actually a GUI-based app by giving it a WinMain? The code below compiles fine for me with $ g++ -mwindows -o trial trial.C #if defined (_WIN32) # define WIN32_LEAN_AND_MEAN # include <stdlib.h> // for __argc, __argv # include <windows.h> // for WinMain #endif #if defined (_WIN32) int mymain(int argc, char * argv[]) #else int main(int argc, char * argv[]) #endif { // LyX's code, unchanged, goes here. Sleep(5000); return 0; } // This will require the "-mwindows" flag when linking with // gcc under MinGW. // For MSVC, use "/subsystem:windows". #if defined (_WIN32) int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { std::cout << "WinMain" << std::endl; return mymain(__argc, __argv); } #endif Regards, Angus