View Full Version : Running/embedding portable programs?
Islander
11-11-2007, 04:07 PM
I am wondering if it is possible, or if anyone has played around with something like this yet, but I was wondering, now that there are quite a few portable versions of programs floating around, would it be possible to, for example, include a portable version of Firefox (http://portableapps.com/apps/internet/firefox_portable) for example to be the display browser within AMS?
You could then have it pre-loaded with what ever plug-ins are needed, ie.; Flash, and what ever else one might like. That way you dont have to wonder if the clients has what is needed, or the necessity for them to install additional plug-ins.
FoxLeader
11-11-2007, 05:20 PM
Hello,
I started working on this sometime ago with Firefox (and AMS 6). I'll try to remeber to upload it on monday, so you'll be able to have a look at it.
Regards,
FoxLeader
Derek
11-11-2007, 05:39 PM
There should be no reason why 'portable firefox' wouldn't work using File.Run
It works well enough in BartsPE, so it should be much the same in AMS, tho you wouldn't be able to embed in Browser object because AMS uses IE ActiveX for that.
FoxLeader
11-11-2007, 05:46 PM
That IS possible. I've done it. I'll upload tomorrow, since it's a relativly heavy file. (more than 20MB, so impossible to upload directly on those forums).
However, I have a problem: I need it to maximize within the AMS app, however on my 1680*1050 screen, there's like 10 or 20 px that can't maximizes. Here's my code to embed FireFox:
(as you probably undestood, FireFox is in "AutoPlay\\ffEngine", so you must unzip FF Portable in this folder.
On Show:
display = System.GetDisplayInfo();
Window.SetPos(Application.GetWndHandle(), 0, 0);
Window.SetSize(Application.GetWndHandle(), display.Width, display.Height-34);
--################################################## ################
File.Run("AutoPlay\\ffEngine\\FirefoxPortable.exe", "www.startforce.com", "AutoPlay\\ffEngine\\", SW_MINIMIZE, false);
blnEmbedded=false;
while (blnEmbedded==false) do
windows = Window.EnumerateTitles();
window_name = "WebOSBrowser";
-- Loop through the table of windows.
for handle, title in windows do
-- Check if the window title has the target text.
result = String.Find(title, window_name, 1, false);
-- if the string was found in the title, send the window a close message.
if (result ~= -1) then
blnEmbedded=true;
--Dialog.Message("","IN")
result = DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SetParent", handle..","..Application.GetWndHandle(), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
Window.SetSize(handle, display.Width+20, display.Height+165)
Window.SetPos(handle,-10,-52)
Page.Redraw()
Window.Show(handle)
end
end
end
Page.Redraw()
Web.SetSize("Navigator", display.Width, display.Height);
On Size:
curSize = Window.GetSize(Application.GetWndHandle());
Window.SetSize(handle, curSize.Width+40, curSize.Height+40)
Window.SetPos(handle,-10,-30)
Page.Redraw()
Window.Show(handle)
On Key:
if e_Key == 27 then
Application.Minimize()
end
On Mouse Move:
if e_X >= display.Width-50 and e_Y >= 0 then
Application.Minimize();
end
So that was the whole code.
Derek
11-11-2007, 06:56 PM
lol ... thats not embedded. You're doing precisely what i said - File.Run ;)
FoxLeader
11-11-2007, 07:15 PM
Well... yeah, but have you tried it? It runs inside the AMS app. Sure, that's not like a webobject but that's as near as possible.
Islander
11-12-2007, 03:17 AM
Hello FoxLeader & Derek,
Thanks for the replies, I didnt know if anyone else had thought about something like this or not.
@FoxLeader, if its not running as a webobject or embeded, do you see all of the control panels and menus? or is this opening outside of AMS?
Or is it loading it as a program, but showing it inside of an AMS window?
FoxLeader
11-12-2007, 03:42 PM
You can show them, or you can hide them. But the window is all there, it just depends how you configure it.
Anyway, you can try it here: http://www.box.net/shared/lq15vhveej
Note that it've only been tested on my Vista x64 with a 1680*1050 display, so if there's anything, just say and I'll take a look at it.
Another thing is that I've made it to be fullscreen, except the windows taskbar and the Firefox status bar. The purpose, as I've made it, is simply to be used as a "Web OS" client; it just opens the Web OS, but with a fast look at the code you should understand how to adapt it.
usernameCasper
11-18-2007, 01:16 PM
Yes, it is possible.
You have to invoke a dll for it or write one your own using the header/lib.
You need the 'SetParent' function in the user32.dll.
Code snippet:
local strDlg_1 = Dialog.Input("requested hwnd","requested hwnd child:","",MB_ICONQUESTION);
local strDlg_2 = Dialog.Input("requested hwnd","requested hwnd newParent:","",MB_ICONQUESTION);
DLL.CallFunction(_SystemFolder.."\\User32.dll", "SetParent",String.ToNumber(strDlg_1)..","..String.ToNumber(strDlg_2), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
Note: 'String.ToNumber()' is redundant.
The DLL would return an int 64 bit value, indicating the status, wheter
the call was succesful implementat or not. 0 for faillure, 1 for succes.
FYI, I didn't use a variable to store the result.
NOTE: There are different hwnd's in the builded executable when runned, on
a particular page. It's important you know the precious hwnd of the page
you want to embed the portable application. Otherwhise the embbeded app
will flicker or not be drawing well. That's why you need to get the child hwnd
of this page. When you got this, embed the app on this childhwnd, this wont
cause flickering/redrawing problems.
The flickering/drawing problems happens cause the form is redrawing itself
continue. That's why the embedded app suffer from this.
In detail: Pages are divided in classes, the page you want embed your app
does have multiple hwnd's, the form where the app will be embedded does
have multiple childwindows, where 2 hwnds are in the same class, where
only 1 can be used for the parentwindow.
Important: close the childhwnd before you close the parenthwnd, otherwise
child will crash and maybe memory allocations could be compromised.
I hope I informed you well, it's hard to explain this.
This should work.
Kind regards,
Casper
usernameCasper
11-18-2007, 01:39 PM
Now it makes me wonder why the page got 2 childwindows for the same class?
Could someone explain this little further ?
It looks like 1 is used to repaint/update the page, as the other is used to have
childwindows attach to this hwnd, maybe a ref to make it 1, where the WM message
is send when an event has occoured? E.g. timers/user interaction -> Call method/function RedrawWindow, this also improves page loading speed imo.
If so, than I would like to make that ref for considerating (just a suggestion).
Kind regards,
Casper
KARLOSTHG
11-19-2007, 09:55 AM
see this (is in spanish, and visual basic code)
http://www.elguille.info/colabora/2007/F_Manchado_Incrustar_Programa.htm
and this in english
http://msdn2.microsoft.com/en-us/library/ms633541.aspx
i found the first code searching about embedding objects
sorry for my english bye:yes
usernameCasper
11-19-2007, 11:03 AM
I've played today on my free day with the pinvoke (api call).
Enum the child of the Application.GetWndHandle() will give you imo the FormClass without RedrawClass (I called them so, cause the one is redrawing while the other is the parent for all objects with hwnd's).
I embedded my own console onto a page (ofc on the "FormClass").
It works great, although, the funniest thing is... The hwnd isn't visible anymore in a hwnd enum, but it's still accessible).
I founded out that there is no way to disable the console for being moved,
you can remove the menu, this is for the win32 console, thus not using
the system.windows.forms !! For the forms, it's easy to disable this, by
overriding window messages). So I needed a workaround.
I embedded my console into the webobject and repositioned my console
so user cant move it out of the parent window, this worked great).
Cause the menuitems are removed, there is no way this console can be closed without terminating it (unless its a system proc ofc).
Maybe a suggestion to make child-windows as well for AMS ?
It's very powerful, ofc this is also a workaround.
If someone needs an example, I'll be happy to post it (AMS 6).
Maybe the wrong section to post this, but maybe not when a workaround is provided :p
Have fun coding,
Casper
FoxLeader
11-21-2007, 07:03 PM
Ouch. I think those last things are too complicated for my understandings :rolleyes
If anybody has the time to make an exemple, I would be pleased to test and report bugs :D
Regards,
FoxLeader
Edit: So usernameCasper, I'd be pleased to see this :)
usernameCasper
11-22-2007, 04:35 AM
Hey FoxLeader,
I just posted it in the AMS 6 example section, I hope you will see it soon as
possible, cause it must be checked by IR before it will be visible to public.
I hope you find it usefull !
-Casper
FoxLeader
11-22-2007, 10:48 AM
Thanks! I'll take a look at this :)
Regards,
FoxLeader
usernameCasper
11-22-2007, 10:50 AM
Hey no problem :yes
You also can make them "Not-Moveable" when you put those applications
in a web-object, only thing is that they lose focus, and you have to use the
window.setorder method to override it :)
Good luck !
-Casper
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.