Hace tiempo que he querido empezar a desarrollar plantillas de desarrollo de distintos temas y que, con el aporte de todos, podamos llegar a concluir una plantilla, completa, y que sirva de ejemplo y manual para cualquiera que necesite utilizarla.
Quisiera empezar con el tema del uso de Excel dentro de una aplicación con Fivewin, ya que es un tema que siempre me ha llamado la atención, y que me ha dado, y me sigue dando, muchos dolores de cabeza, y no he conseguido implementarla con la calidad con la que utilizamos otros controles.
Espero que con la ayuda de todos, podamos completarla y dejar una herramienta de calidad y muy útil
Adjunto un programa, que considero suficiente para poder empezar
Por favor, ayuda
English
friends
I have long wanted to start developing templates development of different themes and with the contribution of all, we can come to conclude a template, complete, and serve as an example and manual for anyone who needs to use it.
Let me begin with the issue of using Excel within an application Fivewin as it is a subject that has always caught my attention, and that has given me and still gives me many headaches, and I have not managed to implement the quality with which we use other controls.
I hope that with everyone's help, we can complete and leave a quality tool and very useful
Please, help
Attached program, which I consider sufficient to start
-------------------------------------------------------------------------------------------------------------------------
1.- Seleccionar opcion "Archivo" en el menu de Excel. No respeta dimensiones del control en el que se ubica.
Select "File" menu in Excel. Not respect dimensions of control in which it is located.
Code: Select all
#include "Fivewin.ch"
#include "Splitter.ch"
//----------------------------------------------------------------------------//
REQUEST DBFCDX
#define LWIDTH 364
Static oWnd
Static oMsgBar
Static oBar
Static oVSplitL
Static oPnelCtrlL
Static oPnelCtrlR
Static oExcel, oBook
Static oBrw
//----------------------------------------------------------------------------//
Function Main()
local oSay
local nSize := 32
local cPanel := "TPanel()" // "TScrollPanel()"
DEFINE WINDOW oWnd //SIZE 600, 400
DEFINE BUTTONBAR oBar SIZE nSize, nSize OF oWnd NOBORDER 2015 //COLOR CLR_HGRAY
DEFINE BUTTON OF oBar ;
PROMPT "Exit" ACTION ( if( !Empty( oExcel ), ( oBook:Close(), oExcel:Quit(), oExcel := nil ), ), DbCloseAll(), oWnd:End() ) ;
TOOLTIP FWString( "Exit" )
DEFINE BUTTON OF oBar GROUP ;
PROMPT "Show" ACTION ( oVSplitL:SetPosition( LWIDTH - 4 ), ;
oPnelCtrlL:Show(), ; //oVSplitL:Adjust(), ;
oSay:Refresh() ) ;
TOOLTIP FWString( "Show" )
DEFINE BUTTON OF oBar ;
PROMPT "Hide" ACTION ( oPnelCtrlL:Hide(), ;
oVSplitL:SetPosition( 0 ) ) ; //oVSplitL:Adjust() ) ;
TOOLTIP FWString( "Hide" )
DEFINE BUTTON OF oBar GROUP ;
PROMPT "Show 2" ACTION ( oPnelCtrlL:Show(), ;
oSay:Refresh() ) ;
TOOLTIP FWString( "Show 2" )
DEFINE BUTTON OF oBar ;
PROMPT "Hide 2" ACTION ( oPnelCtrlL:Hide() ) ;
TOOLTIP FWString( "Hide 2" )
DEFINE MSGBAR oMsgBar OF oWnd PROMPT "Editor" 2015
oPnelCtrlL := &(cPanel):New( if( !Empty( oBar ), oBar:nBottom + 6, 2 ), ;
4, ;
ScreenHeight() - 6 - if( !Empty( oMsgBar ), oMsgBar:nHeight(), 2 ), ;
LWIDTH - 8, ;
oWnd )
oPnelCtrlL:SetColor( CLR_MAGENTA, CLR_GRAY )
oPnelCtrlL:bRClicked := { | o | MsgInfo( "1" ) }
//oPnelCtrlL:nOpacity := 128
oPnelCtrlR := &(cPanel):New( if( !Empty( oBar ), oBar:nBottom + 6, 2 ), ;
LWIDTH + 2, ;
ScreenHeight() - 6 - if( !Empty( oMsgBar ), oMsgBar:nHeight(), 2 ), ;
ScreenWidth() - 4, ; // - LWIDTH - 8, ;
oWnd )
oPnelCtrlR:SetColor( CLR_MAGENTA, CLR_HGRAY )
oPnelCtrlR:bRClicked := { | o | MsgInfo( "2" ) }
//oPnelCtrlL:nOpacity := 128
@ if( !Empty( oBar ), oBar:nBottom + 4, 2 ), LWIDTH - 4 SPLITTER oVSplitL ;
VERTICAL ;
PREVIOUS CONTROLS oPnelCtrlL ;
HINDS CONTROLS oPnelCtrlR ;
LEFT MARGIN 0 ;
RIGHT MARGIN 8 ;
SIZE 2, ScreenHeight() - if( !Empty( oBar ), oBar:nBottom + 10, 0 ) - ;
if( !Empty( oMsgBar ), oMsgBar:nHeight(), 2 ) ;
COLOR CLR_RED ;
PIXEL OF oWnd
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT ( MyBrowse(), ;
MyExcel(), ;
oPnelCtrlL:bResized := { || oBrw:AdjClient() } ) ;
ON RESIZE ( oVSplitL:AdjLeft() )
Return nil
//----------------------------------------------------------------------------//
Function MyExcel()
local oHoja
local oObject
local oQ
local cSource
local lSw := .T.
TRY
oExcel = GetActiveObject( "Excel.Application" )
CATCH
TRY
oExcel = CreateObject("Excel.Application")
CATCH
MsgInfo("Excel is not installed on this PC. You need Excel to continue")
lSw := .F.
END
END
if lSw
oExcel := CreateObject( "Excel.Application" )
oBook := oExcel:WorkBooks:Add()
oHoja := oExcel:ActiveSheet()
oExcel:Visible := .T.
oExcel:DisplayAlerts := .F.
SetParent( oExcel:hWnd, oPnelCtrlR:hWnd )
endif
Return lSw
//----------------------------------------------------------------------------//
Function MyBrowse()
local cAlias
Select( 1 )
Use Customer
cAlias := Alias()
@ 1, 1 XBROWSE oBrw DATASOURCE cAlias OF oPnelCtrlL PIXEL
oBrw:CreateFromCode()
Return nil
//----------------------------------------------------------------------------//