Un ejemplo de cómo convertir un menu en un Tree
En este ejemplo, pinto el menú, pero no es necesario, evidentemente
Se olvidó incluirlo en la versión actual
( Sólo funciona a partir de la versión 18.02 )
An example of how to convert a menu into a Tree
In this example, I paint the menu, but it's not necessary, obviously
He forgot to include it in the current version
(It only works from version 18.02)
Code: Select all
//----------------------------------------------------------------------------//
// Test make tree from menu
// 28/01/2018
// Cristobal Navarro
//----------------------------------------------------------------------------//
#include "fivewin.ch"
Static oFont
Static oFontMenu
Static oWnd
Static nItCheck := 2
//----------------------------------------------------------------------------//
function Main()
Local cFont := "Segoe UI"
Local cFontH := -12
local oMnu
local oBrw
local oTreeMnu
DEFINE FONT oFont NAME "Segoe UI SEMILIGHT" SIZE 0, -14
DEFINE FONT oFontMenu NAME cFont SIZE 0, cFontH WEIGHT 300
//oMnu := MakeMenu()
DEFINE WINDOW oWnd TITLE "Test Make Tree From Menu" FROM 0, 0 TO 600, 800 ;
MENU MakeMenu() ;
PIXEL //STYLE WS_POPUP
oWnd:SetFont( oFont )
oWnd:SetColor( CLR_WHITE, Rgb( 240, 240, 240 ) )
oTreeMnu := oWnd:oMenu:MnuTree()
//oTreeMnu := oMnu:MnuTree()
@ 05, 05 XBROWSE oBrw SIZE 300, -10 OF oWnd ;
DATASOURCE oTreeMnu CELL LINES NOBORDER PIXEL
WITH OBJECT oBrw
:nMarqueeStyle := MARQSTYLE_HIGHLROW
:lrecordselector := .F.
:lHeader := .F.
:lFooter := .F.
:lHScroll := .F.
:lVScroll := .F.
:SetFont( oFont )
:nRowHeight := Int( Abs( oFont:nHeight * 2.4 ) )
:nColDividerStyle := 0
:nRowDividerStyle := 0
:bClrStd := { || { Rgb( 255, 255, 255 ), Rgb( 88, 88, 88 ) } }
:bClrSelFocus := { || { Rgb( 255, 255, 255 ), Rgb( 000, 152, 218 ) } }
:SetColor( Rgb( 255, 255, 255 ), Rgb( 88, 88, 88 ) )
:aCols[ 1 ]:AddBitmap( { 0xe127, 0xe1D2, 0xe1F5 } )
:CreateFromCode()
END
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
RELEASE FONT oFontMenu
return nil
//----------------------------------------------------------------------------//
function MakeMenu()
local oMenu, oMnu1, oMnu11, oMnu2, oMnu3
local oIt4
MENU oMenu 2013 FONT oFontMenu COLORLEFT CLR_BLUE, Rgb( 248, 248, 240 ) ;
COLORSELECT CLR_WHITE, CLR_WHITE, CLR_BROWN
MENUITEM FWVERSION + ": " DISABLED FILE "https://ssl.gstatic.com/gb/images/a/f420d06f66.png"
MENUITEM "One"
MENU oMnu1
MENUITEM "Sunday" CHECKED
MENUITEM SEPARATOR Upper( "Select" )
MENUITEM "Monday" + CRLF + "Other" BOLD RADIOCHECK 3, 2
MENUITEM "Tuesday" ACTION MsgInfo( "Hola" )
MENUITEM "Wednesday"
SEPARATOR
MENUITEM "Thursday" FILE "https://ssl.gstatic.com/gb/images/a/dfbeb24785.png"
MENU oMnu11
MENUITEM "Saturday"
ENDMENU
SEPARATOR
MENUITEM "Exit" ACTION WndMain():End()
ENDMENU
MENUITEM "Tree"
MENU oMnu2
MENUITEM "Dialog Tree" CHARICON 57699 ACTION MenuTree( oWnd:oMenu ) BOLD
SEPARATOR
MENUITEM "None" CHARICON 57698
ENDMENU
MENUITEM "Other"
MENU oMnu3
MENUITEM "Sunday" CHARICON 57696
SEPARATOR
MENUITEM "Monday" CHARICON 57697
ENDMENU
oMenu:AddHelp( , , , , , .F. )
MENUITEM "&" FILE "https://ssl.gstatic.com/gb/images/a/f420d06f66.png" HELP
MENU
MENUITEM "Day" CHARICON 57696
SEPARATOR
MENUITEM "Month" CHARICON 57697
SEPARATOR
MENUITEM "Year" CHARICON 57697
ENDMENU
MENUITEM "&" FILE "https://www.gstatic.com/images/branding/product/1x/gmail_16dp.png" HELP
MENU
MENUITEM "Sunday" CHARICON 57696
SEPARATOR
MENUITEM "Monday" CHARICON 57697
ENDMENU
MENUITEM "&" FILE "https://www.google.com/images/icons/product/calendar-16.png" HELP ACTION MsgInfo( FWVERSION )
MENU
MENUITEM "Sunday" CHARICON 57696
SEPARATOR
MENUITEM "Monday" CHARICON 57697
ENDMENU
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function MenuTree( oMenu )
local oDlg, oTree
DEFINE DIALOG oDlg SIZE 400, 400 TITLE "TreeView From Menu"
oDlg:lTruePixel := .T.
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oTree := oMenu:MnuToTreeV( oDlg, 1, 2, 370, 180 ), ;
oTree:SetFont( oFont ) )
return oTree
//----------------------------------------------------------------------------//
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.