I dug this up and it took me two days to post here for some reason...
This is quite simple, you may have thought of it or done it in fact.
Basically, if you happen to make a program/applet/plugin and you want a part of it done in Blitz, Look No Further! I hope. It has to be a fully self-contained blitz app though; don't expect the other program to pass you variables and stuff. I may make a cross-program data sending dll in the next 30 years if there isn't one easily findable though to solve that... But that has nothing to do with this.
Now, what this does is the main program executes the blitz program, and passes it a single command line value, which is its own window handle (in the user32 dll).
Then the blitz program uses that command line value to pop itself inside of its new parent window (using win32 dll), thus creating a nice effect, useful for stuff. For instance, if you made a web plugin with c++, you could grab the window handle and actually have blitz doing all the plugin stuff. Useful for online game applications, vrml plugins, etc.
That is all in theory, but I feel that it should work unless Windows and web browsers are stupid.
So the BB part pretty much embeds itself, with only a tiny bit of help from the parent window's end. That help isn't even needed, if you use various other methods to find the parent's handle, which can be found.
Anyway, here's my code:
Main window:
Child window. Note: MUST be compiled as SelfEmbedder.exe to work in this example.
So there you are. Please help me test this to see if it actually does work, and give me any suggestions/ideas you have.
This is quite simple, you may have thought of it or done it in fact.
Basically, if you happen to make a program/applet/plugin and you want a part of it done in Blitz, Look No Further! I hope. It has to be a fully self-contained blitz app though; don't expect the other program to pass you variables and stuff. I may make a cross-program data sending dll in the next 30 years if there isn't one easily findable though to solve that... But that has nothing to do with this.
Now, what this does is the main program executes the blitz program, and passes it a single command line value, which is its own window handle (in the user32 dll).
Then the blitz program uses that command line value to pop itself inside of its new parent window (using win32 dll), thus creating a nice effect, useful for stuff. For instance, if you made a web plugin with c++, you could grab the window handle and actually have blitz doing all the plugin stuff. Useful for online game applications, vrml plugins, etc.
That is all in theory, but I feel that it should work unless Windows and web browsers are stupid.
So the BB part pretty much embeds itself, with only a tiny bit of help from the parent window's end. That help isn't even needed, if you use various other methods to find the parent's handle, which can be found.
Anyway, here's my code:
Main window:
MyAppTile$ = "Embedder_MainWindow" Include "Consts_Win32.bb" Graphics 800,600,0,2 AppTitle MyAppTile$ Global hWnd = SystemProperty("AppHWND") ;NOTE: Now covered by self-embedder ;style=GetWindowLong(hWnd ,GWL_STYLE) ;style = style Xor WS_CLIPCHILDREN ;SetWindowLong hwnd,GWL_STYLE,style ExecFile "SelfEmbedder.exe " + hWnd ; First parameter is the scancode to fake, the second is the window name ;InstallCloseHandler(222, MyAppTile$) ;Removed. Blitzclose.dll ;Using key 222 because that's the Power key. ;If someone were to press it, they would want the app gone anyway :) exfg = 0 While (Not KeyHit(1)) ;If KeyHit(222) Then exfg = 1 ;for clicking on [X] ;If exfg = 1 Then Exit Wend ;UnInstallCloseHandler() End
Child window. Note: MUST be compiled as SelfEmbedder.exe to work in this example.
MyAppTile$ = "Embedder_ChildWindow" Include "Consts_Win32.bb" Graphics3D 500,500,0,2 AppTitle MyAppTile$ SetBuffer BackBuffer() Global hWnd = SystemProperty("AppHWND") ;the blitz runtime window style=GetWindowLong(hWnd ,GWL_STYLE) style = style Xor WS_BORDER + WS_CAPTION ;style = style Xor WS_DISABLED SetWindowLong hwnd,GWL_STYLE,style Global Parent = CommandLine() ;handle of parent window passed to embedder via the command line style=GetWindowLong(Parent,GWL_STYLE) style = style Xor WS_CLIPCHILDREN SetWindowLong Parent,GWL_STYLE,style api_SetParent hWnd,Parent ;useless 3d test stuff AmbientLight 200,200,200 camera = CreateCamera() PositionEntity camera,-5,0,0 CameraClsColor camera,255,255,255 cube = CreateCube() PointEntity camera,cube ; First parameter is the scancode to fake, the second is the window name ;InstallCloseHandler(222, MyAppTile$) exfg = 0 While (Not KeyHit(1)) ;Exiting the app ;If KeyHit(222) Then exfg = 1 ;for clicking on [X] If Not api_IsWindow(Parent) Then exfg = 1 ;Program stuff MXsp# = -MouseXSpeed() MYsp# = MouseYSpeed() If MouseDown(1) Then TurnEntity camera,MYsp#,MXsp#,0 If KeyDown(17) Then MoveEntity camera,0,0,0.1 If KeyDown(31) Then MoveEntity camera,0,0,-0.1 If KeyDown(30) Then MoveEntity camera,-0.1,0,0 If KeyDown(32) Then MoveEntity camera,0.1,0,0 TurnEntity cube,1,2,3 RenderWorld ;end 3d stuff Flip ;Cls If exfg = 1 Then Exit Wend ;UnInstallCloseHandler() End
So there you are. Please help me test this to see if it actually does work, and give me any suggestions/ideas you have.