en Misceláneos

Harbour y OCX

/*
    Demo uso de OCX SkinCrafter
    NOTA: Boton derecho en ejecutable, compatibilidad, 
    ejecutar el programa como administrador.
*/

#include "oohg.ch"

FUNCTION Main()

  Local aSkins := Directory( ".\Skins\*.Skf" )
  Local aItems := {}
  Local nCont

  Public oSkin

    If Empty( aSkins )
        Aadd( aItems, {""} )
    EndIf

    For nCont := 1 To Len( aSkins )
        Aadd( aItems, { aSkins[nCont][1] } )
    Next

    InitOcx()
    CreateObjSkin()

    aLic := { "SKINCRAFTER", ;
              "SKINCRAFTER.COM", ;
              "[email protected]", ;
              "DEMOSKINCRAFTERLICENCE" }

    oSkin:InitLicenKeys(aLic[1],aLic[2],aLic[3],aLic[4])
    oSkin:DefineLanguage(0)
    oSkin:InitDecoration(1)

    InitSkin( aItems[1][1] )

    Define Window Win_0 At 0, 0 ;
           Width 640 Height 480 ;
           Title 'ooHG with SkinCrafter by MigSoft' ;
           Icon "Skin" Main Nomaximize ;
           On Release ExitOcx()

        @ 160,   4 Frame frame_1 Caption '' ;
                   Width 330 Height 280

        @ 180,  13 Grid grid_1 Width 310 ;
                   Height 250 Headers {'Skin'} ;
                   Widths {285} Items aItems Value 1 ;
                   On DblClick Aplica()

        @ 20,  360 Label lbl_1 Value 'Etiqueta' AutoSize

        @ 15,  417 TextBox cTexto  Value "TextBox"   ;
                   Width 200 Height 022
        @ 60,  360 CheckBox lCheck Caption 'Checkbox';
                   Width 100 Height 20
        @ 60,  530 DatePicker date_1                 ;
                   Width 90  Height 20
        @ 100, 360 ProgressBar progress_1 Value 33   ;
                   Width 260 Height 20
        @ 150, 380 MonthCalendar month_1

        @ 400, 360 Button btn_2 Caption '&Aplicar' ;
                   Action Aplica() ;
                   Width 70 Height 20
        @ 400, 450 Button btn_1 Caption '&Salir'   ;
                   Action Win_0.Release() ;
                   Width 70 Height 20
        @ 400, 540 Button btn_3 Caption '&Mensaje' ;
                   Action MsgInfo( "Saludos cordiales" ) ;
                   Width 70 Height 20

        @ 7,9 FRAME frame_2 CAPTION "" ;
              WIDTH 190 HEIGHT 95 ;

        Win_0.frame_1.fontcolor := {0,0,0}
        Win_0.frame_1.fontname  := 'MS Sans Serif'
        Win_0.frame_1.fontsize  := 10

        @ 15,  208 LISTBOX list_1 WIDTH  98 HEIGHT 110 ;
                   FONT 'MS Sans Serif' ;
                   ITEMS { 'Harbour','xHarbour' } SIZE 10 ;

        Win_0.list_1.fontcolor  := {0,0,0}
        Win_0.list_1.backcolor  := {255,255,255}

        @ 135,  16 BUTTON button_1 CAPTION 'Normal' ;
                   ACTION msginfo('Button pressed') ;
                   WIDTH 70 HEIGHT 20 ;
                   FONT 'MS Sans Serif' SIZE 10 ;

        Win_0.button_1.fontcolor:={0,0,0}

        @ 135, 126 BUTTON button_2 ;
            CAPTION 'Focused' ;
            ACTION msginfo('Button pressed') ;
            WIDTH 70 ;
            HEIGHT 20 ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.button_2.fontcolor:={0,0,0}

        @ 135, 236 BUTTON button_3 ;
            CAPTION 'HightLight' ;
            ACTION msginfo('Button pressed') ;
            WIDTH 70 ;
            HEIGHT 20 ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.button_3.fontcolor:={0,0,0}

        @ 25,  15 TEXTBOX text_1 ;
            HEIGHT 24 ;
            WIDTH 90 ;
            Font 'MS Sans Serif' ;
            size 10 ;
            VALUE "TextBox";
            MAXLENGTH 20 ;

        Win_0.text_1.fontcolor:={0,0,0}
        Win_0.text_1.backcolor:={255,255,255}

        @ 60,  15 COMBOBOX combo_1 ;
            WIDTH  90 ;
            FONT 'MS Sans Serif' ;
            ITEMS {"GUI 1","GUI 2","GUI 3"} ;
            VALUE 2 ;
            SIZE 10 ;

        Win_0.combo_1.fontcolor:={0,0,0}
        Win_0.combo_1.backcolor:={255,255,255}

        @ 18, 110 CHECKBOX checkbox_1 ;
            CAPTION 'Check' ;
            WIDTH 80 ;
            HEIGHT 28;
            VALUE .F. ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.checkbox_1.fontcolor:={0,0,0}

        @ 46, 110 RADIOGROUP radiogroup_1 ;
            OPTIONS  {'option 1','option 2'}  ;
            VALUE 1 ;
            WIDTH  80 ;
            SPACING  25 ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.radiogroup_1.fontcolor:={0,0,0}

        @ 110, 13 PROGRESSBAR progressbar_1 ;
            RANGE 1,100 ;
            VALUE 35;
            WIDTH 186 ;
            HEIGHT 18 ;

        Win_0.progressbar_1.fontcolor:={0,0,0}
        Win_0.progressbar_1.backcolor:={255,255,255}

    End Window

    Center   Window Win_0
    Activate Window Win_0

RETURN .T.


Static Function Aplica()

Local aRenglon:=Win_0.grid_1.Item( Win_0.grid_1.Value )

    InitSkin( aRenglon[1] )

Return .T.

Function InitSkin( cSkin )

    oSkin:LoadSkinFromFile( ".\Skins\" + cSkin )
    oSkin:ApplySkin()

Return .T.

Function InitOcx()

    Execute File ;
    "regsvr32 /s .\SkinCrafter3_vs2012.Dll" ;
    Wait Minimize

Return .T.

Function ExitOcx()

    Execute File ;
    "regsvr32 /s /u .\SkinCrafter3_vs2012.Dll" ;
    Wait Minimize

Return .T.

Function CreateObjSkin()

    Local cOcxFileName := "SkinCrafter.SCSkin3"

    OCX_bSaveHandler := errorblock( { |x| break(x) } )
    BEGIN SEQUENCE
          oSkin := GetActiveObject( cOcxFileName )
    RECOVER USING oError
          OCX_Error = oError:genCode
    END
    errorblock( OCX_bSaveHandler )

    if OCX_Error != 0
       OCX_bSaveHandler := errorblock( { |x| break(x) } )
       BEGIN SEQUENCE
             oSkin := CreateObject( cOcxFileName )
       RECOVER USING oError
             MsgStop( 'SkinCrafter DLL not available or '+ ;
             'insufficient permissions !!!', 'Warning...' )
             ExitOcx()
             RETURN .F.
       END
       errorblock( OCX_bSaveHandler )
     endif

Return .T.