IonicWind Software

IWBasic => General Questions => Topic started by: aurelCB on July 28, 2013, 09:13:27 AM

Title: Browser in a DLL
Post by: aurelCB on July 28, 2013, 09:13:27 AM
Hi..
Anyone have any example about how put browser window into dll?
thanks in advance ;)
Title: Re: Browser in a DLL
Post by: LarryMc on July 28, 2013, 10:42:45 AM
back in 2005 in the old pyxia forums there was a post about running dialogs and windows from inside a dll.
dialogs appear to be easy to make happen.

Although a final solution for windows was not posted, things that were mentioned about having the WINDOW declaration in the main program; having to use @hitwindow inside the dll;  that the window handler needed to be in your main program; and it mentioned making sure the dll stayed loaded until your main program closes, especially with a browser.
Title: Re: Browser in a DLL
Post by: aurelCB on July 28, 2013, 05:40:30 PM
Hi Larry  :)
Thanks on reply, but nothing concrete,,,
maybe someone else have something ...
Title: Re: Browser in a DLL
Post by: aurelCB on July 30, 2013, 03:40:51 PM
Anyone...
any idea how this can be done  ???
Title: Re: Browser in a DLL
Post by: LarryMc on July 30, 2013, 08:35:08 PM
Okay, maybe the following will give you enough information to figure it out.
This is the main program; compile as windows exe
declare import,LoadLibraryA(f as pointer),int
declare import,GetProcAddress(hInst as int,name as string),uint

declare PluginOptionsTemplate()
declare InitPluginTemplate(win as window),uint
def win as window
def run,hInst,InitPlugin,PluginOptions as uint
run=1
openwindow win,0,0,640,480,@caption | @sysmenu,0,"Window",&WinProc
hInst=LoadLibraryA(getstartpath+"testdll.dll")
if(hInst)
InitPlugin=GetProcAddress(hInst,"InitPlugin")
if(InitPlugin)
  PluginOptions=!<InitPluginTemplate>InitPlugin(win)
  if (PluginOptions) then !<PluginOptionsTemplate>PluginOptions()
endif
endif
waituntil run=0
end
sub WinProc
select @class
  case @idclosewindow
   closewindow win : run=0
endselect
return
endsub


This is the dll. It opens a dialog and attaches a browser win to it.
Resizing doesn't work right.
you'll probably have to create a child window to the dialog and then attach the browser to it.

The reason it is a dialog is because if you open it as a window instead of a dialog its size will be limited to the size of the main program window.
Can't remember but you may be able to open it as a toolwindow and not have that problem.
Compile as dll
DECLARE import,InvalidateRect(hwnd:INT, lpRect:pointer, bErase:INT),INT
def myDialog as dialog
export InitPlugin
sub InitPlugin(win as window),uint
createdialog myDialog,0,0,600,400,0x80CB0080|@size,win,"Dialog",&DialogProc
return &PluginOptions
endsub
sub PluginOptions
domodal(myDialog)
return
endsub
sub DialogProc(),int
select @class
  case @idclosewindow
   closedialog myDialog,@idcancel
  case @idinitdialog
   centerwindow myDialog
IF ATTACHBROWSER(myDialog,"http://www.ionicwind.com") = -1
MESSAGEBOX myDialog, "Couldn't create browser control","Error"
END
ENDIF
case @IDSIZE
InvalidateRect(myDialog.hwnd, NULL, TRUE)
endselect
return 0
endsub


Hope this helps and good luck!
Title: Re: Browser in a DLL
Post by: LarryMc on July 30, 2013, 08:39:07 PM
I forgot the FreeLibrary API command to free the library before you close your program.
Title: Re: Browser in a DLL
Post by: aurelCB on July 30, 2013, 11:09:00 PM
Wow... :)
Thank you very much Larry,yes toolwindow may be good option!
;)
Title: Re: Browser in a DLL
Post by: aurelCB on July 31, 2013, 01:03:15 AM
It work fine as external window.
I was thinking something about how can be done...
create something like scintilla control in a dll form.
Of course first to try with something simple like ordinary edit control created in a dll.
As i see main problem is how properly return control hendler...do you agree with that?
Title: Re: Browser in a DLL
Post by: LarryMc on July 31, 2013, 07:14:50 AM
while I was looking into it the main thing was that the window/dialog in the dll has to be a child of your main program window.
If not, the handler of the 2nd one created won't work