run another exe file in window of main programm?
Posted: Mon Jul 05, 2010 9:40 am
				
				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.
			http://www.purebasic.com
https://www.purebasic.fr/english/
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