Code

// To compile this code you need to add references
// to System.Windows.Forms and VulcanVORDDClasses
// You can do this in Visual Studio, VIDE, or
// on the command line

#using System.Windows.Forms

CLASS DBWin INHERIT System.Windows.Forms.Form
   PROTECT aTextControls AS ARRAY
   PROTECT server AS dbserver

CONSTRUCTOR() CLASS DBWin
   SUPER()
   SELF:InitialiseForm()
   RETURN

METHOD AddTextControl(oControl AS Control) AS VOID CLASS DBWin
   SELF:Controls:Add(oControl)
   AAdd(SELF:aTextControls,oControl)
   RETURN

METHOD Configure() AS VOID CLASS DBWin
   LOCAL nCount AS INT
   LOCAL oControl AS TextBox
   LOCAL oButton AS Button
   LOCAL nTopPosition AS INT
   LOCAL i AS INT

   oButton := System.Windows.Forms.Button{}
   oButton:Location := System.Drawing.Point{300,25}
   oButton:Size := System.Drawing.Size{72,24}
   oButton:Text := "&Previous"
   oButton:Click = System.EventHandler{ SELF,@DBWin.PreviousClick() }

   SELF:Controls:Add(oButton)
   oButton := System.Windows.Forms.Button{}
   oButton:Location := System.Drawing.Point{300,50}
   oButton:Size := System.Drawing.Size{72,24}
   oButton:Text := "&Next"
   oButton:Click = System.EventHandler{ SELF,@DBWin.NextClick() }

   SELF:Controls:Add(oButton)
   nCount := SELF:server:FCount

   SELF:aTextControls := {}
   nTopPosition := 20
   FOR i := 1 UPTO nCount
      oControl := TextBox{}
      oControl:Size := System.Drawing.Size{200,22}
      oControl:Location := System.Drawing.Point{50,nTopPosition (i-1)*25}
      oControl:ReadOnly := TRUE
      SELF:AddTextControl(oControl)
   NEXT
   SELF:Size := System.Drawing.Size{400,90 nCount*25}
   RETURN

METHOD FillForm() AS VOID CLASS DBWin
   LOCAL nCount AS DWORD
   LOCAL oControl AS Control
   LOCAL i AS DWORD

   nCount := (DWORD)ALen(SELF:aTextControls)
   FOR i := 1U UPTO nCount
      oControl := (Control)SELF:aTextControls[i]
      oControl:Text := AsString(SELF:Server:FIELDGET(i))
   NEXT
   RETURN

METHOD InitialiseForm() AS VOID CLASS DBWin
   SELF:Location := System.Drawing.Point{100,100}
   SELF:Size := System.Drawing.Size{400,100}
   SELF:Text := "DBF Demo"
   RETURN

METHOD NextClick(oControl AS OBJECT , e AS System.EventArgs) AS VOID CLASS DBWin
   SELF:server:Skip(1)
   IF ! SELF:server:Eof
      SELF:FillForm()
   ELSE
      System.Windows.Forms.MessageBox.Show("End of file","DBF Demo")
      SELF:server:GoBottom()
   ENDIF
   RETURN

METHOD PreviousClick(oControl AS OBJECT , e AS System.EventArgs) AS VOID CLASS DBWin
   SELF:server:Skip(-1)
   IF ! SELF:server:Bof
      SELF:FillForm()
   ELSE
      System.Windows.Forms.MessageBox.Show("Beginning of file","DBF Demo")
   ENDIF
   RETURN

METHOD Use(oDBF AS dbserver) AS VOID CLASS DBWin
   SELF:server := oDBF
   SELF:Configure()
   SELF:FillForm()
   RETURN

END CLASS


FUNCTION Start AS VOID
   LOCAL o AS DBWin
   LOCAL db AS dbserver

   System.Windows.Forms.Application.EnableVisualStyles()
   db := dbserver{"d:\test1\customer.dbf"}
   o := DBWin{}
   o:Use(db)
   Application.Run(o)
   db:Close()
   RETURN

 

 Print  
Copyright 2012 GrafX Software DevelopmentTerms Of UsePrivacy Statement     Login