Page 1 of 1

run another exe file in window of main programm?

Posted: Mon Jul 05, 2010 9:40 am
by SeregaZ
it is passible? i mean launch some external exe file in window of my programm, like web site runing in webgadjet, or like virtual mashines do.

Re: run another exe file in window of main programm?

Posted: Mon Jul 05, 2010 10:40 am
by Shardik
Have you already taken a look into the example codes from srod and gnozal which embed
the calculator into their own window?
http://www.purebasic.fr/english/viewtop ... 74&start=4
http://www.purebasic.fr/english/viewtop ... 73&start=9

Re: run another exe file in window of main programm?

Posted: Tue Jul 06, 2010 2:30 pm
by SeregaZ
ouch... search request wrong...

Re: run another exe file in window of main programm?

Posted: Sun Feb 06, 2011 8:53 am
by SeregaZ
i use this code:

Code: Select all

#APPNAME1 = "Calculator" 

Define *Parent 
Global *Child 


Procedure MyWindowCallback(hWnd, uMsg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select uMsg
    Case #WM_PAINT
        RedrawWindow_(*Child, 0, 0, #RDW_INVALIDATE|#RDW_ERASE|#RDW_FRAME) 
  EndSelect
  ProcedureReturn Result
EndProcedure


*Child = FindWindow_(0, #APPNAME1) 
If Not *Child 
  RunProgram("calc.exe") : Delay(1000) 
  *Child = FindWindow_(0, #APPNAME1) 
  If Not *Child 
    MessageRequester("Error", #APPNAME1 + " must be running !") 
    End 
  EndIf 
EndIf 

*Parent = OpenWindow(0, 0, 0, 320, 240, "Master", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget) 

If *Parent 
  
  SetWindowColor(0, $AAAAAA) 
  
  CreateStatusBar(0, WindowID(0)) 
  
  SetParent_(*Child, WindowID(0)) 
  SetWindowPos_(*Child, 0, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_SHOWWINDOW) 
  SetWindowCallback(@MyWindowCallback())
  
  Repeat 
    
    Select WaitWindowEvent() 
        
      Case #PB_Event_CloseWindow 
        If IsWindow_(*Child) 
          SetParent_(*Child, 0) 
        EndIf 
        CloseWindow(0) 
        Break 
    EndSelect 
    
  ForEver 
  
EndIf 

End
and i have one small problem. when i open a few windows and switch between them by directly clicking on inside programm - my main window still not active and can be stay behind of another window.
Image

who can advice in this case?

Re: run another exe file in window of main programm?

Posted: Wed Feb 09, 2011 7:18 pm
by SeregaZ
anybody?