Clase TActiveX mejorada y RibbonBar más fácil
Posted: Tue Apr 07, 2009 7:42 am
Gracias a las pruebas que estamos haciendo estos dias con el RibbonBar de CodeJock, hemos mejorado la Clase TActiveX para que automaticamente use objetos TOleAuto en los eventos, por lo que el uso del RibbonBar es mucho más simple y fácil
Aqui teneis un ejemplo de uso. Fijaros en la forma en que oControl se obtiene desde RibbonBarEvent():
Aqui teneis un ejemplo de uso. Fijaros en la forma en que oControl se obtiene desde RibbonBarEvent():
- Code: Select all Expand view
#include "FiveWin.ch"
#define xtpControlButton 1
#define xtpFlagRightAlign 1
#define ID_ADDTAB 10
#define ID_ADDGROUP 20
#define ID_ADDBUTTON 30
static oRb
function Main()
local oWnd, oAct, oMenu, oTabs, oGroups, oControls
DEFINE WINDOW oWnd TITLE "Visual RibbonBar"
@ 0, 0 ACTIVEX oAct PROGID "Codejock.CommandBarsFrame.12.1.1" OF oWnd SIZE 0, 0
oAct:bOnEvent = { | cEvent, aParams | RibbonBarEvent( cEvent, aParams ) }
oAct:Do( "AttachToWindow", oWnd:hWnd )
oRb = oAct:Do( "AddRibbonBar", "fwh" )
oMenu = oRb:Controls:Add( 2, 0, "Menu" )
oMenu:Flags = xtpFlagRightAlign
oTabs = oMenu:CommandBar:Controls:Add( 2, 0, "Tabs" )
oTabs:CommandBar:Controls:Add( 1, ID_ADDTAB, "Add" )
oGroups = oMenu:CommandBar:Controls:Add( 3, 0, "Groups" )
oGroups:CommandBar:Controls:Add( 1, ID_ADDGROUP, "Add" )
oControls = oMenu:CommandBar:Controls:Add( 3, 0, "Controls" )
oControls:CommandBar:Controls:Add( 1, ID_ADDBUTTON, "Add Button" )
ACTIVATE WINDOW oWnd
return nil
function RibbonBarEvent( cEvent, aParams )
local oControl, oTab, oGroup, oItem
do case
case cEvent == "Execute"
oControl = aParams[ 1 ]
do case
case oControl:Id == ID_ADDTAB
oControl = oRb:InsertTab( oRb:TabCount + 1, "Tab " + AllTrim( Str( oRb:TabCount + 1 ) ) )
oControl:Id = oRb:TabCount
oControl:Selected = .T.
case oControl:Id == ID_ADDGROUP
if oRb:TabCount > 0
oGroup = oRb:SelectedTab:Groups:AddGroup( "Group " + AllTrim( Str( oRb:SelectedTab:Groups:GroupCount + 1 ) ),;
( oRb:SelectedTab:Index * 10 ) + oRb:SelectedTab:Groups:GroupCount + 1 )
endif
case oControl:Id == ID_ADDBUTTON
if oRb:SelectedTab:Groups:GroupCount > 0
oGroup = oRb:FindGroup( ( oRb:SelectedTab:Index * 10 ) + oRb:SelectedTab:Groups:GroupCount )
oItem = oGroup:Add( xtpControlButton, 1, nil )
oItem:Caption = "Button " + AllTrim( Str( oGroup:Count ) )
endif
otherwise
if ! Empty( oControl:Caption )
MsgInfo( oControl:Caption )
endif
endcase
endcase
return nil