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

  1. #include "FiveWin.ch"
  2.  
  3. static oWnd, oBmp
  4.  
  5. //----------------------------------------------------------------------------//
  6.  
  7. function Main()
  8.  
  9.    local oBrush, oBar
  10.  
  11.    SET RESOURCES TO "BORDLGS.DLL", "BWCC.DLL"
  12.  
  13.    SET 3DLOOK ON
  14.  
  15.    DEFINE BRUSH oBrush STYLE BORLAND
  16.  
  17.    DEFINE WINDOW oWnd FROM 1, 5 TO 20, 75 ;
  18.       TITLE "Using Dialogs from DLLs and Borland's Dialog Boxes!" ;
  19.       BRUSH oBrush ;
  20.       MENU  BuildMenu()
  21.  
  22.    DEFINE BUTTONBAR oBar OF oWnd
  23.  
  24.    DEFINE BUTTON FILE "..\bitmaps\Select.bmp" OF oBar ACTION TestSelect() ;
  25.       MESSAGE "Testing a sample selection dialog"
  26.  
  27.    DEFINE BUTTON FILE "..\bitmaps\Edit.bmp"   OF oBar ;
  28.       ACTION ( TestClient(), oBmp:SetFore() ) ;
  29.       MESSAGE "Testing a typical bussiness dialog"
  30.  
  31.    DEFINE BUTTON FILE "..\bitmaps\Browse.bmp"   OF oBar ;
  32.       ACTION TestBrowse() MESSAGE "Easy and powerfull Browsers"
  33.  
  34.    DEFINE BUTTON FILE "..\bitmaps\Exit.bmp"   OF oBar ;
  35.       ACTION Exit() MESSAGE "When you want to end"    // UDF
  36.  
  37.    DEFINE BUTTON FILE "..\bitmaps\Colors.bmp" OF oBar ACTION ChooseColor() GROUP ;
  38.       MESSAGE "Calling Windows standard color selection dialog"
  39.  
  40.    DEFINE BUTTON FILE "..\bitmaps\Dlg.bmp"    OF oBar ;
  41.       ACTION cGetFile( "*.dbf", "Select a DBF" ) ;
  42.       MESSAGE "Calling Windows standard Get a File dialog"
  43.  
  44.    DEFINE BUTTON FILE "..\bitmaps\Fonts.bmp"  OF oBar ACTION ChooseFont() ;
  45.       MESSAGE "Calling Windows standard font selection dialog"
  46.  
  47.    DEFINE BUTTON FILE "..\bitmaps\Blocks.bmp" OF oBar ACTION About() GROUP ;
  48.       MESSAGE "About FiveWin designers"
  49.  
  50.    DEFINE BUTTON FILE "..\bitmaps\Printer.bmp" OF oBar ;
  51.       ACTION WinHelp( "Order.hlp" ) MESSAGE "Please read this info"
  52.  
  53.    @ 6, 18 BITMAP oBmp FILENAME "..\bitmaps\Luck.bmp" OF oWnd
  54.  
  55.    SET MESSAGE OF oWnd ;
  56.       TO "FiveWin - Storing Dialogs inside DLLs - pure Data-Driven power!"
  57.  
  58.    ACTIVATE WINDOW oWnd MAXIMIZED
  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, oBtnOk
  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.    // Not necessary now
  130.    // REDEFINE SAY ID 10 OF oDlg
  131.  
  132.    REDEFINE LISTBOX cItem ITEMS aItems ID 110 OF oDlg
  133.  
  134.    REDEFINE BUTTON oBtnOk ID 1 OF oDlg ;
  135.       ACTION MsgInfo( "You selected..." + cItem )
  136.  
  137.    REDEFINE BUTTON ID 2 OF oDlg ACTION oDlg:End()
  138.  
  139.    REDEFINE BUTTON ID 140 OF oDlg ;
  140.       ACTION ( MsgInfo( "You can execute any action from here...", "Info" ),;
  141.                oDlg:Circle( 100, 260, 30 ) )
  142.  
  143.    ACTIVATE DIALOG oDlg CENTERED // NOWAIT
  144.  
  145. return nil
  146.  
  147. //----------------------------------------------------------------------------//
  148.  
  149. function TestClient()
  150.  
  151.    local oDlg,  oRecNo,  oPhoto, oExit
  152.    local oName, oAdress, oCountry, oActive, oNotes
  153.    local cName, cAdress, cCountry, cNotes, cPhoto
  154.    local aCountries := { "SPAIN", "USA", "CANADA", "GERMANY", "JAPAN", "..." }
  155.    local lActive
  156.  
  157.    USE Clients SHARED     // Testing Windows for WorkGroups
  158.  
  159.    cName    := Clients->Name
  160.    cAdress  := Clients->Adress
  161.    cCountry := Clients->Country
  162.    lActive  := Clients->Active
  163.    cNotes   := StrTran( Clients->Notes, Chr( 141 ) + Chr( 10 ), "" )
  164.    cPhoto   := Clients->Photo
  165.  
  166.    DEFINE DIALOG oDlg RESOURCE "Client"
  167.  
  168.    REDEFINE SAY oRecNo PROMPT Str( RecNo(), 5 ) ;  // Here we trap a reference
  169.       ID 60 OF oDlg                                // to the SAY Object
  170.  
  171.    REDEFINE GET oName VAR cName ID 110 OF oDlg PICTURE "@!A" ;
  172.       COLOR "W+*/B"
  173.  
  174.    REDEFINE GET oAdress VAR cAdress COLOR "GR+/RB" ID 120 OF oDlg
  175.  
  176.    REDEFINE COMBOBOX oCountry VAR cCountry ITEMS aCountries ;
  177.       ID 130 OF oDlg
  178.  
  179.    REDEFINE CHECKBOX oActive  VAR lActive ID 140 OF oDlg
  180.  
  181.    REDEFINE GET oNotes VAR cNotes MEMO ID 150 OF oDlg ;
  182.       COLOR "w+/g"
  183.  
  184.    REDEFINE BITMAP oPhoto FILENAME cPhoto ID 230 OF oDlg
  185.  
  186.    REDEFINE SCROLLBAR ID 220 OF oDlg RANGE 1, RecCount() ;
  187.       ON DOWN ( DbSkip(),;
  188.                 If( EoF(), DbGoBottom(),),;
  189.                 oPhoto:LoadBMP( Clients->Photo ),;
  190.                 cName    := Clients->Name,    oName:Refresh(),;
  191.                 cAdress  := Clients->Adress,  oAdress:Refresh(),;
  192.                 cCountry := Clients->Country, oCountry:Refresh(),;
  193.                 lActive  := Clients->Active,  oActive:Refresh(),;
  194.                 cNotes   := StrTran( Clients->Notes, Chr( 141 ) + Chr( 10 ), "" ),;
  195.                             oNotes:Refresh(),;
  196.                 oRecNo:SetText( Str( RecNo(), 5 ) ) ) ;
  197.       ON UP   ( DbSkip( -1 ),;
  198.                 oPhoto:LoadBMP( Clients->Photo ),;
  199.                 cName    := Clients->Name,    oName:Refresh(),;
  200.                 cAdress  := Clients->Adress,  oAdress:Refresh(),;
  201.                 cCountry := Clients->Country, oCountry:Refresh(),;
  202.                 lActive  := Clients->Active,  oActive:Refresh(),;
  203.                 cNotes   := StrTran( Clients->Notes, Chr( 141 ) + Chr( 10 ), "" ),;
  204.                            oNotes:Refresh(),;
  205.                 oRecNo:SetText( Str( RecNo(), 5 ) ) )
  206.  
  207.    REDEFINE BUTTON ID 170 OF oDlg ;
  208.       ACTION ( oPhoto:Save( "Test.bmp" ), MsgInfo( "Look at Test.bmp on disk" ) )
  209.  
  210.    REDEFINE BUTTON ID 180 OF oDlg ;
  211.       ACTION ( oDlg:Copy( .t. ),;
  212.                MsgInfo( "A copy of this Dialog have been placed at the Clipboard!" ) )
  213.  
  214.    REDEFINE BUTTON ID 190 OF oDlg ;
  215.       ACTION ( oPhoto:HardCopy( 4 ),;
  216.                MsgInfo( "Hardcopy of the picture sent to the printer" ) )
  217.  
  218.    REDEFINE BUTTON ID 200 OF oDlg ACTION ;
  219.       BrowseClients( @cName, @cAdress, @cCountry, @lActive, @cNotes,;
  220.               oPhoto, oName, oAdress, oCountry, oActive, oNotes, oRecNo )
  221.  
  222.    REDEFINE BUTTON ID 210 OF oDlg ACTION oDlg:HardCopy( 2 )  // nScale factor
  223.  
  224.    REDEFINE BUTTON oExit ID 240 OF oDlg ACTION oDlg:End()
  225.  
  226.    ACTIVATE DIALOG oDlg CENTERED ;
  227.       ON INIT MsgInfo( "Init Dialog clause testing" )
  228.  
  229.    USE
  230.  
  231. return nil
  232.  
  233. //----------------------------------------------------------------------------//
  234.  
  235. function BrowseClients( cName, cAdress, cCountry, lActive, cNotes,;
  236.                  oPhoto, oName, oAdress, oCountry, oActive, oNotes, oRecNo )
  237.  
  238.    local oDlg
  239.    local nOldRecNo := RecNo()
  240.  
  241.    DEFINE DIALOG oDlg RESOURCE "Clients"
  242.  
  243.    REDEFINE LISTBOX FIELDS ID 110 OF oDlg
  244.  
  245.    ACTIVATE DIALOG oDlg
  246.  
  247.    if oDlg:nResult == 1           // ID_OK
  248.       cName    = Clients->Name
  249.       cAdress  = Clients->Adress
  250.       cCountry = Clients->Country
  251.       lActive  = Clients->Active
  252.       cNotes   = Clients->Notes
  253.  
  254.       oPhoto:LoadBmp( Clients->Photo )
  255.       oName:Refresh()
  256.       oAdress:Refresh()
  257.       oCountry:Refresh()
  258.       oActive:Refresh()
  259.       oNotes:Refresh()
  260.       oRecNo:SetText( Str( RecNo(), 5 ) )
  261.    else
  262.       GOTO nOldRecNo
  263.    endif
  264.  
  265. return nil
  266.  
  267. //----------------------------------------------------------------------------//
  268.  
  269. function About()
  270.  
  271.    local oDlg
  272.  
  273.    ShellAbout( FWVERSION, FWCOPYRIGHT, 0 )
  274.  
  275.    DEFINE DIALOG oDlg RESOURCE "About"
  276.  
  277.    ACTIVATE DIALOG oDlg CENTERED
  278.  
  279. return nil
  280.  
  281. //----------------------------------------------------------------------------//
  282.  
  283. function Exit()
  284.  
  285.    local oDlg
  286.    local lEnd := .f.
  287.  
  288.    DEFINE DIALOG oDlg RESOURCE "Exit"
  289.  
  290.    REDEFINE BITMAP ID 110 OF oDlg RESOURCE "Question"
  291.  
  292.    REDEFINE BUTTON ID 6 OF oDlg ACTION ( lEnd := .t., oDlg:End() )
  293.    REDEFINE BUTTON ID 7 OF oDlg ACTION oDlg:End()
  294.  
  295.    ACTIVATE DIALOG oDlg CENTERED
  296.  
  297.    if lEnd
  298.       oWnd:End()
  299.    endif
  300.  
  301. return nil
  302.  
  303. //----------------------------------------------------------------------------//
  304.  
  305. function Stop()
  306.  
  307.    local oDlg
  308.  
  309.    DEFINE DIALOG oDlg RESOURCE "Stop"
  310.  
  311.    REDEFINE SAY PROMPT "Only available in commercial version" ID 10 OF oDlg
  312.    REDEFINE BITMAP ID 110 OF oDlg RESOURCE "Hand"
  313.  
  314.    ACTIVATE DIALOG oDlg CENTERED
  315.  
  316. return nil
  317.  
  318. //----------------------------------------------------------------------------//
  319.  
  320. function TestBrowse()
  321.  
  322.    local oDlg
  323.  
  324.    USE Dialog
  325.  
  326.    DEFINE DIALOG oDlg RESOURCE "Clients"
  327.  
  328.    REDEFINE LISTBOX FIELDS ID 110 OF oDlg
  329.  
  330.    REDEFINE BUTTON ID 998 OF oDlg ;
  331.       ACTION MsgInfo( "Hey man! This is really powerfull" )
  332.  
  333.    ACTIVATE DIALOG oDlg CENTERED
  334.  
  335.    USE
  336.  
  337. return nil
  338.  
  339. //----------------------------------------------------------------------------//
  340.