RunProgram / ShellExecute program

Just starting out? Need help? Post your questions and find answers here.
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

RunProgram / ShellExecute program

Post by Palpatine »

Hi,

I have created a menu system that should run external programs on the press of a button. But whether I use Runprogram or ShellExecute, the external program is launched but my PB programs' screen is closed, which results in an error because the menu system tries to continue drawing the menu graphics in the lus...

Also, when I give Runprogram the parameters to wait for the external program to return, the entire system hangs...

Cheers,
Ron
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

hi ron,

do you have the source? If you have it, or could post a source containing the problem, maybe we can solve the problem.

Welcome to the boards, anyway :)
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Code: Select all

If IsScreenActive() <> 0
  ;ClearScreen
  ;Draw
  ;FlipBuffers
EndIf
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

Thanks, I'm not at home right now, but will post it later on.

Cheers,
Ron

thefool wrote:hi ron,

do you have the source? If you have it, or could post a source containing the problem, maybe we can solve the problem.

Welcome to the boards, anyway :)
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

DarkDragon wrote:

Code: Select all

If IsScreenActive() <> 0
  ;ClearScreen
  ;Draw
  ;FlipBuffers
EndIf
Hi,

Thanks, but this just skips the drawing when the screen is not active right? How do I prevent the screen from closing and being inactive?

Cheers,
Ron
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

what about iconizing(minimizing) your menu-system before launching?
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

thefool wrote:what about iconizing(minimizing) your menu-system before launching?
Maybe for some applications, but I also want windowed apps to run on top of the menu screen. As example I would like to fade the menu screen a bit and launch the calulcator...

Cheers,
Ron
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

thefool wrote:hi ron,

do you have the source? If you have it, or could post a source containing the problem, maybe we can solve the problem.

Welcome to the boards, anyway :)
Hi,

Here's the part of the code where the external program is run from. In the top of the code, the screen is openened first using:

Code: Select all

OpenScreen(1024,768,16,"Menu Interface")             ; open a new screen
Code:

Code: Select all

internetmenu:
; load the background screen
submenu=LoadImage(2,"Menus\Internet\Background.png")  ; load the background image for the internet into the variable achtergrond

; now load the button images into the variables for the internet menu and set up the coordinates
menubutton(1,1)=LoadImage(#PB_Any,"Menus\Internet\browse.png")
menubuttonx(1,1)=201
menubuttony(1,1)=256
menubutton(1,2)=LoadImage(#PB_Any,"Menus\Internet\email.png")
menubuttonx(1,2)=229
menubuttony(1,2)=409
menubutton(1,3)=LoadImage(#PB_any,"Menus\Internet\Exit.png")
menubuttonx(1,3)=710
menubuttony(1,3)=580

; set the default button for the main menu
buttoncolumn=1
buttonrow=1
Repeat                             ; continue until einde is set to TRUE
  FlipBuffers()                                                 ; flip the buffers 
  StartDrawing(ScreenOutput())
  DrawImage(submenu,0,0)                                       ; draw the mainmenu
  ExamineMouse()
  x=MouseX()
  y=MouseY()
  muis$=Str(x)+" "+Str(x)
  Locate(1,1)
  DrawText(muis$)
  
  ; draw the current selected button
  DrawImage(UseImage(menubutton(buttoncolumn,buttonrow)),menubuttonx(buttoncolumn,buttonrow),menubuttony(buttoncolumn,buttonrow))

  If muis = #true                                               ; is the mouse pointer activated?
    DrawImage(UseImage(pointer),x,y)                        ; if yes then draw the mousepointer
  EndIf

;  FlipBuffers()
  StopDrawing()                                                 ; exit drawing mode

  ExamineKeyboard()                                             ; was a key pressed?

  If muis=#true                                                 ; is the mouse active?
    If MouseX()>menubuttonx(1,1) And MouseX()<(menubuttonx(1,1)+598) And MouseY()>menubuttony(1,1) And MouseY()<(menubuttony(1,1)+123)    ; mouse over 1st button?
      buttonrow=1                                               ; make button 1 the active button
      buttoncolumn=1
    Else
      If MouseX()>menubuttonx(1,2) And MouseX()<(menubuttonx(1,2)+596) And MouseY()>menubuttony(1,2) And MouseY()<(menubuttony(1,2)+121)  ; mouse over 2nd box?
        buttonrow=2
        buttoncolumn=1
      Else
        If MouseX()>menubuttonx(1,3) And MouseX()<(menubuttonx(1,3)+150) And MouseY()>menubuttony(1,3) And MouseY()<(menubuttony(1,3)+55)  ; mouse over 3rd box?
          buttonrow=3
          buttoncolumn=1
        EndIf
      EndIf
    EndIf
  EndIf
 

 
  If KeyboardPushed(#PB_Key_Right)                              ; RIGHT BUTTON pressed?
    If buttoncolumn=1                                           ; in the left column?
      buttoncolumn=1                                            ; then move one place to the right
    Else                                                        ; if not (so therefor in left column)
      buttoncolumn=1                                             ; move to the right
    EndIf
  Else
    If KeyboardPushed(#PB_Key_Left)                             ; LEFT BUTTON pressed?
      If buttoncolumn=1 
        buttoncolumn=1
      Else
        buttoncolumn=1
      EndIf
    Else     ; Now for the up and down keys
      If KeyboardPushed(#PB_Key_Up)     ; UP BUTTON pressed?
        If buttonrow=1    ; already in top row?
          buttonrow=1    
        Else
          buttonrow=buttonrow-1 ; deduct one from the buttonrow (move one place up)
        EndIf
      Else
        If KeyboardPushed(#PB_Key_Down)    ; DOWN BUTTON pressed?
          If buttonrow=3   ; already in bottom of screen?
            buttonrow=3
          Else
            buttonrow=buttonrow+1 ; add one row
          EndIf
        Else
          If KeyboardPushed(#PB_Key_Return) Or MouseButton(1)<>0     ; Button is choosen, in this case enter pressed
            If buttoncolumn=1   ; Button is in 1st column
              Select buttonrow
                Case 1     ; Browsing the internet choosen
                  ShellExecute_(0, "open", "http://www.purebasic.com", "", "", 0) 
                  ;RunProgram(browse$)
                Case 2     ; Go to the email program
                  RunProgram(email$)
                Case 3     ; third row
                  einde=#true
                EndSelect
            Else      ; Button is in 2nd column
            EndIf
          Else
             ; NEXT BUTTON QUERY HERE
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  If KeyboardPushed(#PB_Key_Escape)
    einde=#true
  EndIf
Until einde=#true
einde=#false
Delay(wachttijd)
Return
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

Palpatine,

The code you sent is not complete, so that it is difficult to appreciate the process you are doing.

But it seems that it is organized so that you may have an error when looping because the ScreenOutput() does no more exist after an event occurs.

Maybe if you send the whole code, we can help you further.

Did you test your app with Debugger enabled ? It should show you where it crashes.

By the way, the concept is quite good to draw hand made buttons etc in an openscreen.

Probably you could use sprites instead of images to draw windows contents.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

fweil wrote: But it seems that it is organized so that you may have an error when looping because the ScreenOutput() does no more exist after an event occurs.
This is exactly the case! The error message in the debug window show a null result when trying 'startdrawing'...

As for the code layout, thanks! ;-)

Cheers,
Ron
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

@fweil

Ok am back home but the code is like 1,000 lines (!)...

I know for sure now that the problem is that my program's screen is closed - the error occurs when flipbuffers() or startdrawing(screenoutput()) is started.

If you (or anyone) are willing to help, I can send you the source by email..

Cheers,
Ron
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

Post it by email to me
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

...,

Have a look @ the tricks'n tips section .... 8)
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

fweil wrote:...,

Have a look @ the tricks'n tips section .... 8)
Which example do you mean? RunProgramEx?

Best regards,
Ron
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

...,

I was meaning viewtopic.php?t=10820
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Post Reply