run another exe file in window of main programm?

Just starting out? Need help? Post your questions and find answers here.
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

run another exe file in window of main programm?

Post 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.
User avatar
Shardik
Addict
Addict
Posts: 2067
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

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

Post 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
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

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

Post by SeregaZ »

ouch... search request wrong...
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

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

Post 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?
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

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

Post by SeregaZ »

anybody?
Post Reply