April 28, 2024, 05:44:45 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Browser in a DLL

Started by aurelCB, July 28, 2013, 09:13:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

Hi..
Anyone have any example about how put browser window into dll?
thanks in advance ;)

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Hi Larry  :)
Thanks on reply, but nothing concrete,,,
maybe someone else have something ...

aurelCB

Anyone...
any idea how this can be done  ???

LarryMc

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!
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

I forgot the FreeLibrary API command to free the library before you close your program.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Wow... :)
Thank you very much Larry,yes toolwindow may be good option!
;)

aurelCB

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?

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library