templates / plantillas

templates / plantillas

Postby Antonio Linares » Sat Dec 22, 2007 7:53 am

A dialog created from source code:
Code: Select all  Expand view
 
#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: Select all  Expand view
 
#include "FiveWin.ch"   
 
function Main()         
 
   local oDlg         
 
   DEFINE DIALOG oDlg RESOURCE "Test"         
 
   ACTIVATE DIALOG oDlg CENTERED   
 
return nil 
 


and test.rc
Code: Select all  Expand view
 
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
}
 
Last edited by Antonio Linares on Sun Sep 28, 2008 11:29 am, edited 3 times in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sat Dec 22, 2007 8:41 am

A window:
Code: Select all  Expand view
 
#include "FiveWin.ch"
 
function Main()
 
   local oWnd
 
   DEFINE WINDOW oWnd TITLE "Test"
 
   ACTIVATE WINDOW oWnd
 
return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sat Jan 26, 2008 11:16 pm

MDI window and a PRINT ... PREVIEW:
Code: Select all  Expand view
 
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

A dialog with a folder

Postby Antonio Linares » Mon May 26, 2008 12:06 pm

A dialog with a folder from source code:

test.prg
Code: Select all  Expand view
 
#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: Select all  Expand view
 
#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: Select all  Expand view
 
#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"
{
}
 
Last edited by Antonio Linares on Sat Aug 30, 2008 6:47 pm, edited 2 times in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Aug 05, 2008 6:48 pm

A folder and two xbrowses:

test.prg
Code: Select all  Expand view
 
#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: Select all  Expand view
 
#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
}
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Aug 06, 2008 5:41 am

A XBrowse on a dialog:

test.prg
Code: Select all  Expand view
 
#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: Select all  Expand view
 
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
}
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Aug 18, 2008 7:08 pm

A window and a non modal dialog:

Code: Select all  Expand view
 
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Sep 07, 2008 10:16 am

Creating a XBrowse from source code:

Code: Select all  Expand view

#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Sep 08, 2008 3:49 pm

Building a C function from a PRG:

Code: Select all  Expand view

#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Oct 01, 2008 10:59 pm

MDI window with MDICHILD window with a buttonbar:
Code: Select all  Expand view

#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Oct 05, 2008 8:54 am

A dialog with a timer:
Code: Select all  Expand view

#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Oct 05, 2008 4:08 pm

Accessing "high level" (PRG code) from "low level" (C code):
Code: Select all  Expand view

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Oct 05, 2008 10:01 pm

Sending a message to an object from low level:
Code: Select all  Expand view

#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Oct 09, 2008 12:13 pm

Browsing an array with xbrowse:
Code: Select all  Expand view

#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby joseluisysturiz » Sun Nov 23, 2008 7:10 am

Antonio Linares wrote:A folder and two xbrowses:

test.prg
Code: Select all  Expand view
#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: Select all  Expand view

#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... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Next

Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 16 guests