FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Codejock RibbonBar first tests
Posts: 866
Joined: Tue Oct 16, 2007 08:57 AM
Re: Codejock RibbonBar first tests
Posted: Fri Apr 03, 2009 02:15 PM

Hi Antonio,

I post my last paste picture below source code.

Thanks post my code.

Regards,

Richard

Best Regards,



Richard



Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 32bit

MySQL v8.0

Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 64bit
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Fri Apr 03, 2009 02:17 PM

Richard,

Ok, thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Fri Apr 03, 2009 03:11 PM
A very early Visual RibbonBar designer prototype. The idea is to interactively desing the RibbonBar and than its source code could be automatically generated:

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

static oRb

function Main()

   local oWnd, oAct, oMenu, aControls := {}

   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, pParams | RibbonBarEvent( cEvent, aParams, pParams, aControls ) }

   oAct:Do( "AttachToWindow", oWnd:hWnd )

   oRb = oAct:Do( "AddRibbonBar", "fwh" )

   oMenu = oRb:Controls:Add( 2, 0, "Menu" )
   oMenu:Flags = 1  && xtpFlagRightAlign

   oTabs = oMenu:CommandBar:Controls:Add( 2, 0, "Tabs" )
   AAdd( aControls, oTabs:CommandBar:Controls:Add( 1, 3000, "Add" ) )

   oGroups = oMenu:CommandBar:Controls:Add( 3, 0, "Groups" )
   AAdd( aControls, oGroups:CommandBar:Controls:Add( 1, 4000, "Add" ) )

   ACTIVATE WINDOW oWnd

return nil

function RibbonBarEvent( cEvent, aParams, pParams, aControls )

   local oTab 

   static nTab := 1, nGroup := 1

   do case
      case cEvent == "Execute" .and. Len( aControls ) > 0
           do case
              case aControls[ 1 ]:hObj == aParams[ 1 ]
                   oTab = oRb:InsertTab( nTab, "Tab " + AllTrim( Str( nTab++ ) ) )
                   oTab:Selected = .T.

              case aControls[ 2 ]:hObj == aParams[ 1 ]
                   MsgInfo( "Insert Group" )

           endcase
   endcase
   
return nil

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Fri Apr 03, 2009 05:52 PM
Visual RibbonBar: Dynamically adding tabs and groups

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

static oRb

function Main()

   local oWnd, oAct, oMenu, aControls := {}

   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, pParams | RibbonBarEvent( cEvent, aParams, pParams, aControls ) }

   oAct:Do( "AttachToWindow", oWnd:hWnd )

   oRb = oAct:Do( "AddRibbonBar", "fwh" )

   oMenu = oRb:Controls:Add( 2, 0, "Menu" )
   oMenu:Flags = 1  && xtpFlagRightAlign

   oTabs = oMenu:CommandBar:Controls:Add( 2, 0, "Tabs" )
   AAdd( aControls, oTabs:CommandBar:Controls:Add( 1, 3000, "Add" ) )

   oGroups = oMenu:CommandBar:Controls:Add( 3, 0, "Groups" )
   AAdd( aControls, oGroups:CommandBar:Controls:Add( 1, 4000, "Add" ) )

   ACTIVATE WINDOW oWnd

return nil

function RibbonBarEvent( cEvent, aParams, pParams, aControls )

   local oTab 

   do case
      case cEvent == "Execute" .and. Len( aControls ) > 0
           do case
              case aControls[ 1 ]:hObj == aParams[ 1 ]
                   oTab = oRb:InsertTab( oRb:TabCount + 1, "Tab " + AllTrim( Str( oRb:TabCount + 1 ) ) )
                   oTab:Selected = .T.

              case aControls[ 2 ]:hObj == aParams[ 1 ]
                   if oRb:TabCount > 0
                      oRb:SelectedTab:Groups:AddGroup( "&Group", Len( oRb:SelectedTab:Groups ) + 1 )
                   endif 

           endcase
   endcase
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Fri Apr 03, 2009 07:15 PM
Visual RibbonBar: enhanced version

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

static oRb

function Main()

   local oWnd, oAct, oMenu, aControls := {}

   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, pParams | RibbonBarEvent( cEvent, aParams, pParams, aControls ) }

   oAct:Do( "AttachToWindow", oWnd:hWnd )

   oRb = oAct:Do( "AddRibbonBar", "fwh" )

   oMenu = oRb:Controls:Add( 2, 0, "Menu" )
   oMenu:Flags = 1  && xtpFlagRightAlign

   oTabs = oMenu:CommandBar:Controls:Add( 2, 0, "Tabs" )
   AAdd( aControls, oTabs:CommandBar:Controls:Add( 1, 3000, "Add" ) )

   oGroups = oMenu:CommandBar:Controls:Add( 3, 0, "Groups" )
   AAdd( aControls, oGroups:CommandBar:Controls:Add( 1, 4000, "Add" ) )

   ACTIVATE WINDOW oWnd

return nil

function RibbonBarEvent( cEvent, aParams, pParams, aControls )

   local oTab 

   do case
      case cEvent == "Execute" .and. Len( aControls ) > 0
           do case
              case aControls[ 1 ]:hObj == aParams[ 1 ]
                   oTab = oRb:InsertTab( oRb:TabCount + 1, "Tab " + AllTrim( Str( oRb:TabCount + 1 ) ) )
                   oTab:Selected = .T.

              case aControls[ 2 ]:hObj == aParams[ 1 ]
                   if oRb:TabCount > 0
                      oRb:SelectedTab:Groups:AddGroup( "Group " + AllTrim( Str( oRb:SelectedTab:Groups:GroupCount + 1 ) ),;
                                                       oRb:SelectedTab:Groups:GroupCount + 1 )
                   endif   

           endcase
   endcase
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 01:32 AM
Visual RibbonBar: adding controls (buttons), developed together with Daniel :-)

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

#define xtpControlButton     1

static oRb

function Main()

   local oWnd, oAct, oMenu, oGroups, oControls, aControls := {}

   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, pParams | RibbonBarEvent( cEvent, aParams, pParams, aControls ) }

   oAct:Do( "AttachToWindow", oWnd:hWnd )

   oRb = oAct:Do( "AddRibbonBar", "fwh" )

   oMenu = oRb:Controls:Add( 2, 0, "Menu" )
   oMenu:Flags = 1  && xtpFlagRightAlign

   oTabs = oMenu:CommandBar:Controls:Add( 2, 0, "Tabs" )
   AAdd( aControls, oTabs:CommandBar:Controls:Add( 1, 3000, "Add" ) )

   oGroups = oMenu:CommandBar:Controls:Add( 3, 0, "Groups" )
   AAdd( aControls, oGroups:CommandBar:Controls:Add( 1, 4000, "Add" ) )

   oControls = oMenu:CommandBar:Controls:Add( 3, 0, "Controls" )
   AAdd( aControls, oControls:CommandBar:Controls:Add( 1, 5000, "Add Button" ) )

   ACTIVATE WINDOW oWnd

return nil

function RibbonBarEvent( cEvent, aParams, pParams, aControls )

   local oTab, oGroup, oControl 

   do case
      case cEvent == "Execute" .and. Len( aControls ) > 0
           do case
              case aControls[ 1 ]:hObj == aParams[ 1 ]
                   oTab = oRb:InsertTab( oRb:TabCount + 1, "Tab " + AllTrim( Str( oRb:TabCount + 1 ) ) )
                   oTab:Id = oRb:TabCount
                   oTab:Selected = .T.

              case aControls[ 2 ]:hObj == aParams[ 1 ]
                   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 aControls[ 3 ]:hObj == aParams[ 1 ]
                   if oRb:SelectedTab:Groups:GroupCount > 0
                      oGroup = oRb:FindGroup( ( oRb:SelectedTab:Index * 10 ) + oRb:SelectedTab:Groups:GroupCount )
                      oControl = oGroup:Add( xtpControlButton, 1, nil )
                      oControl:Caption = "Button " + AllTrim( Str( oGroup:Count ) )
                   endif   

           endcase
   endcase
   
return nil

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 07:42 AM
Hi ,

Anybody here tried to run the generated Sample Exe on a PC other than the Development PC (ie On a PC where the CodeJock Setup is not installed).

For me it is giving the following error.


Regards

Anser
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 08:33 AM
Anser,

I think that first you have to register the ActiveX as an administrator. But not 100% sure about it.

Also, you can check if the ActiveX is available before using it:
Code (fw): Select all Collapse
if ! IsActiveX( "Codejock.CommandBars.v13.0.0.ocx" )
   MsgStop( "ActiveX missing" )
   return nil
endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 09:26 AM
Dear Mr.Antonio,

I think that first you have to register the ActiveX as an administrator. But not 100% sure about it.


I am testing the problem in Win XP as Administrator.

Another Problem which I have seen is that IsActivex() is always returning .F.
Code (fw): Select all Collapse
If IsActivex("Codejock.CommandBars.v12.1.1.ocx")
    MsgInfo("Activex is already Registerd")
else // If not registered then Display the msg and REgister the OCX
    MSgInfo("Activex is NOT Registerd, Now it will Register")  // This line is getting executed
    RegisterServer( "Codejock.CommandBars.v12.1.1.ocx" ) 
Endif

// After REsgisterServer, IsActivex() should return .T., but it is returning .F.
If IsActivex("Codejock.CommandBars.v12.1.1.ocx")
    MSgInfo("Activex is Successful")
else
    MSgInfo("Unable to register the Activex") // This line is getting executed
endif
The OCX contorl and my Test.Exe is available in the Same folder

To re-check, I manually registered the OCX Control and run the Test.Exe again, but the fuction IsActivex() is always returning .F.

I can't understand where I have gone wrong ?

Regards

Anser
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 02:50 PM
Anser,

Please call this function CoInitialize() before calling IsActiveX( cProgId ):
Code (fw): Select all Collapse
#pragma BEGINDUMP

#include <hbapi.h>

unsigned long CoInitialize( void * );

HB_FUNC( COINITIALIZE )
{
   hb_retnl( CoInitialize( NULL ) );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 08:02 PM
Anser,

perhaps you have the same problem on some machines as I, so here my solution:

What happens: By executing the method 'AttachToWindow', the RibbonBar begins to fire events, so the code block 'RibbonBarEvent' will be executed and failed 'in the line 'case cEvent == "Execute"' with the error '==' because <cEvent> is numerical!

Solution: Put in the following code:
Code (fw): Select all Collapse
function RibbonBarEvent( cEvent, aParams, pParams, aButtons, oWnd )

    IF Valtype( cEvent ) == "N"
       DO CASE
          CASE cEvent == 1
            cEvent := "Execute"
          OTHERWISE
            cEvent := ""
       ENDCASE
   ENDIF


HTH
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 09:09 PM

Fafi,

you can assign a code block to <oact:bOnEvent>. When an event in the RibbonBar occurs, this code block will be executed. If a button was clicked by the user, the variable <cEvent> has 'normally' the value "Execute". All buttons resides in the array <aButtons>, if 'aButtons[ 1 ]:hObj == aParams[ 1 ]' you know which button was pressed!

I really want to know, how Lailton, Richard, or who else has discovered this know how, compliments to them. Perhaps I have to read the Codejack help file more systematically :wink:

BTW, sometimes <cEvent> is numerical, if so on your machine, the code crashes the first time (after 'AttachToWindow') your code block is executed!

Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Sat Apr 04, 2009 09:18 PM

Frank,

> I really want to know, how Lailton, Richard, or who else has discovered this know how

You can inspect all properties, methods and events from Microsoft Word VBA:

viewtopic.php?p=78087#p78087

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Codejock RibbonBar first tests
Posted: Mon Apr 06, 2009 06:22 AM
Dear Mr. Frank,

I tried your solution but did not work. My app is crashing when it reaches the point

Code (fw): Select all Collapse
oAct := TActiveX():New( oWnd, "Codejock.CommandBarsFrame.12.1.1", 0, 0, 0, 0 )


I tried to check the ValType of cEvent, but the application crashes before reaching that point

Code (fw): Select all Collapse
Function RibbonBarEvent( cEvent, aParams, pParams, aButtons )
MsgInfo(ValType(cEvent))


Dear Mr.Antonio,

As suggested by you I tried CoInitialize() before calling IsActiveX( cProgId ) but still IsActivex() is always returning .F.

I tried a utility named RegDllView, to check whether the OCX is registered, and it shows that the OCX is regsitered in the system. I am using Windows XP SP3

I tested this in 2 other Win XP Pc's and 1 Windows 7 PC.

I even doubt the licence issue as said in this thread viewtopic.php?f=3&t=13351
I am looking for a code to pass the licence key when the contols are used in Client PC (when we use the control on a PC where the CodeJock setup.exe is not installed). In the write up it is said that the valid license key should be used on Form Initialiase using the property GlobalSetting:Licence of the CodeJock Control, but the app is crashing before I can access the Property's of the Control at TActivex initialize itself

Thanks & REgards

Anser
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Codejock RibbonBar first tests
Posted: Mon Apr 06, 2009 07:10 AM

Anser,

Are you using 12.1.1 or 13.0.0 ?

Have you tried both ?

regards, saludos

Antonio Linares
www.fivetechsoft.com