FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH Class TWebServer example
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
FWH Class TWebServer example
Posted: Sun Oct 09, 2011 11:25 PM
In this example you can see how easily you can serve web pages from your own FWH app! :-)

webserv1.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd
   
   DEFINE WINDOW oWnd TITLE "FWH Class TWebServer example"

   ACTIVATE WINDOW oWnd ICONIZED ;
      ON INIT BuildServer()
   
return nil   

function BuildServer()

   local oWebServer := TWebServer():New()

   oWebServer:lDebug = .T.
   oWebServer:cLogFile = "weblog.txt"

   oWebServer:Activate()

   oWebServer:Explore()  // launches your internet navigator

return nil


When you run it, your internet navigator will be automatically shown:
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FWH Class TWebServer example
Posted: Mon Oct 10, 2011 08:29 AM

Wonderful! But... it doesn't work here. :-(

It only creates an iconized windows and then nothing else. I try to manually launch IE and go to locahost but it only opens two Microsoft pages containing some information about IIS.

What am I missing?

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH Class TWebServer example
Posted: Mon Oct 10, 2011 09:32 AM
Enrico,

This change is required in FWH Class TWebServer:
Code (fw): Select all Collapse
   METHOD Explore( cHtmlFile ) INLINE cHtmlFile := If( cHtmlFile == nil,;
             ::cDefPage, cHtmlFile ),;
             ShellExecute( 0, 'Open', "http://localhost/" + cHtmlFile )


I forgot to say it, sorry :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH Class TWebServer example
Posted: Mon Oct 10, 2011 09:42 AM
Serving a pulldown menu:

(EXE and full source code included):
http://code.google.com/p/fivewin-contributions/downloads/detail?name=webserv1.zop&can=2&q=

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH Class TWebServer example
Posted: Mon Oct 10, 2011 10:19 AM
Executing an action:



In default.htm change:
Code (fw): Select all Collapse
   <ul>
      <li>
         Edit
         <ul>
              <li>Cut</li>
              <a href="#" onclick="alert('Copy')"><li>Copy</li></a>
              <li>Paste</li>
         </ul>
      </li> 
   </ul>


In styles.css add:
Code (fw): Select all Collapse
#menu ul ul a
{
   text-decoration: none;
}


Next: Routing the event to our EXE... :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion