home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / samples.z / Text.wxf < prev    next >
Encoding:
Text File  |  1996-05-06  |  7.9 KB  |  364 lines

  1. Save Format v1.3
  2. @begin Form "WinText"
  3.  Exported 0;
  4.  
  5.  @begin Object "WDialog"
  6.   WSCaption 1;
  7.   WSSizeable 1;
  8.   WSDlgBorder 1;
  9.   WSSysMenu 1;
  10.   WSSystemMenu 1;
  11.   WSMinimizeBox 1;
  12.   WSMaximizeBox 1;
  13.   WSGroup 1;
  14.   WSTabStop 1;
  15.   WSResizeBorder 1;
  16.   WSVisible 1;
  17.   FormPositionType "Centered";
  18.   FormAbsTop "259";
  19.   FormAbsLeft "197";
  20.   FDXStructName "WinTextFDXStruct";
  21.   Font "8.MS Sans Serif";
  22.   Text "Intersolv Text File Example";
  23.   @begin Event "Create"
  24.    GencodeSrcLine 228;
  25.    FunctionName "WinText::WinText_Create";
  26.   @end;
  27.   @begin UserFunction "WinText()"
  28.    Compiler 1;
  29.    GencodeSrcLine 242;
  30.    FunctionName "WinText::WinText()";
  31.   @end;
  32.   @begin UserFunction "~WinText()"
  33.    Compiler 1;
  34.    GencodeSrcLine 246;
  35.    FunctionName "WinText::~WinText()";
  36.   @end;
  37.   @begin UserFunction "Process( WWindow *parent )"
  38.    GencodeSrcLine 250;
  39.    FunctionName "WinText::Process( WWindow *parent )";
  40.   @end;
  41.   @begin UserFunction "Prototype for Process( WWindow *parent )"
  42.    Private 1;
  43.    GencodeSrcLine 66;
  44.    FunctionName "WinText::Prototype for Process( WWindow *parent )";
  45.   @end;
  46.   ResID 108;
  47.   DesignName WinText;
  48.   TabIndex 0;
  49.   DesignRect 212,108,217,90;
  50.  @end;
  51.  
  52.  @begin Object "WQuery"
  53.   BindLimit "0";
  54.   ConcurrencyLevel "WQCLLock";
  55.   CursorType "WQCTDynamic";
  56.   SQL "select * from text.txt\r\norder by Employee";
  57.   Transaction "WinText::transaction_text";
  58.   AutoOpen "0";
  59.   ResID 101;
  60.   DesignName query_text;
  61.   TabIndex 0;
  62.   DesignRect 6,57,19,17;
  63.  @end;
  64.  
  65.  @begin Object "WLabel"
  66.   WSSLeftNoWordWrap 1;
  67.   WSSNotify 1;
  68.   WCCSNoResize 1;
  69.   WCCSNoParentAlign 1;
  70.   WSChild 1;
  71.   WSMinimizeBox 1;
  72.   WSGroup 1;
  73.   WSVisible 1;
  74.   AutoSize "1";
  75.   Text "Employee:";
  76.   ResID 102;
  77.   DesignName label_1;
  78.   TabIndex 0;
  79.   DesignRect 6,12,33,8;
  80.  @end;
  81.  
  82.  @begin Object "WTextBox"
  83.   WTextBoxAutoHScroll 1;
  84.   WSBorder 1;
  85.   WSChild 1;
  86.   WSMaximizeBox 1;
  87.   WSTabStop 1;
  88.   WSExClientEdge 1;
  89.   WSVisible 1;
  90.   DataColumns "Employee";
  91.   DataSource "WinText::query_text";
  92.   FDXFieldName "textb_1_data";
  93.   FDXFieldType "WString";
  94.   ResizePercentages "[ 0 0 100 0 ]";
  95.   ResID 103;
  96.   DesignName textb_1;
  97.   TabIndex 1;
  98.   DesignRect 56,12,145,12;
  99.  @end;
  100.  
  101.  @begin Object "WTransaction"
  102.   DataSource "Text File Optima Example";
  103.   AutoConnect "0";
  104.   ResID 104;
  105.   DesignName transaction_text;
  106.   TabIndex 2;
  107.   DesignRect 26,57,19,17;
  108.  @end;
  109.  
  110.  @begin Object "WLabel"
  111.   WSSLeftNoWordWrap 1;
  112.   WSSNotify 1;
  113.   WCCSNoResize 1;
  114.   WCCSNoParentAlign 1;
  115.   WSChild 1;
  116.   WSVisible 1;
  117.   AutoSize "1";
  118.   Text "Start date:";
  119.   ResID 105;
  120.   DesignName label_2;
  121.   TabIndex 2;
  122.   DesignRect 6,27,30,8;
  123.  @end;
  124.  
  125.  @begin Object "WTextBox"
  126.   WTextBoxAutoHScroll 1;
  127.   WSBorder 1;
  128.   WSChild 1;
  129.   WSMaximizeBox 1;
  130.   WSTabStop 1;
  131.   WSExClientEdge 1;
  132.   WSVisible 1;
  133.   DataColumns "StartDate";
  134.   DataSource "WinText::query_text";
  135.   FDXFieldName "textb_2_data";
  136.   FDXFieldType "WString";
  137.   ResizePercentages "[ 0 0 100 0 ]";
  138.   ResID 106;
  139.   DesignName textb_2;
  140.   TabIndex 3;
  141.   DesignRect 56,27,145,12;
  142.  @end;
  143.  
  144.  @begin Object "WLabel"
  145.   WSSLeftNoWordWrap 1;
  146.   WSSNotify 1;
  147.   WCCSNoResize 1;
  148.   WCCSNoParentAlign 1;
  149.   WSChild 1;
  150.   WSVisible 1;
  151.   AutoSize "1";
  152.   Text "Salary:";
  153.   ResID 107;
  154.   DesignName label_3;
  155.   TabIndex 4;
  156.   DesignRect 6,42,21,8;
  157.  @end;
  158.  
  159.  @begin Object "WTextBox"
  160.   WTextBoxAutoHScroll 1;
  161.   WSBorder 1;
  162.   WSChild 1;
  163.   WSMaximizeBox 1;
  164.   WSTabStop 1;
  165.   WSExClientEdge 1;
  166.   WSVisible 1;
  167.   DataColumns "Salary";
  168.   DataSource "WinText::query_text";
  169.   FDXFieldName "textb_3_data";
  170.   FDXFieldType "WString";
  171.   ResizePercentages "[ 0 0 100 0 ]";
  172.   ResID 108;
  173.   DesignName textb_3;
  174.   TabIndex 5;
  175.   DesignRect 56,42,145,12;
  176.  @end;
  177.  
  178.  @begin Object "WDataNavigator"
  179.   WSChild 1;
  180.   WSMaximizeBox 1;
  181.   WSTabStop 1;
  182.   WSVisible 1;
  183.   BOFAction "WDNActionMoveFirst";
  184.   DataSource "WinText::query_text";
  185.   EOFAction "WDNActionMoveLast";
  186.   ShowAdd "1";
  187.   ShowCancel "1";
  188.   ShowDelete "1";
  189.   ShowEdit "1";
  190.   ShowMoveFirst "1";
  191.   ShowMoveLast "1";
  192.   ShowMoveNext "1";
  193.   ShowMovePrevious "1";
  194.   ShowRefresh "1";
  195.   ShowUpdate "1";
  196.   ResID 109;
  197.   DesignName datanavigator_1;
  198.   TabIndex 6;
  199.   DesignRect 56,62,147,12;
  200.  @end;
  201.  
  202.  @begin HPPPrefixBlock
  203. @begin-code HPPPrefix
  204.  
  205. // Declarations added here will be included at the top of the .HPP file
  206.  
  207. @end-code;
  208.   GencodeSrcLine 13;
  209.  @end;
  210.  
  211.  @begin CPPPrefixBlock
  212. @begin-code CPPPrefix
  213.  
  214. // Code added here will be included at the top of the .CPP file
  215.  
  216. //  Include definitions for resources.
  217. #include "WRes.h"
  218. #include "odbcadm.hpp"
  219. #include "applic.hpp"
  220.  
  221.  
  222.  
  223. static WChar *Driver_keys[]={
  224.     WTEXT( "Description" ), WTEXT( "" ),
  225.     WTEXT( "ScanRows" ), WTEXT( "25" ),
  226.     WTEXT( "FileOpenCache" ), WTEXT( "0" ),
  227.     WTEXT( "CacheSize" ), WTEXT( "4" ),
  228.     WTEXT( "IntlSort" ), WTEXT( "0" ),
  229.     WTEXT( "UseLongQualifiers" ), WTEXT( "0" ),
  230.     WTEXT( "TableType" ), WTEXT( "Character" ),
  231.     WTEXT( "Delimiter" ), WTEXT( "#" ),
  232.     WTEXT( "UndefinedTable" ), WTEXT( "GUESS" ),
  233.     WTEXT( "ExtraExtensions" ), WTEXT( "" ),
  234.     WTEXT( "DataFileExtension" ), WTEXT( "TXT" ),
  235.     WTEXT( "FirstLineNames" ), WTEXT( "1" ),
  236.     NULL
  237. };
  238.  
  239. static WChar Driver[]=
  240.     WTEXT( "INTERSOLV OEM 2.12 32-BIT Text (*.*)" );
  241.     
  242. static WChar Datasource[]= WTEXT( "Text File Optima Example" );
  243.  
  244. @end-code;
  245.   GencodeSrcLine 10;
  246.  @end;
  247.  
  248.  @begin ClassContentsBlock
  249. @begin-code ClassContents
  250.  
  251.     public:
  252.         // add your public instance data here
  253.     private:
  254.         // add your private instance data here
  255.         WString                 _dbpath;
  256.  
  257.     protected:
  258.         // add your protected instance data here
  259.  
  260. @end-code;
  261.   GencodeSrcLine 58;
  262.  @end;
  263.  
  264. @begin-code GeneratedClassContents
  265.  
  266.         WinText();
  267.         ~WinText();
  268.  
  269. @end-code;
  270.  
  271. @begin-code Code "WinText::WinText()"
  272.  
  273. WinText::WinText()
  274. {
  275.     
  276. }
  277.  
  278. @end-code;
  279.  
  280. @begin-code Code "WinText::~WinText()"
  281.  
  282. WinText::~WinText()
  283. {
  284.     
  285. }
  286.  
  287. @end-code;
  288.  
  289. @begin-code Code "WinText::Process( WWindow *parent )"
  290.  
  291. WBool WinText::Process( WWindow *parent )
  292. {
  293.     WString             driver_dll;
  294.     WStringArray        keys;
  295.     int                 i;
  296.     WString             db_file;
  297.     WFilePath           path;
  298.     WString             dir;
  299.     
  300.     if( !ODBCAdmin::DriverExists( Driver, driver_dll ) ) {
  301.         WMessageBox::Messagef( parent, WMBLevelError, WMBButtonOk, "Driver Error",
  302.                 "The ODBC Driver '%s' is not installed. Data source cannot "
  303.                 "be created.", Driver );
  304.         return( FALSE );
  305.     }
  306.     
  307.     for( i = 0; Driver_keys[i] != NULL; ++i );
  308.     keys.SetCount( i + 4 );
  309.     for( i = 0; Driver_keys[i] != NULL; ++i ) {
  310.         keys[i] = Driver_keys[i];
  311.     }
  312.     keys[i] = WTEXT( "Driver" );
  313.     keys[i + 1] = driver_dll;
  314.     keys[i + 2] = WTEXT( "Database" );
  315.     db_file = Application->GetProgramPath();
  316.     path = db_file;
  317.     dir = path.GetDirectory();
  318.     dir.Concat( "\\.." );
  319.     path.SetFileName( "" );
  320.     path.SetDirectory( dir );
  321.     path.CleanDirectory();
  322.     keys[i + 3] = path;
  323.     _dbpath = path;
  324.  
  325.     if( !ODBCAdmin::AddDataSource( Datasource, Driver, keys ) ) {
  326.         WMessageBox::Messagef( parent, WMBLevelError, WMBButtonOk, "Data source Error",
  327.                 "The ODBC Datasource '%s' could not be installed", Datasource );
  328.         return( FALSE );
  329.     }
  330.  
  331.     Create( parent );
  332.     
  333.     return( TRUE );    
  334. }
  335.  
  336. @end-code;
  337.  
  338. @begin-code Code "WinText::Prototype for Process( WWindow *parent )"
  339.  
  340.     public:
  341.         WBool Process( WWindow *parent );
  342.  
  343. @end-code;
  344.  
  345. @begin-code Code "WinText::WinText_Create"
  346.  
  347. WBool WinText::WinText_Create(
  348.     WObject *                 source,
  349.     WCreateEventData *        event )
  350. {
  351.     WString                 connect_parms;
  352.     
  353.     connect_parms.Sprintf( "database=%s", _dbpath.GetText() );
  354.     transaction_text->SetConnectParams( connect_parms );
  355.     transaction_text->Connect();
  356.     query_text->Open();
  357.     query_text->MoveFirst();
  358.     
  359.     return FALSE;
  360. }
  361.  
  362. @end-code;
  363. @end;
  364.