Kroeger Simon (ext) wrote:

>Hi all,
>
>i'm using ruby 1.8.2 (2004-12-25) [i386-mswin32] on win2000.
>
>When starting my GUI app with rubyw (because i don't like the empty
>window) there is another window poping up whenever i call popen. (or use
>backquotes to start another process)
>
>Using just ruby.exe all seems fine (except the initial nasty empty
>window)
>
>Someone knows a way around?
>
>cheers
>
>Simon
>
>
>
>  
>
Below was my attempt to say, here is how you should fix this issue. And 
then it didn't work. If I run it with ruby it works fine. When I run it 
with rubyw, it just goes away when I click run. Any ideas anyone? The 
system code and `` code is taken from the list a long time ago.

Steve Tuckner

---------------------------------------------
require "vr/vruby"
require "vr/vrcontrol"
require 'Win32API'

def system(command)
  Win32API.new("crtdll", "system", ['P'], 'L').Call(command)
end

def `(command)
  popen = Win32API.new("crtdll", "_popen", ['P','P'], 'L')
  pclose = Win32API.new("crtdll", "_pclose", ['L'], 'L')
  fread = Win32API.new("crtdll", "fread", ['P','L','L','L'], 'L')
  feof = Win32API.new("crtdll", "feof", ['L'], 'L')
  saved_stdout = $stdout.clone
  psBuffer = " " * 128
  rBuffer = ""
  f = popen.Call(command,"r")
  while feof.Call( f )==0
      l = fread.Call( psBuffer,1,128,f )
      rBuffer += psBuffer[0..l]
  end
  pclose.Call f
  $stdout.reopen(saved_stdout)
  rBuffer
end

class MyForm < VRForm

    def construct
        addControl VRButton, "run", "run", 0, 0, 150, 40
        move 0, 0, 160, 73
    end

    def run_clicked
        messageBox(`dir`)
    end
end

VRLocalScreen.showForm MyForm
VRLocalScreen.messageloop