Author Topic: Web Browser  (Read 19443 times)

0 Members and 2 Guests are viewing this topic.


John

  • Hero Member
  • *****
  • Posts: 3643
Re: Web Browser
« Reply #16 on: April 22, 2013, 09:36:20 PM »
Charles,

Can I use this example with DLLC?

Since I'm already committed to IUP, is using their web browser control a better path for me to follow?

Either way the source is very well documented and worth the peek.

John
« Last Edit: April 22, 2013, 09:47:02 PM by JRS »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4283
    • Oxygen Basic
Re: Web Browser
« Reply #17 on: April 22, 2013, 09:47:22 PM »
Hi John, Hooking up a web browser object directly in COM is complex. So, if you are committed to IUP then let it do all the work for you.

John

  • Hero Member
  • *****
  • Posts: 3643
Re: Web Browser
« Reply #18 on: April 22, 2013, 09:58:11 PM »
I have to agree. Getting the IUP web control working in BaCon was a breeze. I don't see Windows being an obstacle.




Code: [Select]
' IupWebBrowser sample

PRAGMA OPTIONS -I/usr/include/iup
PRAGMA LDFLAGS iup iupweb
PRAGMA INCLUDE iup.h iupweb.h

PROTO IupOpen IupWebBrowserOpen IupSetAttribute IupSetAttributeHandle IupSetCallback IupShow IupMainLoop IupClose

DECLARE web TYPE Ihandle*
DECLARE txt TYPE Ihandle*
DECLARE dlg TYPE Ihandle*
DECLARE btLoad TYPE Ihandle*
DECLARE btReload TYPE Ihandle*
DECLARE btBack TYPE Ihandle*
DECLARE btForward TYPE Ihandle*
DECLARE btStop TYPE Ihandle*
DECLARE self TYPE Ihandle*
DECLARE url TYPE STRING

FUNCTION navigate_cb(Ihandle* self, STRING url)
  PRINT "NAVIGATE_CB: ", url
  self = NULL
  IF INSTR(url, "download") THEN
    RETURN IUP_IGNORE
  ELSE
    RETURN IUP_DEFAULT
  END IF
END FUNCTION

FUNCTION error_cb(Ihandle* self, STRING url)
  PRINT "ERROR_CB: ", url
  self = NULL
  RETURN IUP_DEFAULT
END FUNCTION

FUNCTION completed_cb(Ihandle* self, STRING url)
  PRINT "COMPLETED_CB: ", url
  self = NULL
  RETURN IUP_DEFAULT
END FUNCTION

FUNCTION newwindow_cb(Ihandle* self, STRING url)
  PRINT "NEWWINDOW_CB: ", url
  IupSetAttribute(self, "VALUE", url)
  RETURN IUP_DEFAULT
END FUNCTION

FUNCTION back_cb(Ihandle* self)
  web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  IupSetAttribute(web, "BACKFORWARD", "-1")
  RETURN IUP_DEFAULT
END FUNCTION

FUNCTION forward_cb(Ihandle* self)
  web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  IupSetAttribute(web, "BACKFORWARD", "1")
  RETURN IUP_DEFAULT
END FUNCTION

FUNCTION stop_cb(Ihandle* self)
  web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  IupSetAttribute(web, "STOP", NULL)
  RETURN IUP_DEFAULT
END FUNCTION

FUNCTION reload_cb(Ihandle* self)
  web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  IupSetAttribute(web, "RELOAD", NULL)
  ' TEST:
  ' PRINT "STATUS=", IupGetAttribute(web, "STATUS")
  RETURN IUP_DEFAULT
END FUNCTION

FUNCTION load_cb(Ihandle* self)
  txt  = (Ihandle*)IupGetAttribute(self, "MY_TEXT")
  web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"))
  ' TESTS:
  ' IupSetAttribute(txt, "VALUE", IupGetAttribute(web, "VALUE"))
  ' IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>, World!</body></html>")
  ' IupSetAttribute(web, "VALUE", "http://www.microsoft.com")
  RETURN IUP_DEFAULT
END FUNCTION

IupOpen(NULL, NULL)
IupWebBrowserOpen()             
' Creates an instance of the WebBrowser control
web = IupWebBrowser()
' Creates a dialog containing the control
dlg = IupDialog(IupVbox(IupHbox(btBack = IupButton("Back", NULL), \
                                btForward = IupButton("Forward", NULL), \
                                txt = IupText(""), \
                                btLoad = IupButton("Load", NULL), \
                                btReload = IupButton("Reload", NULL), \
                                btStop = IupButton("Stop", NULL), \
                                NULL), \
                                web, NULL))
IupSetAttribute(dlg, "TITLE", "IupWebBrowser")
IupSetAttribute(dlg, "MY_TEXT", (STRING)txt)
IupSetAttribute(dlg, "MY_WEB", (STRING)web)
IupSetAttribute(dlg, "RASTERSIZE", "800x600")
IupSetAttribute(dlg, "MARGIN", "10x10")
IupSetAttribute(dlg, "GAP", "10")
' IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>World!</body></html>")
' IupSetAttribute(txt, "VALUE", "My HTML")
' IupSetAttribute(txt, "VALUE", "file:///D:/tecgraf/iup/html/index.html")
IupSetAttribute(txt, "VALUE", "http://www.basic-converter.org/")
IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"))
IupSetAttributeHandle(dlg, "DEFAULTENTER", btLoad)
IupSetAttribute(txt, "EXPAND", "HORIZONTAL")
IupSetCallback(btLoad, "ACTION", (Icallback)load_cb)
IupSetCallback(btReload, "ACTION", (Icallback)reload_cb)
IupSetCallback(btBack, "ACTION", (Icallback)back_cb)
IupSetCallback(btForward, "ACTION", (Icallback)forward_cb)
IupSetCallback(btStop, "ACTION", (Icallback)stop_cb)
IupSetCallback(web, "NEWWINDOW_CB", (Icallback)newwindow_cb)
IupSetCallback(web, "NAVIGATE_CB", (Icallback)navigate_cb)
IupSetCallback(web, "ERROR_CB", (Icallback)error_cb)
IupSetCallback(web, "COMPLETED_CB", (Icallback)completed_cb)
IupShow(dlg)
IupMainLoop()
IupClose()

Frankolinox

  • Full Member
  • ***
  • Posts: 230
Re: Web Browser
« Reply #19 on: April 23, 2013, 12:49:55 AM »
Quote
I already look inro jose forum and see this examples...
so it looks that we need CWindow.inc for this browser example..
Looks complicating but maybe is not that much... 
 

@aurel: I am at work and have no example by hand, but it's not true that you need cWindow include files for running "webbrowser" example. I wrote my editor over one and a half year before jose adepted his great webbrowser onto "cWindow.inc" basis and I am using usual win api (sdk) features for it.

I will see what I can convert or show next days. how often you need only a little portion from powerbasic to oxygenbasic for runing and that's funny for me how that's working and running here fine ;)

servus, frank

Aurel

  • Guest
Re: Web Browser
« Reply #20 on: April 23, 2013, 03:02:28 AM »
Ok Frank...i will wait for your way from Power Basic..
And yes Charles have a right about using COM into app ,but many other languages have this
because are created with C++ and use static libs and com templates, but this is not case here...
i will see what i can with this small .dll and try to create browser.

Aurel

  • Guest
Re: Web Browser
« Reply #21 on: April 23, 2013, 03:17:21 AM »
Charles...
How i can translate this code to oxygen, i mean do i can translate this like functions

Code: [Select]
typedef long WINAPI EmbedBrowserObjectPtr(HWND);
typedef long WINAPI UnEmbedBrowserObjectPtr(HWND);
typedef long WINAPI DisplayHTMLPagePtr(HWND, LPCTSTR);
typedef long WINAPI DisplayHTMLStrPtr(HWND, LPCTSTR);

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4283
    • Oxygen Basic
Re: Web Browser
« Reply #22 on: April 23, 2013, 06:51:16 AM »
Possibly:

% WINAPI
typedef sys HWND
typedef char* LPCTSTR

typedef sys WINAPI EmbedBrowserObjectPtr(HWND);
typedef sys WINAPI UnEmbedBrowserObjectPtr(HWND);
typedef sys WINAPI DisplayHTMLPagePtr(HWND, LPCTSTR);
typedef sys WINAPI DisplayHTMLStrPtr(HWND, LPCTSTR);

Frankolinox

  • Full Member
  • ***
  • Posts: 230
Re: Web Browser
« Reply #23 on: April 25, 2013, 03:05:22 AM »
for aurel: Here's a little code portion for url using from powerbasic site what I have found on my hd. perhaps it can help you, but you have still to convert that for oxygen.

Code: [Select]
%IDC_STATUSBAR   = 1001
%IDC_REBAR       = 1002
%IDC_SCIED       = 1003
%IDC_TOOLBAR     = 1004
%IDC_EDITURL     = 1005
%IDC_GOBTN       = 1006

insert below wndproc... (callback) ..

'--------------- 1 -------------------------------- //
...
   LOCAL trbi          AS REBARINFO            ' specifies attributes(imagelist) of the rebar control
   LOCAL trbbi         AS REBARBANDINFO        ' specifies or receives the attributes of a rebar band
...

'--------------- 2 -------------------------------- //

CASE %WM_COMMAND
    ...
CASE %IDOK
               ' If we are in the URL edit control, load the web page
               hCtrl = GetDlgItem(GetDlgItem(hWnd, %IDC_REBAR), %IDC_EDITURL)
               IF GetFocus = hCtrl THEN
                  PostMessage hWnd, %WM_COMMAND, %IDC_GOBTN, MAK(DWORD, %BN_CLICKED, %IDC_GOBTN)
                  EXIT FUNCTION
               END IF

CASE %IDC_EDITURL
               SELECT CASE HI(WORD, wParam)
                  CASE %EN_SETFOCUS
                     ' Select all the text of the edit box
                     PostMessage lParam, %EM_SETSEL, 0, -1
                     EXIT FUNCTION
               END SELECT

'--------------- 3 -------------------------------- //

         ' Create the EditUrl edit control
         hCtrl = CreateWindowEx(%WS_EX_CLIENTEDGE, _                                 ' extended styles
                                    "Edit", _                                            ' class name
                                    "", _                                                ' caption
                                    %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                    %ES_LEFT OR %ES_AUTOHSCROLL, _                       ' class styles
                                    251, 4, _                                            ' left, top
                                    300, 21, _                                           ' width, height
                                    hWnd, %IDC_EDITURL, _                          ' handle of parent, control ID
                                    GetModuleHandle(""), BYVAL %NULL)                    ' handle of instance, creation parameters
         SendMessage hCtrl, %WM_SETFONT, hFont, %TRUE
         ' Add the band containing the EditUrl edit control to the rebar
         szItem           = "URL"
         trbbi.cbSize     = SIZEOF(trbbi)
         trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_TEXT OR %RBBIM_CHILD OR _
                            %RBBIM_CHILDSIZE OR %RBBIM_SIZE OR %RBBIM_ID OR _
                            %RBBIM_IDEALSIZE
         trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
         trbbi.lpText     = VARPTR(szItem)
         trbbi.hWndChild  = hCtrl
         trbbi.cxMinChild = 350
         trbbi.cyMinChild = 21
         trbbi.cx         = 350
         trbbi.wID        = %IDS_STRING1
         trbbi.cxIdeal    = 350
         SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)

         ' Create the GoBtn text button
         hCtrl = CreateWindowEx(%NULL, _                                             ' extended styles
                                    "Button", _                                          ' class name
                                    "Go_SCI", _                                              ' caption
                                    %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                    %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER OR _     ' class styles
                                    %BS_FLAT, _
                                    593, 2, _                                            ' left, top
                                    64, 24, _                                            ' width, height
                                    hWnd, %IDC_GOBTN, _                            ' handle of parent, control ID
                                    GetModuleHandle(""), BYVAL %NULL)                    ' handle of instance, creation parameters
         SendMessage hCtrl, %WM_SETFONT, hFont, %TRUE

         ' Add the band containing the GoBtn text button to the rebar
         trbbi.cbSize     = SIZEOF(trbbi)
         trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                            %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
         trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
         trbbi.hWndChild  = hCtrl
         trbbi.cxMinChild = 34
         trbbi.cyMinChild = 24
         trbbi.cx         = 34
         trbbi.wID        = %IDS_STRING2
         trbbi.cxIdeal    = 34
         SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)

best regards, frank

Aurel

  • Guest
Re: Web Browser
« Reply #24 on: April 25, 2013, 05:18:21 AM »
hi frank..
but this code only have
rebar control
edit control and
GoBuuton

there is no nothing like html control  ???

Frankolinox

  • Full Member
  • ***
  • Posts: 230
Re: Web Browser
« Reply #25 on: April 25, 2013, 09:02:25 AM »
sorry, have had wrong file to copy...

take that one:

Code: [Select]
'' commctrl.inc

%RB_INSERTBAND  = (%WM_USER +  1)

' // Size = 12 bytes
TYPE REBARINFO DWORD
   cbSize AS DWORD   ' UINT        cbSize
   fMask  AS DWORD   ' UINT        fMask
   himl   AS DWORD   ' HIMAGELIST  himl
END TYPE

TYPE REBARBANDINFOA
    cbSize     AS DWORD
    fMask      AS DWORD
    fStyle     AS DWORD
    clrFore    AS DWORD
    clrBack    AS DWORD
    lpText     AS ASCIIZ PTR
    cch        AS DWORD
    iImage     AS LONG
    hwndChild  AS DWORD
    cxMinChild AS DWORD
    cyMinChild AS DWORD
    cx         AS DWORD
    hbmBack    AS DWORD
    wID        AS DWORD
#IF (%WIN32_IE >= &H0400)
    cyChild    AS DWORD
    cyMaxChild AS DWORD
    cyIntegral AS DWORD
    cxIdeal    AS DWORD
    lParam     AS LONG
    cxHeader   AS DWORD
#ENDIF
#IF (%WIN32_WINNT >= &H0600)
    rcChevronLocation AS RECT  ' the rect is in client co-ord wrt hwndChild
    uChevronState     AS DWORD ' STATE_SYSTEM_*
#ENDIF
END TYPE

TYPE REBARBANDINFOW
    cbSize     AS DWORD
    fMask      AS DWORD
    fStyle     AS DWORD
    clrFore    AS DWORD
    clrBack    AS DWORD
    lpText     AS WSTRINGZ PTR
    cch        AS DWORD
    iImage     AS LONG
    hwndChild  AS DWORD
    cxMinChild AS DWORD
    cyMinChild AS DWORD
    cx         AS DWORD
    hbmBack    AS DWORD
    wID        AS DWORD
#IF (%WIN32_IE >= &H0400)
    cyChild    AS DWORD
    cyMaxChild AS DWORD
    cyIntegral AS DWORD
    cxIdeal    AS DWORD
    lParam     AS LONG
    cxHeader   AS DWORD
#ENDIF
#IF (%WIN32_WINNT >= &H0600)
    rcChevronLocation AS RECT  ' the rect is in client co-ord wrt hwndChild
    uChevronState     AS DWORD ' STATE_SYSTEM_*
#ENDIF
END TYPE


%IDC_STATUSBAR   = 1001
%IDC_REBAR       = 1002
%IDC_SCIED       = 1003
%IDC_TOOLBAR     = 1004
%IDC_EDITURL     = 1005
%IDC_GOBTN       = 1006

'--------------- 1 -------------------------------- //
...
   LOCAL trbi          AS REBARINFO            ' specifies attributes(imagelist) of the rebar control
   LOCAL trbbi         AS REBARBANDINFO        ' specifies or receives the attributes of a rebar band
...

'--------------- 2 -------------------------------- //

CASE %WM_COMMAND
    ...
CASE %IDOK
               ' If we are in the URL edit control, load the web page
               hCtrl = GetDlgItem(GetDlgItem(hWnd, %IDC_REBAR), %IDC_EDITURL)
               IF GetFocus = hCtrl THEN
                  PostMessage hWnd, %WM_COMMAND, %IDC_GOBTN, MAK(DWORD, %BN_CLICKED, %IDC_GOBTN)
                  EXIT FUNCTION
               END IF

CASE %IDC_EDITURL
               SELECT CASE HI(WORD, wParam)
                  CASE %EN_SETFOCUS
                     ' Select all the text of the edit box
                     PostMessage lParam, %EM_SETSEL, 0, -1
                     EXIT FUNCTION
               END SELECT

'--------------- 3 -------------------------------- //

         ' Create the EditUrl edit control
         hCtrl = CreateWindowEx(%WS_EX_CLIENTEDGE, _                                 ' extended styles
                                    "Edit", _                                            ' class name
                                    "", _                                                ' caption
                                    %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                    %ES_LEFT OR %ES_AUTOHSCROLL, _                       ' class styles
                                    251, 4, _                                            ' left, top
                                    300, 21, _                                           ' width, height
                                    hWnd, %IDC_EDITURL, _                          ' handle of parent, control ID
                                    GetModuleHandle(""), BYVAL %NULL)                    ' handle of instance, creation parameters
         SendMessage hCtrl, %WM_SETFONT, hFont, %TRUE
         'SetWindowText hCtrl, "http://www.oxygenbasic.org/forum"

         ' Add the band containing the EditUrl edit control to the rebar
         szItem           = "URL"
         trbbi.cbSize     = SIZEOF(trbbi)
         trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_TEXT OR %RBBIM_CHILD OR _
                            %RBBIM_CHILDSIZE OR %RBBIM_SIZE OR %RBBIM_ID OR _
                            %RBBIM_IDEALSIZE
         trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
         trbbi.lpText     = VARPTR(szItem)
         trbbi.hWndChild  = hCtrl
         trbbi.cxMinChild = 350
         trbbi.cyMinChild = 21
         trbbi.cx         = 350
         trbbi.wID        = %IDS_STRING1
         trbbi.cxIdeal    = 350
         SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)

         ' Create the GoBtn text button
         hCtrl = CreateWindowEx(%NULL, _                                             ' extended styles
                                    "Button", _                                          ' class name
                                    "Go_SCI", _                                              ' caption
                                    %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                    %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER OR _     ' class styles
                                    %BS_FLAT, _
                                    593, 2, _                                            ' left, top
                                    64, 24, _                                            ' width, height
                                    hWnd, %IDC_GOBTN, _                            ' handle of parent, control ID
                                    GetModuleHandle(""), BYVAL %NULL)                    ' handle of instance, creation parameters
         SendMessage hCtrl, %WM_SETFONT, hFont, %TRUE

         ' Add the band containing the GoBtn text button to the rebar
         trbbi.cbSize     = SIZEOF(trbbi)
         trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                            %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
         trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
         trbbi.hWndChild  = hCtrl
         trbbi.cxMinChild = 34
         trbbi.cyMinChild = 24
         trbbi.cx         = 34
         trbbi.wID        = %IDS_STRING2
         trbbi.cxIdeal    = 34
         SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)


...

FUNCTION MdiWindowProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
                        BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG

   LOCAL hr            AS LONG
   LOCAL nTab          AS LONG
   LOCAL rc            AS RECT
   LOCAL szText        AS ASCIIZ * 255
   LOCAL hWB           AS DWORD
   LOCAL pIWebBrowser2 AS IWebBrowser2
'   LOCAL pWBEvents     AS DWebBrowserEvents2Impl
   LOCAL dwCookie      AS DWORD

   SELECT CASE wMsg

      CASE %WM_CREATE
         GetClientRect hWnd, rc
         ' Increase the tab number and set the caption
         hWB = CreateWebBrowser(hWnd) 'creates new window with tabs
         ' Insert new tab
         nTab = SendMessage(ghTabMdi, %TCM_GETITEMCOUNT, 0, 0)
         szText = FORMAT$(nTab + 1, "000")
         SetWindowText(hWnd, szText)
         InsertTabMdiItem(ghTabMdi, nTab + 1, szText)
         ' Set it as the current selection on the tab control
         SendMessage(ghTabMdi, %TCM_SETCURSEL, nTab, 0)

      CASE %WM_SIZE
         MoveWindow GetDlgItem(hWnd, %IDC_EDIT), 0, 0, LOWRD(lParam), HIWRD(lParam), %TRUE
         MoveWindow GetDlgItem(hWnd, %IDC_SCIEDIT), 0, 0, LOWRD(lParam), HIWRD(lParam), %TRUE

      CASE %WM_SETFOCUS
         SetFocus GetActiveWbWindow

      CASE %WM_MDIACTIVATE
         ' Using handle, get associated tab via caption string
         ' Get the caption text of the window
         GetWindowText(lParam, szText, %MAX_PATH)
         ' Find the associated tab and activate it
         EnumMdiTitleToTab(szText)
         SetFocus GetActiveWbWindow

      CASE %WM_DESTROY
         ' Get the handle of the window that hosts the control
         hWB = GetDlgItem(hWnd, %IDC_EDIT)
         ' Disconnect events and remove property
            ' Remove Tab associated with this window
         GetWindowText(hWnd, szText, SIZEOF(szText))
         nTab = EnumMdiTitleToTabRemove(szText)

   END SELECT

   FUNCTION = DefMDIChildProc(hWnd, wMsg, wParam, lParam)

END FUNCTION

the rebar feature you don't need I think and the "commctrl.inc" should be important for you but I didn't know if that's allowed without legacy to copy or use it from jose's website or powerbasic incorporation, better to ask if you are using it or/and working with it ;)

best regards, frank

Aurel

  • Guest
Re: Web Browser
« Reply #26 on: April 25, 2013, 09:34:48 PM »
hWB = CreateWebBrowser(hWnd) 'creates new window with tabs

frank this part is important, and i probably part of comctrl.inc
for which i dont see why be limited to use if is part of JoseRoca headers
or maybe im wrong about JoseRoca headers... ::)

Frankolinox

  • Full Member
  • ***
  • Posts: 230
Re: Web Browser
« Reply #27 on: April 27, 2013, 12:50:46 AM »
Quote
hWB = CreateWebBrowser(hWnd) 'creates new window with tabs

look at the last part of this example aurel, you can see it's just a function (createwebbrowser), but you have to create an own class for it and in codeproc a new scintilla control, that's all ;) this code part comes from jose's first webbrowser example it didn't work at that time with cWindows.inc. I can only say thank him for that great work. I hope the code part below can help you.

Code: [Select]

%RB_INSERTBAND  = (%WM_USER +  1)

' // Size = 12 bytes
TYPE REBARINFO DWORD
   cbSize AS DWORD   ' UINT        cbSize
   fMask  AS DWORD   ' UINT        fMask
   himl   AS DWORD   ' HIMAGELIST  himl
END TYPE

TYPE REBARBANDINFOA
    cbSize     AS DWORD
    fMask      AS DWORD
    fStyle     AS DWORD
    clrFore    AS DWORD
    clrBack    AS DWORD
    lpText     AS ASCIIZ PTR
    cch        AS DWORD
    iImage     AS LONG
    hwndChild  AS DWORD
    cxMinChild AS DWORD
    cyMinChild AS DWORD
    cx         AS DWORD
    hbmBack    AS DWORD
    wID        AS DWORD
#IF (%WIN32_IE >= &H0400)
    cyChild    AS DWORD
    cyMaxChild AS DWORD
    cyIntegral AS DWORD
    cxIdeal    AS DWORD
    lParam     AS LONG
    cxHeader   AS DWORD
#ENDIF
#IF (%WIN32_WINNT >= &H0600)
    rcChevronLocation AS RECT  ' the rect is in client co-ord wrt hwndChild
    uChevronState     AS DWORD ' STATE_SYSTEM_*
#ENDIF
END TYPE

TYPE REBARBANDINFOW
    cbSize     AS DWORD
    fMask      AS DWORD
    fStyle     AS DWORD
    clrFore    AS DWORD
    clrBack    AS DWORD
    lpText     AS WSTRINGZ PTR
    cch        AS DWORD
    iImage     AS LONG
    hwndChild  AS DWORD
    cxMinChild AS DWORD
    cyMinChild AS DWORD
    cx         AS DWORD
    hbmBack    AS DWORD
    wID        AS DWORD
#IF (%WIN32_IE >= &H0400)
    cyChild    AS DWORD
    cyMaxChild AS DWORD
    cyIntegral AS DWORD
    cxIdeal    AS DWORD
    lParam     AS LONG
    cxHeader   AS DWORD
#ENDIF
#IF (%WIN32_WINNT >= &H0600)
    rcChevronLocation AS RECT  ' the rect is in client co-ord wrt hwndChild
    uChevronState     AS DWORD ' STATE_SYSTEM_*
#ENDIF
END TYPE


%IDC_STATUSBAR   = 1001
%IDC_REBAR       = 1002
%IDC_SCIED       = 1003
%IDC_TOOLBAR     = 1004
%IDC_EDITURL     = 1005
%IDC_GOBTN       = 1006

'--------------- 1 -------------------------------- //
...
   LOCAL trbi          AS REBARINFO            ' specifies attributes(imagelist) of the rebar control
   LOCAL trbbi         AS REBARBANDINFO        ' specifies or receives the attributes of a rebar band
...

'--------------- 2 -------------------------------- //

CASE %WM_COMMAND
    ...
CASE %IDOK
               ' If we are in the URL edit control, load the web page
               hCtrl = GetDlgItem(GetDlgItem(hWnd, %IDC_REBAR), %IDC_EDITURL)
               IF GetFocus = hCtrl THEN
                  PostMessage hWnd, %WM_COMMAND, %IDC_GOBTN, MAK(DWORD, %BN_CLICKED, %IDC_GOBTN)
                  EXIT FUNCTION
               END IF

CASE %IDC_EDITURL
               SELECT CASE HI(WORD, wParam)
                  CASE %EN_SETFOCUS
                     ' Select all the text of the edit box
                     PostMessage lParam, %EM_SETSEL, 0, -1
                     EXIT FUNCTION
               END SELECT

'--------------- 3 -------------------------------- //

         ' Create the EditUrl edit control
         hCtrl = CreateWindowEx(%WS_EX_CLIENTEDGE, _                                 ' extended styles
                                    "Edit", _                                            ' class name
                                    "", _                                                ' caption
                                    %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                    %ES_LEFT OR %ES_AUTOHSCROLL, _                       ' class styles
                                    251, 4, _                                            ' left, top
                                    300, 21, _                                           ' width, height
                                    hWnd, %IDC_EDITURL, _                          ' handle of parent, control ID
                                    GetModuleHandle(""), BYVAL %NULL)                    ' handle of instance, creation parameters
         SendMessage hCtrl, %WM_SETFONT, hFont, %TRUE
         'SetWindowText hCtrl, "http://www.oxygenbasic.org/forum"

         ' Add the band containing the EditUrl edit control to the rebar
         szItem           = "URL"
         trbbi.cbSize     = SIZEOF(trbbi)
         trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_TEXT OR %RBBIM_CHILD OR _
                            %RBBIM_CHILDSIZE OR %RBBIM_SIZE OR %RBBIM_ID OR _
                            %RBBIM_IDEALSIZE
         trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
         trbbi.lpText     = VARPTR(szItem)
         trbbi.hWndChild  = hCtrl
         trbbi.cxMinChild = 350
         trbbi.cyMinChild = 21
         trbbi.cx         = 350
         trbbi.wID        = %IDS_STRING1
         trbbi.cxIdeal    = 350
         SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)

         ' Create the GoBtn text button
         hCtrl = CreateWindowEx(%NULL, _                                             ' extended styles
                                    "Button", _                                          ' class name
                                    "Go_SCI", _                                              ' caption
                                    %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                    %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER OR _     ' class styles
                                    %BS_FLAT, _
                                    593, 2, _                                            ' left, top
                                    64, 24, _                                            ' width, height
                                    hWnd, %IDC_GOBTN, _                            ' handle of parent, control ID
                                    GetModuleHandle(""), BYVAL %NULL)                    ' handle of instance, creation parameters
         SendMessage hCtrl, %WM_SETFONT, hFont, %TRUE

         ' Add the band containing the GoBtn text button to the rebar
         trbbi.cbSize     = SIZEOF(trbbi)
         trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                            %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
         trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
         trbbi.hWndChild  = hCtrl
         trbbi.cxMinChild = 34
         trbbi.cyMinChild = 24
         trbbi.cx         = 34
         trbbi.wID        = %IDS_STRING2
         trbbi.cxIdeal    = 34
         SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)


...

FUNCTION MdiWindowProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
                        BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG

   LOCAL hr            AS LONG
   LOCAL nTab          AS LONG
   LOCAL rc            AS RECT
   LOCAL szText        AS ASCIIZ * 255
   LOCAL hWB           AS DWORD
   LOCAL pIWebBrowser2 AS IWebBrowser2
'   LOCAL pWBEvents     AS DWebBrowserEvents2Impl
   LOCAL dwCookie      AS DWORD

   SELECT CASE wMsg

      CASE %WM_CREATE
         GetClientRect hWnd, rc
         ' Increase the tab number and set the caption
         hWB = CreateWebBrowser(hWnd) 'creates new window with tabs
         ' Insert new tab
         nTab = SendMessage(ghTabMdi, %TCM_GETITEMCOUNT, 0, 0)
         szText = FORMAT$(nTab + 1, "000")
         SetWindowText(hWnd, szText)
         InsertTabMdiItem(ghTabMdi, nTab + 1, szText)
         ' Set it as the current selection on the tab control
         SendMessage(ghTabMdi, %TCM_SETCURSEL, nTab, 0)

      CASE %WM_SIZE
         MoveWindow GetDlgItem(hWnd, %IDC_EDIT), 0, 0, LOWRD(lParam), HIWRD(lParam), %TRUE
         MoveWindow GetDlgItem(hWnd, %IDC_SCIEDIT), 0, 0, LOWRD(lParam), HIWRD(lParam), %TRUE

      CASE %WM_SETFOCUS
         SetFocus GetActiveWbWindow

      CASE %WM_MDIACTIVATE
         ' Using handle, get associated tab via caption string
         ' Get the caption text of the window
         GetWindowText(lParam, szText, %MAX_PATH)
         ' Find the associated tab and activate it
         EnumMdiTitleToTab(szText)
         SetFocus GetActiveWbWindow

      CASE %WM_DESTROY
         ' Get the handle of the window that hosts the control
         hWB = GetDlgItem(hWnd, %IDC_EDIT)
         ' Disconnect events and remove property
            ' Remove Tab associated with this window
         GetWindowText(hWnd, szText, SIZEOF(szText))
         nTab = EnumMdiTitleToTabRemove(szText)

   END SELECT

   FUNCTION = DefMDIChildProc(hWnd, wMsg, wParam, lParam)

END FUNCTION


$PBSCITE = "PBSCITE32"
'------------------------------------- register the new class ------------------------ //

        ' Register Code Window Class
     szClassName       = "PBSCITE32"
     wcex.cbSize        = SIZEOF(wcex)
     wcex.style         = %CS_HREDRAW OR %CS_VREDRAW OR %CS_DBLCLKS
     wcex.lpfnWndProc   = CODEPTR(SciCodeProc)
     wcex.cbClsExtra    = 0
     wcex.cbWndExtra    = 4
     wcex.hInstance     = hInstance
     wcex.hIcon         = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)
     wcex.hCursor       = LoadCursor(%NULL, BYVAL %IDC_IBEAM)
     wcex.hbrBackground = %COLOR_WINDOW + 1
     wcex.lpszMenuName  = %NULL
     wcex.lpszClassName = VARPTR(szClassName)
     wcex.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)


'------------------------------------------------------------- //
FUNCTION CreateWebBrowser (BYVAL hParent AS DWORD) AS DWORD

   LOCAL hWndChild AS DWORD, caption AS ASCIIZ*260

   ' Create the WebBrowser control
   hWndChild = CreateWindowEx(%NULL, _                                             ' extended styles
                              $PBSCITE, _                                     ' class name
                              caption, _                                      ' caption
                              %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR _    ' window styles
                              %WS_TABSTOP, _
                              0, 0, _                                              ' left, top
                              0, 0, _                                              ' width, height
                              hParent, %IDC_EDIT, _ '%IDC_IEWB, _                                ' handle of parent, control ID
                              GetModuleHandle(""), BYVAL %NULL)                    ' handle of instance, creation parameters
   FUNCTION = hWndChild

END FUNCTION


'------------------------------------------------------------- //

'------- callback (SciCodeProc)
(usual like wndproc function for sdk win api)

...

     CASE %WM_CREATE
        GetClientRect hWnd, rc
        hEdit = CreateWindowEx(%WS_EX_CLIENTEDGE, "Scintilla", BYVAL %NULL, %WS_CHILD OR %WS_VISIBLE OR _
                               %ES_MULTILINE OR %WS_VSCROLL OR %WS_HSCROLL OR _
                               %ES_AUTOHSCROLL OR %ES_AUTOVSCROLL OR %ES_NOHIDESEL, _
                               0, 0, 0, 0, hWnd, %IDC_EDIT, hInst, BYVAL %NULL) '%IDC_SCIEDIT

        pSciData = SendMessage(hEdit, %SCI_GETDIRECTPOINTER, 0, 0)
        IF pSciData THEN Scintilla_SetOptions pSciData
...

'------------------------------------------------------------- //
' end



question: what purpose you will follow with this webbrowser ? ;)

best regards, frank

Aurel

  • Guest
Re: Web Browser
« Reply #28 on: April 27, 2013, 12:40:58 PM »
Frank..
I am wondering why is you code always confusing  to read for me..

Quote
question: what purpose you will follow with this webbrowser
simple...to create web broser example like i do in many other compilers ...
nothing ultra-special...
hmmm... ::)

John

  • Hero Member
  • *****
  • Posts: 3643
Re: Web Browser
« Reply #29 on: April 27, 2013, 01:23:57 PM »
Quote
question: what purpose you will follow with this webbrowser ?

I would embed a web browser control in a desktop application if I had a web application I wish to integrate with my desktop application and sandbox its navigation.