A css treeview on VFP form

Published on by Yousfi Benameur

A css treeview on VFP form



-This code builds a web (only css) treeview on a vfp browser olecontrol and makes the clicked  links working in vfp environments.
All links are redirected from the browser before navigate2 method.
Some links are coded to  visual samples for demo on the form.
Treeview can be expanded or collapsed, can install a fontname,set the background backcolor or the forecolor of the treeview.
i set 4 styles (can switch and even change) and can customize many params in the ybuild method.
you can also customize the icon(whose group 3 icons in one png as currently made on web).

The treeview is fasted rebuild like as clicking on any vfp form button .It can be usefully for users to build their projects easily.

Select code (CTRL+C) and save as a prg and run.

See some screenshots below.
*Css is from this site : http://www.thecssninja.com/css/css-tree-menu

*Can read also this article:http://yousfi.over-blog.com/2015/01/a-vfp-treeview-with-background-image.html

 

This page was last updated on : dimanche 22 février 2015; 21:19:04

 

*Begin code

Set Safe Off
Set Defa To Addbs(Justpath(Sys(16,1)))

*create the 3 treeview icons (in one png)
Local m.ypict
TEXT to m.ypict noshow
iVBORw0KGgoAAAANSUhEUgAAABAAAACgCAYAAAAFOewUAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAApxJREFUeNrslM1u00AQgGdthyalFFOK+ClIIKQKyqUVQvTEE3DmAhLwAhU8QZoH4A2Q2gMSFace4MCtJ8SPBFwAkRuiHKpA6sRN/Lu7zG5i14kctaUqRGhGXnu9O/Pt7MzsMiklvF+9t2kWTDvyIrAsA0aKRRi1T0C/hJ4LUbt5/8rNpWVlp8RSr9J40b48fxFaTQ9+ft8EZ6MJYb0Ok+dnYGpmPgXwKIAvLx8vYXc5GdMAQJgQEkpjRTh36TS2U+DWW/D17WuYgm8pwJyY1npZsZKOxImOV1I/h4+O6vEg5GCZBpgmA6hX8wHKUHDRBXQYicQ4rlc3Tf0VMs8DHBS864F2YFspjgUYjKX/Az3gsdQd2eeBHwmdGWXHcgBGSkZXOXohcEXebRoQcAgjqediNY+AVyu3Z3sAKqfKoGMsewBeEIOPgQxxPJIjcGH6qtL/0AdADzKGnuuD+2tLK7Q8DhHHbOBW+KEzcHLuYc82MkEUekLiwuvVH+guQBQzOG4XdAb8EOcRcqQvDkY2iCLuxECJ43JobMXoutqGgDa2T7UqLKwt9KRyuxKVByqVXXqIoCCUCAqhUOioTWC7G4TQEOD0APy2/7G2Xpu1J4+lxeQ4TXBbITDpoVelRN/BVFbwu5oMMJUBhoXy5tmdRcMwymP2OLQaLjx9/vnBo6V3K6izATmSnMa0Dq7ferIohJhr1p01zrlz49rZF4OMs8JkX23vVQzYp+wbYGV/KpXKjvspl8tsIKCrMNAYFxj2GKS5ZWxg4ewKsJfaGMIY5KXqPz8LBBj6+yDvVP79+yDp/9F9oIx3OisHWwe7Oal0HxCAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgwD8E/BZgAP0qhKj3rXO7AAAAAElFTkSuQmCC
ENDTEXT
=Strtofile(Strconv(m.ypict,14),"icons.png")


Publi yform
yform=Newobject("ytreeview")
yform.Show
Read Events
Return
*
Define Class ytreeview As Form
    Height = 652
    Width = 967
    ShowWindow = 2
    ShowTips = .T.
    AutoCenter = .T.
    Caption = "A web css treeview on a vfp form"
    MinWidth = 850
    BackColor = Rgb(223,223,255)
    xcolor = .F.
    xbgcolor = .F.
    xbold = .F.
    yurl = .F.
    xpict = .F.
    xfont = .F.
    Name = "Form1"

    Add Object olecontrol1 As OleControl With ;
        oleclass="shell.explorer.2",;
        Top = 5, ;
        Left = 2, ;
        Height = 583, ;
        Width = 286, ;
        Name = "Olecontrol1"

    Add Object optiongroup1 As OptionGroup With ;
        AutoSize = .T., ;
        ButtonCount = 5, ;
        Anchor = 768, ;
        BackStyle = 0, ;
        Value = 1, ;
        Height = 27, ;
        Left = 88, ;
        Top = 623, ;
        Width = 95, ;
        Name = "Optiongroup1", ;
        Option1.Caption = "", ;
        Option1.Value = 1, ;
        Option1.Height = 17, ;
        Option1.Left = 5, ;
        Option1.Top = 5, ;
        Option1.Width = 18, ;
        Option1.AutoSize = .T., ;
        Option1.Name = "Option1", ;
        Option2.Caption = "", ;
        Option2.Height = 17, ;
        Option2.Left = 21, ;
        Option2.Top = 5, ;
        Option2.Width = 18, ;
        Option2.AutoSize = .T., ;
        Option2.Name = "Option2", ;
        Option3.Caption = "", ;
        Option3.Height = 17, ;
        Option3.Left = 37, ;
        Option3.Top = 5, ;
        Option3.Width = 18, ;
        Option3.AutoSize = .T., ;
        Option3.Name = "Option3", ;
        Option4.Caption = "", ;
        Option4.Height = 17, ;
        Option4.Left = 55, ;
        Option4.Top = 5, ;
        Option4.Width = 18, ;
        Option4.AutoSize = .T., ;
        Option4.Name = "Option4", ;
        Option5.Caption = "", ;
        Option5.Height = 17, ;
        Option5.Left = 72, ;
        Option5.Top = 5, ;
        Option5.Width = 18, ;
        Option5.AutoSize = .T., ;
        Option5.Name = "Option5"

    Add Object check1 As Checkbox With ;
        Top = 628, ;
        Left = 184, ;
        Height = 17, ;
        Width = 18, ;
        Anchor = 768, ;
        AutoSize = .T., ;
        Alignment = 0, ;
        BackStyle = 0, ;
        Caption = "", ;
        Value = 0, ;
        MousePointer = 15, ;
        ToolTipText = "FontBold", ;
        Name = "Check1"

    Add Object olecontrol2 As OleControl With ;
        oleclass="MSComCtl2.MonthView.2",;
        Top = 89, ;
        Left = 333, ;
        Height = 216, ;
        Width = 215, ;
        Visible = .F., ;
        Name = "Olecontrol2"

    Add Object olecontrol3 As OleControl With ;
        oleclass="MSComCtl2.DTPicker.2",;
        Top = 125, ;
        Left = 555, ;
        Height = 73, ;
        Width = 229, ;
        Visible = .F., ;
        Name = "Olecontrol3"

    Add Object olecontrol4 As OleControl With ;
        oleclass="shell.explorer.2",;
        Top = 293, ;
        Left = 309, ;
        Height = 289, ;
        Width = 409, ;
        Visible = .F., ;
        Anchor = 15, ;
        Name = "Olecontrol4"


    Add Object ycmd1 As CommandButton With ;
        AutoSize = .T., ;
        Top = 624, ;
        Left = 0, ;
        Height = 27, ;
        Width = 45, ;
        FontBold = .T., ;
        Anchor = 768, ;
        Caption = "Bcol", ;
        MousePointer = 15, ;
        ToolTipText = "Treeview Backcolor", ;
        BackColor = Rgb(0,255,0), ;
        Name = "ycmd1"

    Add Object ycmd2 As CommandButton With ;
        AutoSize = .T., ;
        Top = 625, ;
        Left = 45, ;
        Height = 27, ;
        Width = 43, ;
        FontBold = .T., ;
        Anchor = 768, ;
        Caption = "Fcol", ;
        MousePointer = 15, ;
        ToolTipText = "Treeview Forecolor", ;
        BackColor = Rgb(0,255,0), ;
        Name = "ycmd2"

    Add Object ycmd3 As CommandButton With ;
        Top = 624, ;
        Left = 202, ;
        Height = 25, ;
        Width = 37, ;
        FontBold = .T., ;
        Anchor = 768, ;
        Caption = "Font", ;
        ToolTipText = "Select fontname only", ;
        BackColor = Rgb(255,128,0), ;
        Name = "ycmd3"

    Add Object check2 As Checkbox With ;
        Top = 628, ;
        Left = 244, ;
        Height = 17, ;
        Width = 36, ;
        FontBold = .T., ;
        Anchor = 768, ;
        AutoSize = .T., ;
        Alignment = 0, ;
        BackStyle = 0, ;
        Caption = "E/C", ;
        ToolTipText = "Expand/collapse treeview", ;
        Name = "Check2"

    Procedure ybuild

 

        Local m.myvar
        TEXT to m.myvar textmerge noshow

<!DOCTYPE html>
<html lang="en-US">
    <head>
        <meta charset="utf-8" />
        <title>CSS3 Treeview. No JavaScript by Martin Ivanov</title>
        <style>
        /*
         * CSS3 Treeview. No JavaScript
         * @version 1.0
         * @author Martin Ivanov
         * @url developer's website: http://wemakesites.net/
         * @url developer's twitter: https://twitter.com/#!/wemakesitesnet
         * @url developer's blog http://acidmartin.wordpress.com/
         * This solution works with all modern browsers and Internet Explorer 9+.
         **/
        .css-treeview ul,

        .css-treeview li
        {
            padding: 0;
            margin: 0;
            list-style: none;
        }

        .css-treeview input
        {
            position: absolute;
            opacity: 0;

        }

        .css-treeview
        {
        font: normal 12px  "<<thisform.xfont>>",;
"Segoe UI", Arial, Sans-serif;
            <<thisform.xbold>>
            color:<<thisform.xcolor>>;
            -moz-user-select: none;
            -webkit-user-select: none;
            user-select: none;
        }

        .css-treeview a
        {
            color:<<thisform.xcolor>>;
            text-decoration: none;
        }

        .css-treeview a:hover
        {
            text-decoration: underline;
        }

        .css-treeview input + label + ul
        {
            margin: 0 0 0 22px;
        }

        .css-treeview input ~ ul
        {
            display: none;
        }

        .css-treeview label,
        .css-treeview label::before
        {
            cursor: pointer;
        }

        .css-treeview input:disabled + label
        {
            cursor: default;
            opacity: .6;
        }

        .css-treeview input:checked:not(:disabled) ~ ul
        {
            display: block;
        }

        .css-treeview label,
        .css-treeview label::before
        {
            background: url("icons.png") no-repeat;
        }

        .css-treeview label,
        .css-treeview a,
        .css-treeview label::before
        {
            display: inline-block;
            height: 16px;
            line-height: 16px;,
            vertical-align: middle;
        }

        .css-treeview label
        {   color:<<thisform.xcolor>>;
            background-position: 18px 0;
        }

        .css-treeview label::before
        {
            content: "";
            width: 16px;
            margin: 0 22px 0 0;
            vertical-align: middle;
            background-position: 0 -32px;
        }

        .css-treeview input:checked + label::before
        {
            background-position: 0 -16px;
        }

        /* webkit adjacent element selector bugfix */
        @media screen and (-webkit-min-device-pixel-ratio:0)
        {
            .css-treeview
            {
                -webkit-animation: webkit-adjacent-element-selector-bugfix infinite 1s;
            }

            @-webkit-keyframes webkit-adjacent-element-selector-bugfix
            {
                from
                {
                    padding: 0;
                }
                to
                {
                    padding: 0;
                }
            }
        }


.h1 {
  text-shadow: 0 1px 0 #ccc,
               0 2px 0 #c9c9c9,
               0 3px 0 #bbb,
               0 4px 0 #b9b9b9,
               0 5px 0 #aaa,
               0 6px 1px rgba(0,0,0,.1),
               0 0 5px rgba(0,0,0,.1),
               0 1px 3px rgba(0,0,0,.3),
               0 3px 5px rgba(0,0,0,.2),
               0 5px 10px rgba(0,0,0,.25),
               0 10px 10px rgba(0,0,0,.2),
               0 20px 20px rgba(0,0,0,.15);
  text-align: center;
}
        </style>
    </head>
    <body  bgcolor=<<thisform.xbgcolor>>  oncontextmenu="return false;" >

    <div style="cursor:pointer;"><a href="yvfp:/0"><img id="img" src="file:///<<thisform.xpict>>"  title="About.." width="36"  height="36" align="right" ></a>
    <p class="h1">Ycss_treeview </p>
    </div>
       <br> <br>

        <div class="css-treeview"  >

            <ul>
                <li><input type="checkbox" id="item-0" /><label for="item-0">This Folder is Closed By Default</label>
                    <ul>
                        <li><input type="checkbox" id="item-0-0" /><label for="item-0-0">Ooops! A Nested Folder</label>
                            <ul>
                                <li><input type="checkbox" id="item-0-0-0" /><label for="item-0-0-0">Look Ma - No Hands!</label>
                                    <ul>
                                        <li><a href="yvfp:/1">First Nested Item-grid</a></li>
                                        <li><a href="yvfp:/2">Second Nested Item-Editbox</a></li>
                                        <li><a href="yvfp:/3">Third Nested Item-Image</a></li>
                                        <li><a href="yvfp:/4">Fourth Nested Item-olecontrol</a></li>
                                    </ul>
                                </li>
                                <li><a href="yvfp:/5">Item 1-olecontrol</a></li>
                                <li><a href="yvfp:/6">Item 2-Foxite</a></li>
                                <li><a href="yvfp:/7">Item 3-My Blog</a></li>
                            </ul>
                        </li>
                        <li><input type="checkbox" id="item-0-1" /><label for="item-0-1">Yet Another One</label>
                            <ul>
                                <li><a href="yvfp:/8">item-Google</a></li>
                                <li><a href="yvfp:/9">item-Explorer</a></li>
                                <li><a href="yvfp:/10">item-MsPaint</a></li>
                                <li><a href="yvfp:/11">item-Firefox</a></li>
                                <li><a href="yvfp:/12">item-Acrobat</a></li>
                                <li><a href="yvfp:/13">item-SnippingTool</a></li>
                                <li><a href="yvfp:/14">item</a></li>
                                <li><a href="yvfp:/15">item</a></li>
                            </ul>
                        </li>
                        <li><input type="checkbox" id="item-0-2" disabled="disabled" /><label for="item-0-2">Disabled Nested Items</label>
                            <ul>
                                <li><a href="yvfp:/16">item</a></li>
                                <li><a href="yvfp:/17">item</a></li>
                                <li><a href="yvfp:/18">item</a></li>
                                <li><a href="yvfp:/19">item</a></li>
                                <li><a href="yvfp:/20">item</a></li>
                                <li><a href="yvfp:/21">item</a></li>
                                <li><a href="yvfp:/22">item</a></li>
                                <li><a href="yvfp:/23">item</a></li>
                            </ul>
                        </li>
                        <li><a href="yvfp:/24">item</a></li>
                        <li><a href="yvfp:/25">item</a></li>
                        <li><a href="yvfp:/26">item</a></li>
                        <li><a href="yvfp:/27">item</a></li>
                    </ul>
                </li>
                <li><input type="checkbox" id="item-1" checked="checked" /><label for="item-1">This One is Open by Default...</label>
                    <ul>
                        <li><input type="checkbox" id="item-1-0" /><label for="item-1-0">And Contains More Nested Items...</label>
                            <ul>
                                <li><a href="yvfp:/28">ABOUT...</a></li>
                                <li><a href="yvfp:/29">Another Item</a></li>
                                <li><a href="yvfp:/30">And Yet Another</a></li>
                            </ul>
                        </li>
                        <li><a href="yvfp:/31">Lorem</a></li>
                        <li><a href="yvfp:/32">Ipsum</a></li>
                        <li><a href="yvfp:/33">Form Titlebar on/off</a></li>
                        <li><a href="yvfp:/34">Sit Amet-message</a></li>
                    </ul>
                </li>
                <li><input type="checkbox" id="item-2" /><label for="item-2">Can You Believe...</label>
                    <ul>
                        <li><input type="checkbox" id="item-2-0" /><label for="item-2-0">That This Treeview...</label>
                            <ul>
                                <li><input type="checkbox" id="item-2-2-0" /><label for="item-2-2-0">Does Not Use Any JavaScript...</label>
                                    <ul>
                                        <li><a href="yvfp:/35">But Relies Only</a></li>
                                        <li><a href="yvfp:/36">On the Power</a></li>
                                        <li><a href="yvfp:/37">Of CSS3</a></li>
                                    </ul>
                                </li>
                                <li><a href="yvfp:/38">Item 1</a></li>
                                <li><a href="yvfp:/39">Item 2</a></li>
                                <li><a href="yvfp:/40">Item 3</a></li>
                            </ul>
                        </li>
                        <li><input type="checkbox" id="item-2-1" /><label for="item-2-1">This is a Folder With...</label>
                            <ul>
                                <li><a href="yvfp:/41">Some Nested Items...</a></li>
                                <li><a href="yvfp:/42">Some Nested Items...</a></li>
                                <li><a href="yvfp:/43">Some Nested Items...</a></li>
                                <li><a href="yvfp:/44">Some Nested Items...</a></li>

                            </ul>
                        </li>
                        <li><input type="checkbox" id="item-2-2" disabled="disabled" /><label for="item-2-2">Disabled Nested Items</label>
                            <ul>
                                <li><a href="yvfp:/">item</a></li>
                                <li><a href="yvfp:/">item</a></li>
                                <li><a href="yvfp:/">item</a></li>
                                <li><a href="yvfp:/">item</a></li>
                                <li><a href="yvfp:/">item</a></li>
                                <li><a href="yvfp:/">item</a></li>
                                <li><a href="yvfp:/">item</a></li>
                                <li><a href="yvfp:/">Item</a></li>
                            </ul>
                        </li>
                        <li><input type="checkbox" id="item-2-3" /><label for="item-2-3">This is a Folder With...</label>
                            <ul>
                                <li><a href="yvfp:/45">E X I T </a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </body>
</html>
        ENDTEXT
        Local m.lcdest
        m.lcdest=Addbs(Sys(2023))+"ytree.html"

        Strtofile(m.myvar,m.lcdest)
        Try
            Copy File "icons.png" To Sys(2023)  &&mandatory to see icons on treeview
        Catch
        Endtry

        With Thisform
            .olecontrol1.Navigate(m.lcdest)
            .Resize()
        Endwith

    Endproc

    Procedure yactions

        Messagebox("yactions..."+Thisform.yurl,;
            0+32+4096,"",800)

        #Define yerror "An error was ccured"
        If !Thisform.yurl==[yvfp:/29]
            Try
                For i=1 To Thisform.ControlCount
                    If !Inlist( Lower(Thisform.Controls(i).Name),"olecontrol1","olecontrol2" ,"olecontrol3","olecontrol4","optiongroup1","ycmd1","ycmd2","ycmd3","check1","check2")
                        Thisform.RemoveObject(Thisform.Controls(i).Name)
                        DoEvent
                    Endi
                Endfor
            Catch
            Endtry
            With Thisform
                .olecontrol2.Visible=.F.
                .olecontrol3.Visible=.F.
                .olecontrol4.Visible=.F.
            Endwith
        Endi

        Thisform.Refresh

        Do Case
            Case  Thisform.yurl==[yvfp:/0]
                Local m.about
                TEXT to m.about noshow
 this code build a  web oly css treeview on a vfp browser olecontrol and
 makes tghe links working in vfp environments.
all links are redirected from the browser befornavigate2 method
Some links are coded to a visual sample on the form.
Treeview can be expanded or collapsed, can install a fontname,set the background
backcolor or the forecolor of the treeview.
 i set 4 styles (can switch and even change) and can customize many params in the ybuild method.
you can also customize the icon(whose group 3 icons in one png as currently made on web).

        Author: Yousfi Benameur  El Bayadh Algeria<br>
                21 february 2015<br>
                ENDTEXT
                Messagebox(m.about,0+32+4096,"About...")

            Case Thisform.yurl==[yvfp:/1]
                Select * From (Home(1)+"samples\data\customer.dbf") Into Cursor ycurs
                Thisform.AddObject("grid1","grid")
                With Thisform.grid1
                    .RecordSource="ycurs"
                    .Left=Thisform.olecontrol1.Left+Thisform.olecontrol1.Width+5
                    .Top=10
                    .Width=630
                    .Height=400
                    .Themes=.F.
                    .Anchor=15
                    .GridLines=0
                    .DeleteMark=.F.
                    .HeaderHeight=22
                    .SetAll("DynamicBackColor", "IIF(MOD(RECNO( ), 2)=0, RGB(255,255,255), RGB(216,252,218))", "Column")
                    .SetAll("fontsize",12,"header")
                    For i=1 To .ColumnCount
                        .Columns(i).header1.BackColor=Rgb(255*Rand(),255*Rand(),255*Rand())
                    Endfor
                    .Visible=.T.
                    .Refresh
                    Locate
                Endwith

            Case Thisform.yurl==[yvfp:/2]
                Thisform.AddObject("edit1" ,'editbox')
                With Thisform.edit1
                    .Top=10
                    .Left=Thisform.olecontrol1.Left+Thisform.olecontrol1.Width+5
                    .Width=670
                    .Height=350
                    .ForeColor=Rgb(0,255,0)
                    .BackColor=Rgb(10,100,95)
                    .FontSize=11
                    .Alignment=0
                    .Anchor=15
                    TEXT to .value noshow
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel risus eget lorem feugiat
        fermentum nec a turpis. Phasellus purus sem, mollis ac posuere eget, ornare vel orci. Sed ac rutrum
        nulla. Aenean ultrices eget lectus eu efficitur. In hac habitasse platea dictumst. Nulla in iaculis nisi.
        Nullam et pulvinar tellus. Donec arcu dui, efficitur a odio non, porta congue dolor. Aenean viverra
        auctor sagittis. Integer lobortis dignissim auctor. Proin et volutpat massa.
        Cras vitae felis venenatis, egestas sem quis, sodales neque. Donec venenatis hendrerit odio, non
        pellentesque metus scelerisque ac. Suspendisse aliquet rhoncus odio id viverra. Vestibulum feugiat
        lectus a nisl pulvinar, in tempor metus eleifend. Nunc id odio quam. Praesent egestas lorem ut
        sollicitudin consectetur. Vestibulum id bibendum est. Ut vel lacus sapien. Quisque eget molestie
        sem. Integer eget purus eu orci molestie aliquam quis in ante. Integer a magna eget lectus finibus
        porttitor. Donec fringilla sapien a quam aliquet, pellentesque blandit nisl placerat. Nam hendrerit
        velit vel ex aliquam, eget convallis ante mollis.
                    ENDTEXT
                    .Visible=.T.
                Endwith

            Case Thisform.yurl==[yvfp:/3]
                Thisform.AddObject("image1" ,'image')
                With Thisform.image1
                    .Picture=Getpict()
                    If Empty(.Picture)
                        Return .F.
                    Endi
                    .Stretch=2
                    .Left=Thisform.olecontrol1.Width+1
                    .Top=10
                    .Width=Thisform.Width-Thisform.olecontrol1.Width-20
                    .Height=Thisform.Height-20
                    .Anchor=15
                    .Visible=.T.
                Endwith

            Case Thisform.yurl==[yvfp:/4]
                Thisform.olecontrol2.Visible=.T.

            Case Thisform.yurl==[yvfp:/5]
                Thisform.olecontrol3.Visible=.T.
                Thisform.olecontrol3.SetFocus
                Local oshell
                oshell=Newobject("wscript.shell")
                oshell.sendkeys("%{DOWN}")

            Case Thisform.yurl==[yvfp:/6]
                With Thisform.olecontrol4
                    Try
                        .Navigate("www.foxite.com")
                        .Visible=.T.
                    Catch
                    Endtry
                Endwith

            Case Thisform.yurl==[yvfp:/7]
                With Thisform.olecontrol4
                    Try
                        .Navigate("http://yousfi.over-blog.com/")
                        .Visible=.T.
                    Catch
                    Endtry
                Endwith

            Case Thisform.yurl==[yvfp:/8]
                With Thisform.olecontrol4
                    Try
                        .Navigate("www.google.com")
                        .Visible=.T.
                    Catch
                    Endtry
                Endwith

            Case Thisform.yurl==[yvfp:/9]
                Run /N explorer

            Case Thisform.yurl==[yvfp:/10]
                Run /N mspaint


            Case Thisform.yurl==[yvfp:/11]

                If  ! ShellExecute(0, "open", "firefox.exe","","",1)>32
                    Messagebox(yerror,16+4096,1000)
                Endi

            Case Thisform.yurl==[yvfp:/12]
                If !ShellExecute(0, "open", "acroRd32.exe","","",1)>32
                    Messagebox(yerror,16+4096,1000)
                Endi

            Case Thisform.yurl==[yvfp:/13]
                Try
                    Run/N snippingtool
                Catch
                    Messagebox(yerror,16+4096,1000)
                Endtry


            Case Thisform.yurl==[yvfp:/28]
                Thisform.yurl=[yvfp:/0]
                Thisform.yactions()
                Try
                    Set Bell To (Addbs(Getenv('windir')))+"MEDIA\Windows Notify Email.WAV"
                    ?? Chr(7)
                Catch
                Endtry

            Case Thisform.yurl==[yvfp:/33]
                With Thisform
                    Do Case
                        Case  .TitleBar=1
                            .TitleBar=0
                            .Height=.Height+Sysmetric(9)+Sysmetric(4)
                        Case  .TitleBar=0
                            .TitleBar=1
                            .Height=.Height-Sysmetric(9)-Sysmetric(4)
                    Endcase
                Endwith

            Case Thisform.yurl==[yvfp:/34]
                Local m.myvar
                TEXT to m.myvar noshow
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel risus eget lorem feugiat
        fermentum nec a turpis. Phasellus purus sem, mollis ac posuere eget, ornare vel orci. Sed ac rutrum
        nulla. Aenean ultrices eget lectus eu efficitur. In hac habitasse platea dictumst. Nulla in iaculis nisi.
        Nullam et pulvinar tellus. Donec arcu dui, efficitur a odio non, porta congue dolor. Aenean viverra
        auctor sagittis. Integer lobortis dignissim auctor. Proin et volutpat massa.
        Cras vitae felis venenatis, egestas sem quis, sodales neque. Donec venenatis hendrerit odio, non
        pellentesque metus scelerisque ac. Suspendisse aliquet rhoncus odio id viverra. Vestibulum feugiat
        lectus a nisl pulvinar, in tempor metus eleifend. Nunc id odio quam. Praesent egestas lorem ut
        sollicitudin consectetur. Vestibulum id bibendum est. Ut vel lacus sapien. Quisque eget molestie
        sem. Integer eget purus eu orci molestie aliquam quis in ante. Integer a magna eget lectus finibus
        porttitor. Donec fringilla sapien a quam aliquet, pellentesque blandit nisl placerat. Nam hendrerit
        velit vel ex aliquam, eget convallis ante mollis.
        Maecenas molestie erat sit amet molestie tempor.
                ENDTEXT
                Messagebox(m.myvar,"summary help",0+32+4096)

            Case Thisform.yurl==[yvfp:/45]
                Thisform.Release

            Otherwise

                Thisform.AddObject("command1" ,'commandbutton')
                With Thisform.command1
                    .Picture=Home()+"graphics\bitmaps\assorted\beany.bmp"
                    .PicturePosition=7
                    .SpecialEffect=0
                    .Width=320
                    .Height=200
                    .Caption="add some codes and some actions with "+Thisform.yurl +" in form.yactions method!"
                    .WordWrap=.T.
                    .FontSize=20
                    .ForeColor=Rgb(255*Rand(),255*Rand(),255*Rand())
                    .FontBold=.T.
                    .MousePointer=15
                    Local gnUpper,gnLower
                    gnUpper=Thisform.Width-Thisform.olecontrol1.Width
                    gnLower=Thisform.olecontrol1.Width+1
                    .Left=Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)
                    gnUpper=Thisform.Height-.Height
                    gnLower=1
                    .Top=Int((gnUpper - gnLower + 1) * Rand( ) + gnLower)
                    .AutoSize=.T.
                    .Visible=.T.
                    .SetFocus
                    .Click()
                Endwith
        Endcase
    Endproc

    Procedure yrgb2html
        Lparameters tnColor
        Local loColor
        loColor = Createobject("Empty")
        AddProperty(loColor, "nR", Bitand(tnColor, 0xFF))
        AddProperty(loColor, "nG", Bitand(Bitrshift(tnColor, 8), 0xFF))
        AddProperty(loColor, "nB", Bitand(Bitrshift(tnColor, 16), 0xFF))
        AddProperty(loColor, "cHTMLcolor", Strtran("#" + ;
            TRANSFORM(loColor.nR, "@0") +   ;
            TRANSFORM(loColor.nG, "@0") +   ;
            TRANSFORM(loColor.nB, "@0"), "0x000000", "" ))
        Return loColor.cHtmlColor
    Endproc

    Procedure Destroy
        Try  &&clean traces
            Dele File (Addbs(Sys(2023))+"ytree.html")
            Dele File (Addbs(Sys(2023))+"icons.png")
        Catc
        Endtry
        Set Safe On
        Clea Events
    Endproc

    Procedure Init

        With Thisform
            .xcolor= "#00f"
            .xbgcolor="#DCDCDC"
            .xpict=Home(1)+'graphics\icons\elements\sun.ico'
            .xfont="Segoe UI"
            .ybuild()
        Endwith
    Endproc

    Procedure Resize
        This.olecontrol1.Resize
    Endproc

    Procedure Load
        Declare Integer Sleep In kernel32 Integer

        Declare Integer ShellExecute In SHELL32.Dll Integer nWinHandle,;
            STRING cOperation,;
            STRING cFileName,;
            STRING cParameters,;
            STRING cDirectory,;
            INTEGER nShowWindow
    Endproc

    Procedure olecontrol1.BeforeNavigate2
        *** Événement de contrôle ActiveX  ***
        Lparameters pdisp, url, Flags, targetframename, postdata, headers, Cancel
        Nodefault
        If Lower(Substr(url,1,4))== "yvfp"
            Thisform.yurl=url
            Thisform.yactions()
            Cancel=.T. &&this prevent the browser to do the default action .
            Return .F.
        Endi
    Endproc

    Procedure olecontrol1.Init
        This.silent=.T.
    Endproc

    Procedure olecontrol1.Resize
        With This
            .Left=1
            .Top=1
            .Width=280
            Try  &&if not yet created
                .Height=.Parent.Height-Thisform.optiongroup1.Height-2
            Catch
            Endtry
        Endwith
    Endproc

    Procedure optiongroup1.Init
        With This
            .SetAll("mousepointer",15,"optionbutton")
            .SetAll("tooltiptext","Apply one style for treeview","optionbutton")
        Endwith
    Endproc

    Procedure optiongroup1.Option1.Click
        With Thisform
            .xcolor= "#00008B"
            .xbgcolor="#F0E68C"
            .xpict=Home(1)+'graphics\icons\elements\sun.ico'
            .ybuild()
        Endwith
    Endproc

    Procedure optiongroup1.Option2.Click
        With Thisform
            .xcolor= "#8B0000"
            .xbgcolor="#B0C4DE"
            .xpict=Home(1)+'graphics\icons\elements\snow.ico'
            .ybuild()
        Endwith
    Endproc

    Procedure optiongroup1.Option3.Click
        With Thisform
            .xcolor= "#191970 "
            .xbgcolor="#FFE4B5"
            .xpict=Home(1)+'graphics\icons\win95\mycomp.ico'
            .ybuild()
        Endwith
    Endproc

    Procedure optiongroup1.Option4.Click
        With Thisform
            .xcolor= "#F0FFFF"
            .xbgcolor="    #333333"
            .xpict=Home(1)+'graphics\icons\misc\misc15.ico'
            .ybuild()
        Endwith

    Endproc

    Procedure optiongroup1.Option5.Click
        With Thisform
            .xcolor= "#00008B"
            .xbgcolor="#7FFF00"
            .xpict=Home(1)+'graphics\icons\win95\entirnet.ico'
            .ybuild()
        Endwith
    Endproc

    Procedure check1.Click
        With Thisform
            .xbold=Iif(Thisform.check1.Value=0,"","font-weight: bold;")
            .ybuild()
        Endwith
    Endproc

    Procedure olecontrol3.Init
        With This.Font
            .Size=12
            .bold=.T.
        Endwith
    Endproc

    Procedure olecontrol4.Init
        With This
            .Left=Thisform.olecontrol1.Width+1
            .Top=0
            .Width=Thisform.Width-Thisform.olecontrol1.Width-2
            .Height=Thisform.olecontrol1.Height
        Endwith
    Endproc

    Procedure ycmd1.Click
        Local m.xcolor
        m.xcolor=Getcolor()
        If m.xcolor=-1
            Return .F.
        Endi

        With Thisform
            .xbgcolor=.yrgb2html(m.xcolor)
            .ybuild
        Endwith
    Endproc

    Procedure ycmd2.Click
        Local m.xcolor
        m.xcolor=Getcolor()
        If m.xcolor=-1
            Return .F.
        Endi

        With Thisform
            .xcolor=.yrgb2html(m.xcolor)
            .ybuild
        Endwith
    Endproc

    Procedure ycmd3.Click
        Local xfont
        m.xfont=Getfont()
        If Empty(m.xfont)
            Return .F.
        Endi

        m.xfont=Getwordnum(m.xfont,1,",")

        With Thisform
            .xfont=m.xfont
            .ybuild()
        Endwith
    Endproc

    Procedure check2.InteractiveChange  &&expand/collapse treeview  from vfp
        node_list =Thisform.olecontrol1. Document.getElementsByTagName('input')
        j=0
        For Each Node In  node_list
            If (Node.getAttribute('type') == 'checkbox')
                j=j+1
                Node.checked=Iif(This.Value=0,0,1)
            Endi
        Next
    Endproc

Enddefine
*

*End code

 

A css treeview on VFP form
A css treeview on VFP form
A css treeview on VFP form
A css treeview on VFP form
A css treeview on VFP form
A css treeview on VFP form
A css treeview on VFP form

Published on Visual foxpro, Treeview, CSS

To be informed of the latest articles, subscribe:
Comment on this post