FWH Class TWebServer example

FWH Class TWebServer example

Postby Antonio Linares » 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: Select all  Expand view
#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:
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH Class TWebServer example

Postby Enrico Maria Giordano » Mon Oct 10, 2011 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FWH Class TWebServer example

Postby Antonio Linares » Mon Oct 10, 2011 9:32 am

Enrico,

This change is required in FWH Class TWebServer:
Code: Select all  Expand view
  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
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH Class TWebServer example

Postby Antonio Linares » Mon Oct 10, 2011 9: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=

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH Class TWebServer example

Postby Antonio Linares » Mon Oct 10, 2011 10:19 am

Executing an action:

Image

In default.htm change:
Code: Select all  Expand view
  <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: Select all  Expand view
#menu ul ul a
{
   text-decoration: none;
}


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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 115 guests