Codejock RibbonBar first tests

Re: Codejock RibbonBar first tests

Postby richard-service » Fri Apr 03, 2009 2: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 (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Fri Apr 03, 2009 2:17 pm

Richard,

Ok, thanks :-)
regards, saludos

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

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Fri Apr 03, 2009 3: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: Select all  Expand view

#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            
 

Image
regards, saludos

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

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Fri Apr 03, 2009 5:52 pm

Visual RibbonBar: Dynamically adding tabs and groups

RibbonBar.prg
Code: Select all  Expand view

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

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Fri Apr 03, 2009 7:15 pm

Visual RibbonBar: enhanced version

RibbonBar.prg
Code: Select all  Expand view

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

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Sat Apr 04, 2009 1:32 am

Visual RibbonBar: adding controls (buttons), developed together with Daniel :-)

RibonBar.prg
Code: Select all  Expand view

#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            
 

Image
regards, saludos

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

Re: Codejock RibbonBar first tests

Postby anserkk » Sat Apr 04, 2009 7: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.
Image

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Sat Apr 04, 2009 8: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: Select all  Expand view

if ! IsActiveX( "Codejock.CommandBars.v13.0.0.ocx" )
   MsgStop( "ActiveX missing" )
   return nil
endif
 
regards, saludos

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

Re: Codejock RibbonBar first tests

Postby anserkk » Sat Apr 04, 2009 9: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: Select all  Expand view
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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Sat Apr 04, 2009 2:50 pm

Anser,

Please call this function CoInitialize() before calling IsActiveX( cProgId ):
Code: Select all  Expand view

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

Re: Codejock RibbonBar first tests

Postby frose » Sat Apr 04, 2009 8: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: Select all  Expand view
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
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Codejock RibbonBar first tests

Postby frose » Sat Apr 04, 2009 9: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
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Sat Apr 04, 2009 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Codejock RibbonBar first tests

Postby anserkk » Mon Apr 06, 2009 6:22 am

Dear Mr. Frank,

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

Code: Select all  Expand view
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: Select all  Expand view
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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Codejock RibbonBar first tests

Postby Antonio Linares » Mon Apr 06, 2009 7:10 am

Anser,

Are you using 12.1.1 or 13.0.0 ?

Have you tried both ?
regards, saludos

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

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 43 guests