Page 1 of 1

How to convert VB "set" function to Fivewin

Posted: Tue Apr 10, 2007 9:00 am
by dixonchu
How to convert VB "set" function to Fivewin

VB sample code


'Declare a Ribbon Bar object
Dim RibbonBar As RibbonBar

'Add a Ribbon Bar to the command bars
Set RibbonBar = CommandBars.AddRibbonBar("Ribbon Bar")

'Specify the Ribbon Bar is to use the stretched docking style. The Ribbon Bar
'can only be docked to the top or bottom of an application
RibbonBar.EnableDocking xtpFlagStretched

Dim ControlFile As CommandBarPopup

'Add a normal popup to the Ribbon Bar.

Set ControlFile = RibbonBar.Controls.Add(xtpControlPopup, -1, "&File", 1)

'Add commands to the popup
With ControlFile.CommandBar.Controls
.Add xtpControlButton, ID_FILE_NEW, "&New"
.Add xtpControlButton, ID_FILE_OPEN, "&Open..."
Set Control = .Add(xtpControlButton, ID_APP_EXIT, "E&xit")
Control.BeginGroup = True
End With

.......

could anyone help me convert the following code to fivewin

1. Set RibbonBar = CommandBars.AddRibbonBar("Ribbon Bar")
2. Set ControlFile = RibbonBar.Controls.Add(xtpControlPopup, -1, "&File", 1)


Thanks !!!

Posted: Tue Apr 10, 2007 9:47 am
by Antonio Linares
Dixon,

Assuming that CommandBars is an ActiveX object:

>1. Set RibbonBar = CommandBars.AddRibbonBar("Ribbon Bar")

local hRibbonBar := CommandBars:Do( "AddRibbonBar", "RibbonBar" )

> 2. Set ControlFile = RibbonBar.Controls.Add(xtpControlPopup, -1, "&File", 1)

local hControls := OleGetProperty( hRibbonBar, "Controls" )
local hControlFile := OleInvoke( hControls, "Add", xtpControlPopup, -1, "&File", 1)

Posted: Wed Apr 11, 2007 1:49 am
by dixonchu
Dear Antonio

It's very kindly of you to help me out

1. Set RibbonBar = CommandBars.AddRibbonBar("Ribbon Bar")
2. Set ControlFile = RibbonBar.Controls.Add(xtpControlPopup, -1, "&File", 1)

It's ok now

But I still have problem for the following commands
Could you help me this AGAIN !

'Add commands to the popup
With ControlFile.CommandBar.Controls
.Add xtpControlButton, ID_FILE_NEW, "&New"
.Add xtpControlButton, ID_FILE_OPEN, "&Open..."
Set Control = .Add(xtpControlButton, ID_APP_EXIT, "E&xit")
Control.BeginGroup = True
End With

Thank you very much !

Best regards !

Dixon Chu

Posted: Wed Apr 11, 2007 12:55 pm
by Antonio Linares
Dixon,

> With ControlFile.CommandBar.Controls

local hCommandBar := OleGetProperty( hControlFile, "CommandBar" )
local hControls := OleGetProperty( hCommandBar, "Controls" )

Its easy :-)

Posted: Wed Apr 11, 2007 4:38 pm
by Taiwan
Antonio Linares wrote:Dixon,

> With ControlFile.CommandBar.Controls

local hCommandBar := OleGetProperty( hControlFile, "CommandBar" )
local hControls := OleGetProperty( hCommandBar, "Controls" )

Its easy :-)
Hello Antonio,

Could you try to convert these code to FWH?

Code: Select all

Private Sub CommandBars_Execute(ByVal Control As XtremeCommandBars.ICommandBarControl)
    Select Case Control.Id
        Case ID_APP_ABOUT:     MsgBox "Version " & App.Major & "." & App.Minor & "." & App.Revision
        Case ID_FILE_NEW:       MsgBox Control.Caption & " Clicked"
        Case ID_FILE_OPEN:      MsgBox Control.Caption & " Clicked"
        Case ID_FILE_CLOSE:     MsgBox Control.Caption & " Clicked"
        Case ID_FILE_SAVE:      MsgBox Control.Caption & " Clicked"
        
        Case ID_APP_EXIT:      Unload Me
        
        Case ID_VIEW_STATUS_BAR:
            CommandBars.StatusBar.Visible = Not CommandBars.StatusBar.Visible
            CommandBars.RecalcLayout
       
        Case ID_EDIT_CUT:
            Clipboard.SetText txtClient.SelText
            txtClient.SelText = vbNullString
        Case ID_EDIT_COPY:      Clipboard.SetText txtClient.SelText
        Case ID_EDIT_PASTE:     txtClient.SelText = Clipboard.GetText
        Case Else:
            MsgBox Control.Caption & " clicked", vbOKOnly, "Button Clicked"
    End Select
End Sub
Thank you.

Regards,

Richard

Posted: Wed Apr 11, 2007 5:04 pm
by Antonio Linares
Richard,

Code: Select all

function CommandBars_Execute( hControl )

   do case
        case OleGetProperty( hControl, "Id" ) == ID_APP_ABOUT
            ...
   endcase

return nil

Posted: Wed Apr 11, 2007 10:17 pm
by Taiwan
Antonio Linares wrote:Richard,

Code: Select all

function CommandBars_Execute( hControl )

   do case
        case OleGetProperty( hControl, "Id" ) == ID_APP_ABOUT
            ...
   endcase

return nil
Hello Antonio,

How to put this function when we clicked?

Code: Select all

local hControls := OleGetProperty( hRibbonBar, "Controls" ) 
local hControlFile := OleInvoke( hControls, "Add", xtpControlPopup, -1, "&File", 1)
But I don't understand, how to Execute when I clicked someone menuitem or ToolBar's button?

Regards,

Richard

Posted: Thu Apr 12, 2007 5:01 am
by dixonchu
Antonio

It's OK now , Thanks

Best Regards

Dixon Chu

Posted: Fri Apr 13, 2007 8:44 am
by dixonchu
Dear Antonio

Could you help me again !

How to conver VB "AddHandle" to FWH

StatusBar = CommandBars.StatusBar
AddHandler StatusBar.PaneClick, AddressOf StatusBar_PaneClickEvent

Thanks again !

Dixon Chu

Posted: Fri Apr 13, 2007 10:38 am
by Antonio Linares
Dixon,

AddHandler looks like an event response.

Please review samples\webexp.prg to see how to manage ActiveX events