Changing Ribbon on opening a MDI-Child
Posted: Fri Jul 02, 2010 9:17 am
Hi,
when opening a mdi-child I'd like to change the appearance of my ribbon-menu.
I try to redefine my ribbon-menu, but when the menu is being painted, it doesn't look right. A half button appears, but without any functionality.
Is there a malfunction in painting a new ribbon? Or won't this approach work at all?
This is my source code:
when opening a mdi-child I'd like to change the appearance of my ribbon-menu.
I try to redefine my ribbon-menu, but when the menu is being painted, it doesn't look right. A half button appears, but without any functionality.
Is there a malfunction in painting a new ribbon? Or won't this approach work at all?
This is my source code:
Code: Select all
#include "FiveWin.ch"
#INCLUDE "ribbon.CH"
static oWnd, oRb
//----------------------------------------------------------------------------//
function Main()
DEFINE WINDOW oWnd FROM 1, 1 To 42, 105 ;
TITLE "This is a MDI enviroment" MDI VSCROLL
oWnd:bGotFocus := {|| oRb := nil, ribbon_menu() }
oWnd:bInit := {|| oRb := nil, ribbon_menu() }
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
// First MDI-Child
function Create1()
local oWndChild, oIcon
DEFINE ICON oIcon RESOURCE "test"
DEFINE WINDOW oWndChild MDICHILD OF oWnd ICON oIcon
// Build the Ribbon for "MDI1"
oWndChild:bGotFocus = {|| ribbon_menu("mdi1") }
oWndChild:bInit := {|| ribbon_menu("mdi1") }
ACTIVATE WINDOW oWndChild
return nil
// Second MDI-Child
function Create2()
local oWndChild, oIcon
DEFINE ICON oIcon RESOURCE "test"
DEFINE WINDOW oWndChild MDICHILD OF oWnd ICON oIcon
// Build the Ribbon for "MDI2"
oWndChild:bGotFocus = {|| ribbon_menu("mdi2") }
oWndChild:bInit = {|| ribbon_menu("mdi2") }
ACTIVATE WINDOW oWndChild
return nil
FUNCTION Ribbon_Menu(cWindow)
local oGr1, oGr2
local oBackBtn, oBtn[4]
local oBackstage
local aClrMenu1 := { { 0.5, RGB( 69, 124, 188 ), RGB( 41, 93, 171 ) }, { 0.5, RGB( 26, 64, 136 ), RGB( 56, 135, 191 ) } }
local aClrMenu2 := { { 0.5, RGB( 123, 178, 236 ), RGB( 71, 126, 205 ) }, { 0.5, RGB( 17, 78, 175 ), RGB( 128, 225, 255 ) } }
default cWindow := ""
oRb := nil
oRb := TRibbonBar():New(oWnd, {"Folder 1","Folder 2"}, ,,,125,26)
oRb:nLeftMargin = 85 //97
oBackBtn = TRBtn():New( 4, 0, 70, 20, "./../bitmaps/rbnmenu.bmp", { || oRB:Backstage() }, oRB,;
,,,,,, .T., .T.,,,,,, /*"POPUP"*/ , oBackstage,,,,,,,,,,,,, aClrMenu1, nRGB( 125, 172, 215 ),;
nRGB( 65, 106, 189 ) )
ADD GROUP oGr1 RIBBON oRB TO OPTION 1 PROMPT "Group1" WIDTH 140
@ 5,5 ADD BUTTON oBtn[1] PROMPT "Window 1" BITMAP "" GROUP oGr1 ROUND SIZE 63,65 ACTION Create1()
@ 5,70 ADD BUTTON oBtn[2] PROMPT "Window 2" BITMAP "" GROUP oGr1 ROUND SIZE 63,65 ACTION Create2()
// Special Ribbon-Menu for "MDI1"
IF cWindow = "mdi1"
ADD GROUP oGr2 RIBBON oRB TO OPTION 1 PROMPT "Group3b" WIDTH 80
@ 5,5 ADD BUTTON oBtn[3] PROMPT "MDI-button (1)" BITMAP "" GROUP oGr2 ROUND SIZE 63,65 ACTION Msginfo("mdi1 button")
// Special Ribbon-Menu for "MDI2"
ELSEIF cWindow = "mdi2"
ADD GROUP oGr2 RIBBON oRB TO OPTION 1 PROMPT "Group3c" WIDTH 140
@ 5,5 ADD BUTTON oBtn[3] PROMPT "MDI-button (2)" BITMAP "" GROUP oGr2 ROUND SIZE 63,65 ACTION Msginfo("mdi2 button1")
@ 5,70 ADD BUTTON oBtn[4] PROMPT "MDI-button (2)" BITMAP "" GROUP oGr2 ROUND SIZE 63,65 ACTION Msginfo("mdi2 button2")
ENDIF
DEFINE BACKSTAGE oBackstage MAINWIDTH 800
DEFINE BSSELECT OF oBackstage PROMPT "Test1" ACTION Msginfo("Test1")
DEFINE BSSELECT OF oBackstage PROMPT "Test2" ACTION Msginfo("Test2")
SET BACKSTAGE oBackstage TO oRb
oRb:CalcPos()
oRb:Refresh()
return nil
//----------------------------------------------------------------------------//
procedure AppSys // XBase++ requirements
return
//----------------------------------------------------------------------------//