Page 1 of 2
templates / plantillas
Posted: Sat Dec 22, 2007 7:53 am
by Antonio Linares
A dialog created from source code:
Code: Select all
#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
#include "FiveWin.ch"
function Main()
local oDlg
DEFINE DIALOG oDlg RESOURCE "Test"
ACTIVATE DIALOG oDlg CENTERED
return nil
and test.rc
Code: Select all
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
}
Posted: Sat Dec 22, 2007 8:41 am
by Antonio Linares
A window:
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Test"
ACTIVATE WINDOW oWnd
return nil
Posted: Sat Jan 26, 2008 11:16 pm
by Antonio Linares
MDI window and a PRINT ... PREVIEW:
Code: Select all
#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
A dialog with a folder
Posted: Mon May 26, 2008 12:06 pm
by Antonio Linares
A dialog with a folder from source code:
test.prg
Code: Select all
#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
#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
#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"
{
}
Posted: Tue Aug 05, 2008 6:48 pm
by Antonio Linares
A folder and two xbrowses:
test.prg
Code: Select all
#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
#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
}
Posted: Wed Aug 06, 2008 5:41 am
by Antonio Linares
A XBrowse on a dialog:
test.prg
Code: Select all
#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
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
}
Posted: Mon Aug 18, 2008 7:08 pm
by Antonio Linares
A window and a non modal dialog:
Code: Select all
#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
Posted: Sun Sep 07, 2008 10:16 am
by Antonio Linares
Creating a XBrowse from source code:
Code: Select all
#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
Posted: Mon Sep 08, 2008 3:49 pm
by Antonio Linares
Building a C function from a PRG:
Code: Select all
#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
Posted: Wed Oct 01, 2008 10:59 pm
by Antonio Linares
MDI window with MDICHILD window with a buttonbar:
Code: Select all
#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
Posted: Sun Oct 05, 2008 8:54 am
by Antonio Linares
A dialog with a timer:
Code: Select all
#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
Posted: Sun Oct 05, 2008 4:08 pm
by Antonio Linares
Accessing "high level" (PRG code) from "low level" (C code):
Code: Select all
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
Posted: Sun Oct 05, 2008 10:01 pm
by Antonio Linares
Sending a message to an object from low level:
Code: Select all
#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
Posted: Thu Oct 09, 2008 12:13 pm
by Antonio Linares
Browsing an array with xbrowse:
Code: Select all
#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
Posted: Sun Nov 23, 2008 7:10 am
by joseluisysturiz
Antonio Linares wrote:A folder and two xbrowses:
test.prg
Code: Select all
#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
#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...