if I use --app, the SetParent_() call results in an error.
As 'normal' browser window it works, simply set #InAppMode to #False
Any idea how to bring the app window inside of the container?
Code: Select all
EnableExplicit
#User_Data_Dir = "c:\tmp\msedge"
#InAppMode = #True
Procedure.i CreateUserDataDir(Dir$)
Protected Part$, i.i
If Right(Dir$, 1) <> #PS$
Dir$ + #PS$
EndIf
i = 1
Repeat
Part$ + StringField(Dir$, i, #PS$) + #PS$
;Debug Part$
If Right(Part$, 2) <> ":" + #PS$
If FileSize(Part$) <> -2
If CreateDirectory(Part$) = 0
Break
EndIf
EndIf
EndIf
i + 1
Until Part$ = Dir$
ProcedureReturn Bool(FileSize(Dir$) = -2)
EndProcedure
CreateUserDataDir(#User_Data_Dir)
Define.i hWnd, Prog, Event, Quit, TimeOut
Define Parameter$, WindowText$
OpenWindow(0, 0, 0, 1024, 768, "PureBasic Window", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
ContainerGadget(0, 0, 0, WindowWidth(0), WindowHeight(0))
SetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE) | #WS_EX_CONTROLPARENT)
Parameter$ = "--user-data-dir=" + #DQUOTE$ + #User_Data_Dir + #DQUOTE$ + " "
Parameter$ + "--window-position=" + #DQUOTE$ + "0,0" + #DQUOTE$ + " "
Parameter$ + "--window-size=" + #DQUOTE$ + Str(WindowWidth(0)) + "," + Str(WindowHeight(0)) + #DQUOTE$ + " "
CompilerIf #InAppMode = #True
Parameter$ + "--app=https://www.purebasic.fr/english/"
CompilerElse
Parameter$ + "--no-first-run "
Parameter$ + "https://www.purebasic.fr/english/"
CompilerEndIf
Debug Parameter$
Prog = RunProgram("msedge", Parameter$, "");, #PB_Program_Hide)
TimeOut = ElapsedMilliseconds()
Repeat
CompilerIf #InAppMode = #True
hWnd = FindWindowEx_(#Null, hWnd, #Null, "PureBasic Forums - English - Index page")
CompilerElse
hWnd = FindWindowEx_(#Null, hWnd, #Null, "PureBasic Forums - English - Index page - Profil 1 – Microsoft Edge")
CompilerEndIf
If hWnd
Debug hWnd
WindowText$ = Space(#MAX_PATH)
GetWindowText_(hWnd, @WindowText$, #MAX_PATH)
Debug WindowText$
Break
Else
Delay(100)
EndIf
Until ElapsedMilliseconds() - TimeOut > 10000
If SetParent_(hWnd, GadgetID(0)) = 0
Debug "SetParent() Error: " + Str(GetLastError_())
EndIf
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = #True
EndIf
Until Quit