adam wrote:
> I'm looking for a function similar to the wxExecute function. 
> http://www.wxwidgets.org/wiki/index.php/WxExecute  this allows you to do 
> command line stuff without using the command line.
> 
> I've tried using the popen example from Greg Ercolano, but its not working.

        What problem are you having?

        I just compiled it again on my Visual Studio 6 and it ran fine.
        In this case with 1.1.6:

C:\fltk-1.1.6\test>cl /I "." /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D 
"WIN32_LEAN_AND_MEAN" /D "VC_EXTRA_LEAN" /D "WIN32_EXTRA_LEAN" /EHsc /MD /TP /c 
foo.cxx
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.

foo.cxx

C:\fltk-1.1.6\test>link /OUT:foo.exe /INCREMENTAL:NO /NOLOGO /LIBPATH:"..\lib" 
/NODEFAULTLIB:"libcd" /SUBSYSTEM:CONSOLE /MACHINE:I386 glu32.lib opengl32.lib 
comctl32.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib 
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
odbc32.lib odbccp32.lib imm32.lib "..\lib\fltk.lib" "..\lib\fltkgl.lib" foo.obj

C:\fltk-1.1.6-new\test>foo

> I want to run the entire thing without seeing the console window at all,
> running the program in a box in my GUI. Most programming IDEs use this
> when compiling and stuff.

        If you have a /subsystem:windows app, you'd have to use
        a combo of CreatePipe() and CreateProcess() to avoid the
        DOS window, and threads to read the pipe, and shove the results
        into FLTK's widget.

        This is not for the meek; win32's API is really a PITA.
        CreateProcess() is pretty darn ugly, and threads can be
        tricky if not done correctly.

        For specifics on using CreatePipe() and CreateProcess() and threads
        in general, see my recent post on comp.os.ms-windows.programmer.win32:
        
http://groups.google.com/group/comp.os.ms-windows.programmer.win32/msg/0ee700332f211d71?dmode=source

        ..which shows a complete /WIN32/ example. No FLTK involved.
        But the techniques with CreateProcess() and CreatePipe() and
        threads would be the same.

        It's up to you to take that code and modify it so that the
        threads send data to the FLTK widget safely. Get as far as
        you can, and follow up here if you really hit a wall.
        Keep thread safety in mind.

> The Popen example mentioned earlier uses fgets to read the stream,
> however, that will only read parts of the stream. when i run the
> console programs using popen, i get SOME text in the GUI window,
> but some text is still sent to the console window.

        That's probably stderr text you're getting in the console window.
        popen() only reads stdout.

        If you want popen() to grab /both/ stdout /and/ stderr
        from the app, you'll need to invoke the app with 2>&1, eg:

popen("yourapp -arg1 -arg2 2>&1", "r");
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to