Page 1 of 1

Redawing of a commadnBar

Posted: Mon Jan 17, 2011 11:29 am
by edv-rudrich
Hi..

it#s a little frustrating to try to look behind the architecture of XCodeJock--

I need to change captions and group titles of a commandbar object on-the-fly..

CJAddControl does not allow the use of a codeblock as a caption, so I tried
to use variables instead and try to redraw the complete commandbar with
oCommanBar:RedrawBar()

This fails and error log says. Unknown method for this object..
Documentation of CodeJock says that there IS a method called Redrawbar..

Any help?

- Michael

Re: Redawing of a commadnBar

Posted: Mon Jan 17, 2011 12:08 pm
by Tom
Check your mail. ;)

Re: Redawing of a commadnBar

Posted: Mon Jan 17, 2011 4:28 pm
by rdonnay
Tom -

Michael sent me a private email about this, but I didn't have a quick answer because I have spent so little time with Commandbars.

Thank you for doing my support for me again.

I'm down on the US/Mexico border this week, getting a lot more dental work done, so my wits are not with me at the moment. I had a root canal today and another on Wednesday. I'm glad I brought wine with me.

The temp here today is 85 degrees F.

Roger

Re: Redawing of a commadnBar

Posted: Tue Jan 18, 2011 12:55 am
by edv-rudrich
Roger -

I wonder why the Method RedrawBar() crashes.. this should be a method
of the commandbar object like the documentation says..

- Michael

Re: Redawing of a commadnBar

Posted: Tue Jan 18, 2011 4:56 am
by Tom
Here's some code based on the sample from Chris which works. Calling a menu entry sets the caption of the SLE. Remember to change the version # of CJ.

Code: Select all

///////////////////////////////////////////////////////////////////////////////
//
//  Ribbonbar with Xbase++ and eXPress++
//  Creation date: 12/12/2008
//  Chris Andries - ABO service bvba - Belgium
//
///////////////////////////////////////////////////////////////////////////////

#include "Gra.ch"
#include "Xbp.ch"
#include "Appevent.ch"
#include "Font.ch"
#INCLUDE "dcdialog.CH"
#INCLUDE "commandbars.CH"

//define CommandbarCLSID '{D59F55F6-5C22-4C23-80D6-FED9AD149F2C}'
#define CommandbarCLSID 'Codejock.CommandBars.13.4.0'


PROC appsys ; RETURN

function Main()

LOCAL Getlist[0], Getoptions,  oCommandBar, oStatic, oRibbon, oSearchGroup

@ -1,0 DCACTIVEXCONTROL oCommandbar SIZE 50, 10  ;
      CLSID CommandbarCLSID ;
      EVAL {|o| o:visualtheme := 2, ;
                o:add("commandbar",xtpBarTop) ,;
                ;// o:caption := 'Ribbon Bar Sample', ;
                o:execute := {|o|_execute(o,oStatic,oRibbon,oSearchGroup)}, ;
                _StartRibbon(o,@oRibbon,@oSearchGroup)};
      RESIZE DCGUI_RESIZE_REPOSONLY_Y

@ 9,0 DCSAY '' OBJECT oStatic COLOR GRA_CLR_RED, GRA_CLR_WHITE ;
      SIZE 50, 10 FONT '24.Arial Bold' SAYWORDBREAK ;
      RESIZE DCGUI_RESIZE_RESIZEONLY

DCGETOPTIONS RESIZE

DCREAD GUI TITLE 'CodeJock Command Bar' OPTIONS GetOptions FIT

RETURN nil

* -----------

STATIC FUNCTION _StartRibbon(o,oRibbonBar,oSearchGroup)

Local oControl, oPopUp, oTab1, oTab2, oControlFile

oRibbonBar := o:AddRibbonBar("Ribbonbar1")
oRibbonBar:enableDocking(xtpFlagStretched)

oControlFile := oRibbonBar:AddSystemButton()
oControlFile:IconId := 0
oControlFile:Caption := "&File"
oControlFile:CommandBar:Controls:Add( xtpControlButton, 10, "&New" )
oControlFile:CommandBar:Controls:Add( xtpControlButton, 11, "&Open..." )
oControlFile:CommandBar:Controls:Add( xtpControlButton, 12, "&Save" )
oControlFile:CommandBar:Controls:Add( xtpControlButton, 13, "Save &As..." )

oControl := oRibbonBar:Controls:Add(xtpControlPopup, -1, "&Popup ONE", 1)

oPopUp := oControl:CommandBar:Controls
oPopUp:Add(xtpControlButton, 1, "&Nieuw")
oPopUp:Add(xtpControlButton, 2, "&Edit")

oControl := oPopUP:Add(xtpControlButton, 3, "&Save")
oControl:BeginGroup := .T.

oTab1 := oRibbonBar:InsertTab(0, "&Write")
oTab2 := oRibbonBar:InsertTab(0, "&Read")
oGroup := oTab1:Groups:AddGroup("Group",50)
oSearchGroup := oGroup:Add(xtpControlEdit, 51, "Search:")
oSearchGroup:EditHint := "Enter here..."
oSearchGroup:Width := 100
oSearchGroup:TextLimit := 20
oSearchGroup:Text := Space(20)
oSearchGroup:Enabled := .T.
oSearchGroup:SetProperty("ReadOnly",.F.)

return nil

* ------------

STATIC FUNCTION _execute( oPopup, oStatic, oRibbon,oSearchGroup )

LOCAL cMessage

IF oPopup:id == 1
  cMessage := 'Nieuw from Popup'
ELSEIF oPopup:id == 2
  cMessage := 'Edit from Popup'
ELSEIF oPopup:id == 3
  cMessage := 'Save from Popup'
ELSEIF oPopup:id == 10
  cMessage := 'New from System Menu'
ELSEIF oPopup:id == 11
  cMessage := 'Open from System Menu'
ELSEIF oPopup:id == 12
  cMessage := 'Save from System Menu'
ELSEIF oPopup:id == 13
  cMessage := 'SaveAs from System Menu'
ENDIF

IF !Empty(cMessage) .AND. Valtype(oStatic) == 'O'
  oStatic:setCaption('You selected: ' + cMessage)
  oSearchGroup:Caption := cMessage
  oRibbon:RedrawBar()
  oRibbon:RecalcLayout()
ENDIF

RETURN nil