FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Utilities / Utilidades templates / plantillas
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Sat Dec 22, 2007 07:53 AM
A dialog created from source code:
Code (fw): Select all Collapse
 
#include "FiveWin.ch"  
 
function Main()        
 
   local oDlg        
 
   DEFINE DIALOG oDlg TITLE "Test"        
 
   ACTIVATE DIALOG oDlg CENTERED  
 
return nil


A dialog created from resources:
test.prg
Code (fw): Select all Collapse
 
#include "FiveWin.ch"   
 
function Main()         
 
   local oDlg         
 
   DEFINE DIALOG oDlg RESOURCE "Test"         
 
   ACTIVATE DIALOG oDlg CENTERED   
 
return nil


and test.rc
Code (text): Select all Collapse
<div class="text" id="{CB}" style="font-family: monospace;"> 
test DIALOG 17, 36, 185, 147 
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Test" FONT 8, "MS Sans Serif" 
{  
   DEFPUSHBUTTON "OK", 1, 67, 128, 50, 14 
}
 </div>
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Sat Dec 22, 2007 08:41 AM
A window:
Code (fw): Select all Collapse
 
#include "FiveWin.ch" 
 
function Main() 
 
   local oWnd 
 
   DEFINE WINDOW oWnd TITLE "Test" 
 
   ACTIVATE WINDOW oWnd 
 
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Sat Jan 26, 2008 11:16 PM
MDI window and a PRINT ... PREVIEW:
Code (fw): Select all Collapse
 
#include "FiveWin.ch" 
 
function Main() 
 
   local oWnd 
 
   DEFINE WINDOW oWnd TITLE "Test" MDI ; 
      MENU BuildMenu() 
 
   ACTIVATE WINDOW oWnd 
 
return nil 
 
function BuildMenu() 
 
   local oMenu 
    
   MENU oMenu 
      MENUITEM "Test" 
      MENU 
         MENUITEM "Preview" ACTION Preview() 
      ENDMENU    
      oMenu:AddMdi() 
   ENDMENU 
    
return oMenu    
 
function Preview() 
 
   local oPrn 
    
   PRINTER oPrn Preview 
      PAGE 
         oPrn:Say( 2, 2, "Test" ) 
      ENDPAGE 
   ENDPRINTER 
    
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
A dialog with a folder
Posted: Mon May 26, 2008 12:06 PM
A dialog with a folder from source code:

test.prg
Code (fw): Select all Collapse
 
#include "FiveWin.ch" 
 
function Main() 
 
   local oDlg, oFld 
    
   DEFINE DIALOG oDlg SIZE 400, 300
 
   @ 0.5, 1 FOLDER oFld OF oDlg SIZE 188, 138 ;
      PROMPTS "One", "Two", "Three"
      
   ACTIVATE DIALOG oDlg CENTERED 
 
return nil


A dialog with a folder from resources:

test.prg
Code (fw): Select all Collapse
 
#include "FiveWin.ch"
 
function Main()
 
   local oDlg, oFld
   
   DEFINE DIALOG oDlg RESOURCE "Test"
 
   REDEFINE FOLDER oFld ;
      PROMPTS "One", "Two", "three" ;
      DIALOGS "One", "Two", "Three" ;
      ID 100 OF oDlg
      
   ACTIVATE DIALOG oDlg CENTERED
 
return nil


test.rc
Code (text): Select all Collapse
<div class="text" id="{CB}" style="font-family: monospace;"> 
#ifdef __FLAT__
   1 24 "WindowsXP.Manifest" 
#endif
 
test DIALOG 17, 36, 185, 147
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Test"
FONT 8, "MS Sans Serif"
{
 CONTROL "", 100, "SysTabControl32", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 6, 175, 117
 DEFPUSHBUTTON "OK", 1, 67, 128, 50, 14
}
 
one DIALOG 6, 15, 175, 117
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
}
 
two DIALOG 6, 15, 175, 117
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
}
 
three DIALOG 6, 15, 175, 117
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
}
 </div>
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Tue Aug 05, 2008 06:48 PM
A folder and two xbrowses:

test.prg
Code (fw): Select all Collapse
 
#include "FiveWin.ch" 
#include "XBrowse.ch"
 
function Main() 
 
   local oDlg, oFld, oBrw1, oBrw2 
    
   USE Customer 
    
   DEFINE DIALOG oDlg RESOURCE "Test" 
 
   REDEFINE FOLDER oFld ; 
      PROMPTS "One", "Two" ; 
      DIALOGS "One", "Two" ; 
      ID 100 OF oDlg 
      
   REDEFINE XBROWSE oBrw1 ID 10 OF oFld:aDialogs[ 1 ]
      
   REDEFINE XBROWSE oBrw2 ID 10 OF oFld:aDialogs[ 2 ]
      
   ACTIVATE DIALOG oDlg CENTERED 
 
return nil


Test.rc
Code (text): Select all Collapse
<div class="text" id="{CB}" style="font-family: monospace;"> 
#ifdef __FLAT__ 
   1 24 "WindowsXP.Manifest" 
#endif 
 
test DIALOG 17, 36, 185, 147 
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU 
CAPTION "Test" 
FONT 8, "MS Sans Serif" 
{ 
 CONTROL "", 100, "SysTabControl32", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 6, 175, 117 
 DEFPUSHBUTTON "OK", 1, 67, 128, 50, 14 
} 
 
one DIALOG 6, 15, 175, 117
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
 CONTROL "", 10, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL, 4, 4, 168, 110
}
 
two DIALOG 6, 15, 175, 117
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
 CONTROL "", 10, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL, 4, 4, 168, 110
}
 </div>
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Wed Aug 06, 2008 05:41 AM
A XBrowse on a dialog:

test.prg
Code (fw): Select all Collapse
 
#include "FiveWin.ch"
#include "XBrowse.ch"
 
function Main()
 
   local oDlg, oBrw
 
   USE Customer
 
   DEFINE DIALOG oDlg RESOURCE "Test"
 
   REDEFINE XBROWSE oBrw ID 10 OF oDlg AUTOCOLS ALIAS "Customer"
 
   ACTIVATE DIALOG oDlg
 
return nil


Test.rc
Code (text): Select all Collapse
<div class="text" id="{CB}" style="font-family: monospace;"> 
test DIALOG 68, 43, 336, 213
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Test"
FONT 8, "MS Sans Serif"
{
 CONTROL "", 10, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, 5, 6, 325, 175
 DEFPUSHBUTTON "OK", 1, 143, 191, 50, 14
}
 </div>
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Mon Aug 18, 2008 07:08 PM
A window and a non modal dialog:

Code (fw): Select all Collapse
 
#include "FiveWin.ch"
 
function Main()
 
   local oWnd
 
   DEFINE WINDOW oWnd TITLE "A window"
 
   ACTIVATE WINDOW oWnd ;
      ON INIT BuildNonModal()
 
return nil
 
function BuildNonModal()
 
   local oDlg
   
   DEFINE DIALOG oDlg TITLE "A non modal dialog"
   
   ACTIVATE DIALOG oDlg NOWAIT CENTERED
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Sun Sep 07, 2008 10:16 AM
Creating a XBrowse from source code:

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "XBrowse.ch"

function Main()

   local oWnd, oBrw, oCol

   USE Customer

   DEFINE WINDOW oWnd
   
   @ 0, 0 XBROWSE oBrw OF oWnd ALIAS "Customer"
   
   oCol = oBrw:AddCol() 
   oCol:bStrData = { || Customer->First } 
   oCol:cHeader = "First"
   
   oBrw:CreateFromCode()
   
   oWnd:oClient = oBrw

   ACTIVATE WINDOW oWnd

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Mon Sep 08, 2008 03:49 PM
Building a C function from a PRG:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   MsgInfo( Test( 123 ) )

return nil

#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( TEST )
{
   hb_retnl( hb_parnl( 1 ) );   
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Wed Oct 01, 2008 10:59 PM
MDI window with MDICHILD window with a buttonbar:
Code (fw): Select all Collapse
#include "FiveWin.ch" 

static oWnd

function Main() 

   DEFINE WINDOW oWnd TITLE "Test" MDI ; 
      MENU BuildMenu() 

   ACTIVATE WINDOW oWnd 

return nil 

function BuildMenu() 

   local oMenu 
    
   MENU oMenu 
      MENUITEM "Test" 
      MENU 
         MENUITEM "Child" ACTION CreateChild()
         SEPARATOR
         MENUITEM "Exit" ACTION oWnd:End()
      ENDMENU    
      oMenu:AddMdi() 
   ENDMENU 
    
return oMenu    

function CreateChild()

   local oWnd, oBar

   DEFINE WINDOW oWnd MDICHILD TITLE "Child" VSCROLL
   
   DEFINE BUTTONBAR oBar OF oWnd SIZE 50, 50 2007
   
   DEFINE BUTTON OF oBar ACTION MsgInfo( "click" )

   ACTIVATE WINDOW oWnd ;
     ON UP   oWnd:SetText( "up" ) ;
     ON DOWN oWnd:SetText( "down" ) 
    
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Sun Oct 05, 2008 08:54 AM
A dialog with a timer:
Code (fw): Select all Collapse
#include "FiveWin.ch" 

function Main() 

   local oDlg

   DEFINE DIALOG oDlg TITLE "Test" 

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT BuildTimer( oDlg )

return nil 

function BuildTimer( oDlg )

   local oTmr
   
   DEFINE TIMER oTmr OF oDlg INTERVAL 10000 ACTION oDlg:End()

   ACTIVATE TIMER oTmr 

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Sun Oct 05, 2008 04:08 PM
Accessing "high level" (PRG code) from "low level" (C code):
Code (fw): Select all Collapse
function Main()

   MsgInfo( Test() )

return nil

function Another( cValue )

   MsgInfo( cValue )

return "returned from high level"

#pragma BEGINDUMP

#include <hbapi.h>
#include <hbvm.h>

HB_FUNC( TEST )
{
   // We build the virtual machine stack frame

   hb_vmPushSymbol( hb_dynsymGetSymbol( "ANOTHER" ) ); // we push the symbol of the function to call
   hb_vmPushNil(); // we push nil for a function, a codeblock for Eval, an object for a method
   hb_vmPushString( "High level access from low level", strlen( "High level access from low level" ) );
   hb_vmFunction( 1 ); // 1 --> number of supplied parameters
   
   // the returned value can be accessed using hb_stackReturnItem() --> PHB_ITEM
   // or simply calling hb_par...( -1 );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Sun Oct 05, 2008 10:01 PM
Sending a message to an object from low level:
Code (fw): Select all Collapse
#include "hbclass.ch" 

function Main() 

   local oMyObject := TMyClass() 
    
   Test( oMyObject ) 

return nil 

CLASS TMyClass 

   METHOD Say( cMsg ) INLINE MsgInfo( cMsg ) 
    
ENDCLASS    

#pragma BEGINDUMP 

#include <hbapi.h> 
#include <hbvm.h> 

HB_FUNC( TEST ) 
{ 
   // We build the virtual machine stack frame 

   hb_vmPushSymbol( hb_dynsymGetSymbol( "SAY" ) ); // we push the symbol of the method 
   hb_vmPush( hb_param( 1, HB_IT_OBJECT ) ); // we push the object 
   hb_vmPushString( "Calling a method from low level", strlen( "Calling a method from low level" ) ); 
   hb_vmFunction( 1 ); // 1 --> number of supplied parameters 
    
   // the returned value can be accessed using hb_stackReturnItem() --> PHB_ITEM 
   // or simply calling hb_par...( -1 ); 
} 

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
templates / plantillas
Posted: Thu Oct 09, 2008 12:13 PM
Browsing an array with xbrowse:
Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oDlg, oBrw, aValues := { "one", "two", "three" }, nAt := 3
   
   DEFINE DIALOG oDlg

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY aValues // AUTOSORT

   oBrw:CreateFromCode()
   
   oDlg:oClient = oBrw   
      
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oBrw:nArrayAt := nAt, oBrw:aCols[ 1 ]:cHeader := "Values",;
                oBrw:aCols[ 1 ]:nWidth := 100, oDlg:ReSize() )
      
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
templates / plantillas
Posted: Sun Nov 23, 2008 07:10 AM
Antonio Linares wrote:A folder and two xbrowses:

test.prg
#include "FiveWin.ch" 
#include "XBrowse.ch"

function Main() 

   local oDlg, oFld, oBrw1, oBrw2 
    
   USE Customer 
    
   DEFINE DIALOG oDlg RESOURCE "Test" 

   REDEFINE FOLDER oFld ; 
      PROMPTS "One", "Two" ; 
      DIALOGS "One", "Two" ; 
      ID 100 OF oDlg 
      
   REDEFINE XBROWSE oBrw1 ID 10 OF oFld:aDialogs[ 1 ]
      
   REDEFINE XBROWSE oBrw2 ID 10 OF oFld:aDialogs[ 2 ]
      
   ACTIVATE DIALOG oDlg CENTERED 

return nil


Test.rc
#ifdef __FLAT__ 
   1 24 "WindowsXP.Manifest" 
#endif 

test DIALOG 17, 36, 185, 147 
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU 
CAPTION "Test" 
FONT 8, "MS Sans Serif" 
{ 
 CONTROL "", 100, "SysTabControl32", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 6, 175, 117 
 DEFPUSHBUTTON "OK", 1, 67, 128, 50, 14 
} 

one DIALOG 6, 15, 175, 117
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
 CONTROL "", 10, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL, 4, 4, 168, 110
}

two DIALOG 6, 15, 175, 117
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
 CONTROL "", 10, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL, 4, 4, 168, 110
}

Antonio, hace dias con un colega tratamos de hacer 2 xbrowse en un Dlg o Fld desde SOURCE, pero de verdad hicimos de todo y no pudimos, tratamos on oTop, y demas parametro, seria mucho pedir un pequeño ejemplo para futura oportunidad, el termino haciendolo con recurso, gracias, saludos... :-)
Dios no está muerto...



Gracias a mi Dios ante todo!