Announcement

Collapse
No announcement yet.

Powerbasic Web Browser ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Powerbasic Web Browser ?

    Has anyone coded a Web Browser-equivalent capable of locally opening and displaying an HTML file (with Forms), then saving the resulting Cookies somewhere on the computer?

  • #2
    Daniel,

    ? hmm, not really sure what you are after?

    but if you are simply trying to make a web page that uses a form to communicate with a cgi program on your server, then I suggest you search here for AJAX, there are many examples,

    if you want a web browser than is not web based, or one that is running on the client (your home based machine) then look for Jose Roca's web browser

    ?

    Comment


    • #3
      web browser that isn't

      Weirdly enough, I want a web browser that doesn't have to browse the web. I just want to display an input form written in HTML, and when an Execute button is pressed, have it make a cookie and store it somewhere on the computer.

      No internet connection, no server, no nuttin.

      Comment


      • #4
        There must be an "html" control somewhere to let you render HTML. Maybe there is some option to get the values in the form with one of these controls.

        For Cookies, there are cookie functions in WinInet..Dll; but IIRC those require an internet connection. But you shold be able to save your 'cookie file' in the cookie folder (ShGetFolderPath() using CSIDL_COOKIES) using 'regular' file access functions (OPEN, PUT$, etc).

        Not a complete answer I know, but at least it's a starting point.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          ?
          Didn't i mention this already to you?
          I forgot, see my website http://www.hellobasic.com/ at the bottom.

          (simple executable)

          It's a frame based app which catches events and let's you interact with the html.
          hellobasic

          Comment


          • #6
            Originally posted by Daniel Raymer View Post
            Weirdly enough, I want a web browser that doesn't have to browse the web. I just want to display an input form written in HTML, and when an Execute button is pressed, have it make a cookie and store it somewhere on the computer.

            No internet connection, no server, no nuttin.
            Perhaps you'd be better off describing what you want to accomplish. Cookies are pretty basic and there are probably a dozen better ideas that come to mind from your limited description.
            Software makes Hardware Happen

            Comment


            • #7
              Jose Roca has written many versions of "A Web Browser in a DDT dialog"

              a stripped down version is posted here; http://powerbasic.com/support/pbforu...ight=Jose+Roca

              it uses ATL.DLL which is provided w/ IE
              to render the html/javascript/whatever, you can use it to browse the web if on line or browser web pages stored on your local machine, you might have to play with the address a bit for local files, (can't remember exactly, try "file://localhost/C:/yourfile.html' or something?) also for cookies (ref your other thread) they should work? AFAIK, maybe reveiw w3schools.com

              Code:
              'from; http://powerbasic.com/support/pbforums/showthread.php?t=29853&highlight=Jose+Roca"]http://powerbasic.com/support/pbforums/showthread.php?t=29853&highlight=Jose+Roca
              'by Jose Roca
              'New version of the first example. I have made the dialog modeless to
              'be able to pass the keystrokes to the WebBrowser control for processing,
              'otherwise the main dialog will eat them and shortcuts like Ctrl-C
              'won't work.
              
                #DIM ALL
                #INCLUDE "win32api.inc"
              
                %WM_FORWARDMSG = &H37F ' (895)
              
                %ID_OCX     = 1001
                %IDC_URL    = 1010
                %IDC_BTNAVG = 1011
                %IDC_BTBACK = 1012
                %IDC_BTFRWD = 1013
                %IDC_LABEL1 = 1014
              
                GLOBAL hDlg AS DWORD
                GLOBAL hOcx AS DWORD
                GLOBAL oOcx AS DISPATCH
              
              
                DECLARE FUNCTION AtlAxWinInit LIB "ATL.DLL" ALIAS "AtlAxWinInit" () AS LONG
              ' *********************************************************************************************
                DECLARE FUNCTION AtlAxWinTerm () AS LONG
              ' *********************************************************************************************
                FUNCTION AtlAxWinTerm () AS LONG
                  UnregisterClass ("AtlAxWin", GetModuleHandle(BYVAL %NULL))
                END FUNCTION
              ' *********************************************************************************************
              ' **********************************************************************************************
                DECLARE FUNCTION AtlAxGetControl LIB "ATL.DLL" ALIAS "AtlAxGetControl" _
                   ( _
                   BYVAL hWnd AS DWORD, _   ' [in] A handle to the window that is hosting the control.
                   BYREF pp AS DWORD _      ' [out] The IUnknown of the control being hosted.
                ) AS DWORD
              ' *********************************************************************************************
              
              ' *********************************************************************************************
              ' Puts the address of an object in a variant and marks it as containing a dispatch variable
              ' *********************************************************************************************
                SUB AtlMakeDispatch ( _
                   BYVAL lpObj AS DWORD, _                        ' Address of the object instance
                   BYREF vObj AS VARIANT _                        ' Variant to contain this address
                   ) EXPORT
              
                   LOCAL lpvObj AS VARIANTAPI PTR                 ' Pointer to a VARIANTAPI structure
                   LET vObj = EMPTY                               ' Make sure is empty to avoid memory leaks
                   lpvObj = VARPTR(vObj)                          ' Get the VARIANT address
                   @lpvObj.vt = %VT_DISPATCH                      ' Mark it as containing a dispatch variable
                   @lpvObj.vd.pdispVal = lpObj                    ' Set the dispatch pointer address
              
                END SUB
              ' *********************************************************************************************
              
              ' *********************************************************************************************
              ' Main dialog callback
              ' *********************************************************************************************
                CALLBACK FUNCTION MainDlgProc()
              
                   LOCAL rc AS RECT
                   LOCAL r AS LONG
                   LOCAL x AS LONG
                   LOCAL y AS LONG
                   LOCAL xx AS LONG
                   LOCAL yy AS LONG
              
              
                   SELECT CASE CBMSG
              
                      CASE %WM_SIZE
                         GetClientRect CBHNDL, rc
                         x = rc.nLeft
                         y = rc.nTop
                         xx = rc.nRight - rc.nLeft
                         yy = rc.nBottom - rc.nTop - 32
                         MoveWindow hOcx, x, y, xx, yy, %TRUE
              
                      CASE %WM_DESTROY
                         PostQuitMessage 0
              
                      CASE %WM_COMMAND
                         SELECT CASE CBCTL
                            CASE %IDCANCEL
                               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                  DIALOG END CBHNDL, 0
                               END IF
                            CASE %IDC_BTNAVG
                               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                  LOCAL strUrl AS STRING, vVar AS VARIANT
                                  CONTROL GET TEXT CBHNDL, %IDC_URL TO strUrl
                                  vVar = strUrl
                                  OBJECT CALL oOcx.Navigate(vVar)
                               END IF
                            CASE %IDC_BTBACK
                               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                  OBJECT CALL oOcx.GoBack
                               END IF
                            CASE %IDC_BTFRWD
                               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                  OBJECT CALL oOcx.GoForward
                               END IF
                         END SELECT
              
                   END SELECT
              
                END FUNCTION
              ' *********************************************************************************************
              
              ' *********************************************************************************************
              ' Main
              ' *********************************************************************************************
                FUNCTION PBMAIN
              
                   LOCAL hInst AS DWORD
                   LOCAL hr AS DWORD
                   LOCAL OcxName AS ASCIIZ * 255
                   LOCAL pUnk AS DWORD
                   LOCAL vVar AS VARIANT
                   LOCAL uMsg AS tagMsg
                   LOCAL dwCookie AS DWORD
              
                   OcxName = "Shell.Explorer"
              
                   AtlAxWinInit   ' // Initializes ATL
              
                   DIALOG NEW 0, "A Web Browser in a DDT dialog",,, 528, 334, %WS_OVERLAPPEDWINDOW, 0 TO hDlg
                   CONTROL ADD "AtlAxWin", hDlg, %ID_OCX, OcxName, 0, 0, 0, 0, %WS_VISIBLE OR %WS_CHILD
                   CONTROL HANDLE hDlg, %ID_OCX TO hOcx
                   CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "URL", 226, 322, 16, 12
                   CONTROL ADD TEXTBOX, hDlg, %IDC_URL, "", 250, 320, 210, 14
                   CONTROL ADD BUTTON, hDlg, %IDC_BTNAVG, "&Navigate", 470, 320, 46, 14, %WS_TABSTOP OR %BS_DEFAULT
                   CONTROL ADD BUTTON, hDlg, %IDC_BTBACK, "&Back", 5, 320, 46, 14, %WS_TABSTOP
                   CONTROL ADD BUTTON, hDlg, %IDC_BTFRWD, "&Forward", 58, 320, 46, 14, %WS_TABSTOP
                   CONTROL SET TEXT hDlg, %IDC_URL, "http://www.java.com"
              
                   AtlAxGetControl(hOcx, pUnk)
                   AtlMakeDispatch(pUnk, vVar)
                   SET oOcx = vVar
              
                   SetFocus(hOcx)
                   DIALOG SHOW MODELESS hDlg, CALL MainDlgProc TO hr
              
                   WHILE GetMessage(uMsg, %NULL, 0, 0)
                      '// Pass keyboard messages to the ancestor
                      '// Returns 0 if the message was not processed, nonzero if it was
                      IF SendMessage(hOcx, %WM_FORWARDMSG, 0, VARPTR(uMsg)) = 0 THEN
                         IF IsDialogMessage(hDlg, uMsg) = %FALSE THEN
                            TranslateMessage uMsg
                            DispatchMessage uMsg
                         END IF
                      END IF
                   WEND
              
                   AtlAxWinTerm   ' // Uninitializes ATL
                   SET oOcx = NOTHING
              
                END FUNCTION
              ' *********************************************************************************************

              Comment


              • #8
                If you understand the concept i am talking about, you would not need cookies at all but can directly save and load from a native database or whatever.
                hellobasic

                Comment


                • #9
                  I agree w/ Edwin, cookies are older & less secure technology

                  Comment


                  • #10
                    Weirdly enough, I want a web browser that doesn't have to browse the web. I just want to display an input form written in HTML, and when an Execute button is pressed, have it make a cookie and store it somewhere on the computer.
                    Let me guess... you already have coded up the HTML files and would just as soon not ALSO code up some data-entry screens?

                    Or maybe, "I really like the 'web interface look' even though it's not on the web?"

                    Othewise what you describe does not make a whole lot of sense, at least to me it doesn't.

                    MCM
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Keep an open mind.
                      Such an app can bridge the gap for doing local things and communicate with a real webserver all in the same html style.
                      While the app may needs to accepted by a firewall for users the appearance can be the same for local as online use.
                      We had this intention, open a local database and exchange data with the website, for 90% you would see the website html's.
                      This is seriously handy for updating 'your application'.
                      It can become *totally* dynamic.
                      hellobasic

                      Comment


                      • #12
                        I was thinking that's what this app might be... "make it the same for local and remote users."

                        In that case, could one not simulate "CGI?"

                        If local, you could pump the data into the called 'cgi' program via it's STDIN same as a 'real' CGI program? Or just pass the HTML data or the name of a file containg same on the command line?

                        I'm not a 'CGI' guy, but seems to me you could set up your 'CGI' program to understand a command line like this.... . for that matter, you could use a separate program when local, but if you code carefully, you won't be duplicating code; either use an #INCLUDE file (if you only hold a PB/CC license), or make the "EXEs" responsible only for getting the "HTML Data" and put the functions which actually 'do something with it' in a Dynamic Link Library which is used by both EXEs.

                        ???
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Michael Got it Right

                          Michael said: Let me guess... you already have coded up the HTML files and would just as soon not ALSO code up some data-entry screens?

                          Bingo, sir! Even worse, I have about 2,000 lines of code that makes dozens of HTML Forms input screens to let users input data to my program. My Powerbasic program makes a new HTML file based on what the user is doing, and opens it by calling Internet Explorer (locally). When the user fills out the form and presses Execute, my program detects the new cookie and opens and decodes it for the inputs. Very cool, users love it, but it stopped working when I switched to XP. No cookies are being made, apparently.

                          My options are 1) Fix it (I've posted a question here and have hired a supposed expert to figure out why the HTML & Javascript no longer make a cookie); or 2) Find another way of displaying the HTML and capturing the user's information; or 3) throw it all away and code dozens of new input screens.

                          I'm hoping option 2 works out, so I'm not in danger of having it stop working again the next time Micro$oft changes Windows.

                          Thank you all for your interest and help - what do you think I should do, and how?

                          Comment


                          • #14
                            >In that case, could one not simulate "CGI?"

                            Why bother?

                            It can handle events already, setting up a (local) webserver is simply an alternative to this.
                            Just what one could prefer..

                            Imagne i click a web submit button and the ado datalink window pops up to setup a connection for a database.
                            (Just an example of course)
                            But the cgi may produce this same dialog but then result is already more difficult, you'll need a 'protocol' to handle the results.
                            And let's not forget the possible time-out's misery.

                            Frankly, you mis the point if one is trying to keep the local as web appearance the same.
                            Pages distributed with a tool like asp.net can be very interactive and dynamic.
                            For a 'web-billy' this easier to maintain than an ordinary windows app talking to some dumb webserver.
                            Last edited by Edwin Knoppert; 30 May 2008, 10:35 AM.
                            hellobasic

                            Comment


                            • #15
                              >Michael said: Let me guess...

                              The example i have shown uses static htmlfiles.
                              They are included as a resource.
                              MSIE handles loading files from the resource.
                              Though if you need dynamic pages, you may consider using a (local) webserver.
                              Point is that the cookies may not work?
                              Files need to be on disk.
                              It is possible to make html pages 100% dynamic by swapping contents of for example a div element.
                              It can hold anything.

                              This stuff is flexible enough imo.
                              hellobasic

                              Comment


                              • #16
                                Like I said, I'm not a "CGI guy"... but if I already had code to parse and 'do something' with the Raw HTML input (which I think comes in with all the tags and associated baggage), I'd sure find a way to us that code.

                                I'm thinking you could probably re-structure "something" to end up with a function like.....
                                Code:
                                FUNCTION ProcessHTMLPage (HTML AS STRING, other params) [EXPORT] as something
                                .. and two executables, one for local use ....
                                Code:
                                #COMPILE EXE  "local.exe"
                                
                                FUNCTION PBMAIN( ) 
                                
                                 DO 
                                     ShowBlankForm 
                                     Wait for user to send in completed form => HTMLText 
                                     CALL ProcessHTMLPage (HTMLText) 
                                 LOOP Until some_condition
                                
                                END FUNCTION
                                ... and a "true' CGI program for remote use
                                Code:
                                #COMPILE EXE "remote_gci.exe" 
                                
                                FUNCTION PBMAIN() AS LONG
                                
                                    HTMLPage = STDIN 
                                    CALL PRocessHtmlPage (HTMLPage) 
                                  
                                END FUNCTION
                                BOth programs would
                                Code:
                                 EITHER ...
                                #INCLUDE "PRocessHTMLPageFunction.bas" 
                                 ....OR ....
                                DECLARE FUNCTION PRocessHTMLPage .... LIB "ProcessHtmlPage.DLL" ....
                                Gotta be possible.
                                Last edited by Michael Mattias; 30 May 2008, 11:01 AM.
                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  Daniel,

                                  after looking at the code you posted in the Cafe`

                                  I would suggest that it wouldn't be too difficult to modernize your code as Edwin and others here are suggesting, but also if you still want to use cookies...

                                  how do you know that the cookies are not being set? in that code snippet where is a GetCookie() function?

                                  also maybe you have your cookies turned off ???
                                  also, if your code is accessing an external web site in any way, that is now considered cross-site scripting(XSS), and is not allowed with the new browsers, which could be the problem


                                  try this to see if cookies are being set;

                                  Code:
                                  <html>
                                  <head>
                                  <script type="text/javascript">
                                  
                                  
                                  
                                  function getCookie(c_name)
                                  {
                                  if (document.cookie.length>0)
                                    {
                                    c_start=document.cookie.indexOf(c_name + "=");
                                    if (c_start!=-1)
                                      { 
                                      c_start=c_start + c_name.length+1 ;
                                      c_end=document.cookie.indexOf(";",c_start);
                                      if (c_end==-1) c_end=document.cookie.length
                                      return unescape(document.cookie.substring(c_start,c_end));
                                  
                                      } 
                                    }
                                  
                                  return ""
                                  }
                                  
                                  function setCookie(c_name,value,expiredays)
                                  {
                                  var exdate=new Date();
                                  exdate.setDate(exdate.getDate()+expiredays);
                                  document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
                                  }
                                  
                                  function checkCookie()
                                  {
                                  username=getCookie('username');
                                  if (username!=null && username!="")
                                    {
                                  
                                  document.getElementById("display1").innerHTML="<b>Data retrieved from cookie</b>:<BR><font color='red'>"+username+"</font>"
                                    alert('Welcome again '+username+'!');
                                  
                                    }
                                    username=prompt('Please enter another name:',"");
                                    if (username!=null && username!="")
                                      {
                                      setCookie('username',username,365);
                                  document.getElementById("display1").innerHTML="<b>Data retrieved from cookie</b>:<BR><font color='red'>"+username+"</font>"
                                  
                                      }
                                  
                                  else 
                                    {
                                    username=prompt('Please enter your name:',"");
                                    if (username!=null && username!="")
                                      {
                                      setCookie('username',username,365);
                                  document.getElementById("display1").innerHTML="<b>Data retrieved from cookie</b>:<BR><font color='red'>"+username+"</font>"
                                  
                                      }
                                    }
                                  }
                                  
                                  
                                  </script>
                                  </head>
                                  <body onLoad="checkCookie()">
                                  <input type="button" value="Reload" onclick="checkCookie()">
                                  
                                  <br>
                                  <br>
                                  <br>
                                  <br>
                                  <br>
                                  
                                  <center><div id="display1">cookie</div>
                                  </center>
                                  </body>
                                  </html>

                                  Comment


                                  • #18
                                    Have you looked at Prism? This is a Mozilla browser reworked for local html applications. It might save you some time.

                                    http://labs.mozilla.com/2007/10/prism/

                                    If your running FireFox 3.0, you can install the Prism plug-in that will convert standard web pages to local web applications.

                                    https://addons.mozilla.org/en-US/firefox/addon/6665
                                    Last edited by John Spikowski; 31 May 2008, 01:29 AM.

                                    Comment

                                    Working...
                                    X