home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SAMPLES / FWRES.PRG < prev    next >
Text File  |  1994-06-04  |  9KB  |  266 lines

  1. #include "FiveWin.ch"
  2.  
  3. static oWnd
  4. static oBmp
  5.  
  6. //----------------------------------------------------------------------------//
  7.  
  8. function Main()
  9.  
  10.    local oBrush, oBar
  11.  
  12.    SET RESOURCES TO "DIALOGS.DLL"
  13.  
  14.    SET 3DLOOK ON
  15.  
  16.    DEFINE BRUSH oBrush STYLE BRICKS
  17.  
  18.    DEFINE WINDOW oWnd FROM 1, 5 TO 20, 75 ;
  19.       TITLE "Using Dialogs from DLLs" ;
  20.       BRUSH oBrush ;
  21.       MENU  BuildMenu()
  22.  
  23.    DEFINE BUTTONBAR oBar OF oWnd
  24.  
  25.    DEFINE BUTTON FILE "..\bitmaps\Select.bmp" OF oBar ACTION TestSelect() ;
  26.       MESSAGE "Testing a sample selection dialog"
  27.  
  28.    DEFINE BUTTON FILE "..\bitmaps\Edit.bmp"   OF oBar ;
  29.       ACTION ( TestClient(), oBmp:SetFore() ) ;
  30.       MESSAGE "Testing a typical bussiness dialog"
  31.  
  32.    DEFINE BUTTON FILE "..\bitmaps\Exit.bmp"   OF oBar ;
  33.       ACTION Exit() MESSAGE "When you want to end"    // UDF
  34.  
  35.    DEFINE BUTTON FILE "..\bitmaps\Colors.bmp" OF oBar ACTION ChooseColor() GROUP ;
  36.       MESSAGE "Calling Windows standard color selection dialog"
  37.  
  38.    DEFINE BUTTON FILE "..\bitmaps\Dlg.bmp"    OF oBar ;
  39.       ACTION cGetFile( "*.dbf", "Select a DBF" ) ;
  40.       MESSAGE "Calling Windows standard Get a File dialog"
  41.  
  42.    DEFINE BUTTON FILE "..\bitmaps\Fonts.bmp"  OF oBar ACTION ChooseFont() ;
  43.       MESSAGE "Calling Windows standard font selection dialog"
  44.  
  45.    DEFINE BUTTON FILE "..\bitmaps\Blocks.bmp" OF oBar ACTION About() GROUP ;
  46.       MESSAGE "About FiveWin designers"
  47.  
  48.    DEFINE BUTTON FILE "..\bitmaps\Printer.bmp" OF oBar ;
  49.       ACTION WinHelp( "Order.hlp" ) MESSAGE "Please read this info"
  50.  
  51.    @ 6, 18 BITMAP oBmp FILENAME "..\bitmaps\Luck.bmp" OF oWnd
  52.  
  53.    SET MESSAGE OF oWnd ;
  54.       TO "FiveWin - Storing Dialogs inside DLLs - pure Data-Driven power!"
  55.  
  56.    ACTIVATE WINDOW oWnd MAXIMIZED
  57.  
  58.    SET RESOURCES TO
  59.  
  60. return nil
  61.  
  62. //----------------------------------------------------------------------------//
  63.  
  64. function BuildMenu()
  65.  
  66.    local oMenu
  67.  
  68.    MENU oMenu
  69.       MENUITEM "Some &Dialogs"
  70.       MENU
  71.          MENUITEM "Make a selection..." ;
  72.             MESSAGE "It's time to start building Windows applications easily!" ;
  73.             ACTION TestSelect()
  74.  
  75.          MENUITEM "Now you have a real chance..." ;
  76.             MESSAGE "Quick and easy Windows applications using your Clipper!!!" ;
  77.             ACTION ( TestClient(), oBmp:SetFore() )
  78.  
  79.          SEPARATOR
  80.  
  81.          MENUITEM "End..." MESSAGE "Exit this demo" ACTION Exit()     // UDF
  82.       ENDMENU
  83.  
  84.       MENUITEM "Some &Standards..."
  85.       MENU
  86.          MENUITEM "Choose A &Color..." ;
  87.             MESSAGE "Calling standard Windows dialogs" ACTION ChooseColor()
  88.  
  89.          MENUITEM "Getting a &file..." ;
  90.             MESSAGE "Hey, see how easy this is" ;
  91.             ACTION cGetFile( "*.dbf", "Select a DBF" )
  92.  
  93.          MENUITEM "Selecting a f&ont..." ;
  94.             MESSAGE "Any Windows facility is ready for you" ;
  95.             ACTION ChooseFont()
  96.       ENDMENU
  97.  
  98.       MENUITEM "About..." ;
  99.          MESSAGE "Come on... we would like to see your name here soon!" ;
  100.          ACTION About()
  101.  
  102.    ENDMENU
  103.  
  104. return oMenu
  105.  
  106. //----------------------------------------------------------------------------//
  107.  
  108. function TestSelect()
  109.  
  110.    local oDlg
  111.    local cItem  := "Using a Dialog"
  112.    local aItems := { "Using a Dialog",;
  113.                      "stored inside a DLL",;
  114.                      "is extremely easy!", "",;
  115.                      "You can start using",;
  116.                      "Borland's Resource WorkShop",;
  117.                      "to 'draw' your screens!", "",;
  118.                      "Welcome to the power of",;
  119.                      "Clipper, Windows, xBase and OOPS!", "",;
  120.                      "As we promised you:",;
  121.                      "You don't have to know a word",;
  122.                      "of Windows to build",;
  123.                      "incredible Windows applications...",;
  124.                      "You are an xBase Programmer!!!" }
  125.  
  126.  
  127.    DEFINE DIALOG oDlg RESOURCE "Select" COLOR "W+/R"
  128.  
  129.    REDEFINE SAY ID 10 OF oDlg
  130.  
  131.    REDEFINE LISTBOX cItem ITEMS aItems ID 110 OF oDlg
  132.  
  133.    REDEFINE BUTTON ID 120 OF oDlg ;
  134.       ACTION ( MsgInfo( "You selected..." + cItem ) )
  135.  
  136.    REDEFINE BUTTON ID 130 OF oDlg ;
  137.       ACTION ( MsgStop( "Welcome to FiveWin POWER!!!" ),;
  138.                If( MsgYesNo( "End this Dialog ?", "Select" ), oDlg:End(),) )
  139.  
  140.    REDEFINE BUTTON ID 140 OF oDlg ;
  141.       ACTION ( MsgInfo( "You can execute any action from here...", "Info" ),;
  142.                oDlg:Circle( 78, 260, 50 ) )
  143.  
  144.    ACTIVATE DIALOG oDlg CENTERED NOWAIT
  145.  
  146. return nil
  147.  
  148. //----------------------------------------------------------------------------//
  149.  
  150. function TestClient()
  151.  
  152.    local oDlg,  oRecNo,  oPhoto
  153.    local oName, oAdress, oCountry, oActive, oNotes
  154.    local cPhoto, cName, cAdress, cCountry, cNotes
  155.    local aCountries := { "SPAIN", "USA", "CANADA", "GERMANY", "JAPAN", "..." }
  156.    local lActive
  157.  
  158.    USE Clients
  159.  
  160.    cName    := Clients->Name
  161.    cAdress  := Clients->Adress
  162.    cCountry := Clients->Country
  163.    lActive  := Clients->Active
  164.    cNotes   := StrTran( Clients->Notes, Chr( 141 ) + Chr( 10 ), "" )
  165.    cPhoto   := Clients->Photo
  166.  
  167.    DEFINE DIALOG oDlg RESOURCE "Client"
  168.  
  169.    REDEFINE SAY ID 10 OF oDlg                  // Just to make them 3D look
  170.    REDEFINE SAY ID 20 OF oDlg
  171.    REDEFINE SAY ID 30 OF oDlg
  172.    REDEFINE SAY ID 40 OF oDlg
  173.    REDEFINE SAY ID 50 OF oDlg
  174.    REDEFINE SAY oRecNo PROMPT Str( RecNo(), 5 ) ;  // Here we trap a reference
  175.       ID 60 OF oDlg                                // to the SAY Object
  176.  
  177.    REDEFINE GET oName   VAR cName   ID 110 OF oDlg ;
  178.       COLOR "GR+/RB"
  179.  
  180.    REDEFINE GET oAdress VAR cAdress ID 120 OF oDlg
  181.  
  182.    REDEFINE COMBOBOX oCountry VAR cCountry ITEMS aCountries ;
  183.       ID 130 OF oDlg COLOR "W+/R*"
  184.  
  185.    REDEFINE CHECKBOX oActive  VAR lActive ID 140 OF oDlg
  186.  
  187.    REDEFINE GET oNotes VAR cNotes MEMO ID 150 OF oDlg ;
  188.       COLOR "W+/B"
  189.  
  190.    REDEFINE GROUP  ID 160 OF oDlg
  191.    REDEFINE BITMAP oPhoto FILENAME cPhoto ID 230 OF oDlg
  192.  
  193.    REDEFINE SCROLLBAR ID 220 OF oDlg RANGE 1, RecCount() ;
  194.       COLOR "R+/B" ;
  195.       ON DOWN ( DbSkip(),;
  196.                 If( EoF(), DbGoBottom(),),;
  197.                 oPhoto:LoadBMP( Clients->Photo ),;
  198.                 cName    := Clients->Name,    oName:Refresh(),;
  199.                 cAdress  := Clients->Adress,  oAdress:Refresh(),;
  200.                 cCountry := Clients->Country, oCountry:Refresh(),;
  201.                 lActive  := Clients->Active,  oActive:Refresh(),;
  202.                 cNotes   := StrTran( Clients->Notes, Chr( 141 ) + Chr( 10 ), "" ),;
  203.                             oNotes:Refresh(),;
  204.                 oRecNo:SetText( Str( RecNo(), 5 ) ) ) ;
  205.       ON UP   ( DbSkip( -1 ),;
  206.                 oPhoto:LoadBMP( Clients->Photo ),;
  207.                 cName    := Clients->Name,    oName:Refresh(),;
  208.                 cAdress  := Clients->Adress,  oAdress:Refresh(),;
  209.                 cCountry := Clients->Country, oCountry:Refresh(),;
  210.                 lActive  := Clients->Active,  oActive:Refresh(),;
  211.                 cNotes   := StrTran( Clients->Notes, Chr( 141 ) + Chr( 10 ), "" ),;
  212.                            oNotes:Refresh(),;
  213.                 oRecNo:SetText( Str( RecNo(), 5 ) ) )
  214.  
  215.    REDEFINE BUTTON ID 170 OF oDlg ACTION MsgStop( "Only available in commercial version" )
  216.    REDEFINE BUTTON ID 180 OF oDlg ACTION MsgStop( "Only available in commercial version" )
  217.    REDEFINE BUTTON ID 190 OF oDlg ACTION MsgStop( "Only available in commercial version" )
  218.    REDEFINE BUTTON ID 200 OF oDlg ACTION MsgStop( "Only available in commercial version" )
  219.    REDEFINE BUTTON ID 210 OF oDlg ACTION MsgStop( "Only available in commercial version" )
  220.  
  221.    REDEFINE BUTTON ID 240 OF oDlg ACTION oDlg:End()
  222.  
  223.    ACTIVATE DIALOG oDlg CENTERED
  224.  
  225.    USE
  226.  
  227. return nil
  228.  
  229. //----------------------------------------------------------------------------//
  230.  
  231. function About()
  232.  
  233.    local oDlg
  234.    local cAuthors := OemToAnsi( "(c) Antonio Linares && Francisco Pulpón" )
  235.  
  236.    DEFINE DIALOG oDlg RESOURCE "About"
  237.  
  238.    REDEFINE SAY ID 10 OF oDlg          // Just to make them 3D Look
  239.    REDEFINE SAY ID 20 OF oDlg
  240.    REDEFINE SAY ID 30 OF oDlg
  241.  
  242.    ACTIVATE DIALOG oDlg CENTERED
  243.  
  244. return nil
  245.  
  246. //----------------------------------------------------------------------------//
  247.  
  248. function Exit()
  249.  
  250.    local oDlg
  251.  
  252.    DEFINE DIALOG oDlg RESOURCE "Exit"
  253.  
  254.    REDEFINE SAY ID 10 OF oDlg
  255.    REDEFINE BITMAP ID 110 OF oDlg RESOURCE "Question"
  256.  
  257.    ACTIVATE DIALOG oDlg CENTERED
  258.  
  259.    if oDlg:nResult == 1                     // IDOK
  260.       oWnd:End()
  261.    endif
  262.  
  263. return nil
  264.  
  265. //----------------------------------------------------------------------------//
  266.