topic
stringlengths
1
63
text
stringlengths
1
577k
crear LIB desde un PRG
Por favor, Necesito ayuda de los amigos del foro: ¿Cómo puedo crear LIB desde un PRG?
crear LIB desde un PRG
[quote="MGA":osys3axt]Por favor, Necesito ayuda de los amigos del foro: ¿Cómo puedo crear LIB desde un PRG?[/quote:osys3axt] use TLIB.exe [url:osys3axt]https://forums.fivetechsupport.com/viewtopic.php?f=3&t=42147&p=253338&hilit=tlib&sid=7696ee987a3ad8fa749a83c13346b422&sid=4131757af07be1be4ab7aad9d6ad138f#p253338[/url:osys3axt] Regards, saludos.
crear archivo en excel con imagenes
Buenas noches, una consulta Yo he estado creando in infome en Excel usando la clase TXls , ahora necesito ponerne unas imagenes en cieras secciones del reporte Es posible pegar una imagen que la tengo en un archivo "C:\mis fotos\miproducto1.jpg" dentro de un rango de celdas C1:F15 o debere de usar otra clase, (esto es para Office 2010 en adelante, y los reprtes son extensos) Les agradecere sus comentarios , Muchas gracias Lubin
crear archivo en excel con imagenes
Hola Lubin Echale un ojo a esto: [code=fw:1wigtuob]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #B900B9;">//---------------------------</span><br /><span style="color: #B900B9;">/*FORMATOS EXCEL<br />// Line styles<br />#define xlContinuous 1<br />#define xlDash -4115<br />#define xlDashDot 4<br />#define xlDashDotDot 5<br />#define xlDot -4118<br />#define xlDouble -4119<br />#define xlSlantDashDot 13<br />#define xlLineStyleNone -4142<br /><br /><br />// Border positions<br />#define xlEdgeLeft 7<br />#define xlEdgeTop 8<br />#define xlEdgeBottom 9<br />#define xlEdgeRight 10<br /><br />oExcel := CreateObject( "Excel.Application" )<br />oExcel:WorkBooks:Add()<br />oAS := oExcel:ActiveSheet()<br />oAs:Range( "C10" ):Value := "Marco"<br />oAs:Range( "C10" ):Borders( xlEdgeTop ):LineStyle := xlContinuous<br /><br />oHoja:Rows( 2 ):Font:Bold := .T.<br /><br />oHoja:Cells( 1, 4 ):Value := AMPAarra[2][3][1][13]<br /><br />oHoja:Cells( 2, 1 ):AddComment()<br />oHoja:Cells( 2, 1 ):Comment:Text := "la data, fechita"<br /><br />oHoja:Columns( 1 ):Set( "NumberFormat", "#,##0" )<br /><br />oHoja:Columns( (nContador + 1 ) ):NumberFormat := "#.##0"<br /><br />oHoja:Columns( (nContador + 1 ) ):NumberFormat := Lower( Set( _SET_DATEFORMAT ) )<br />oHoja:Columns( (nContador + 1 ) ):HorizontalAlignment := - 4152 //xlRight<br />oHoja:Cells( nFound, 3 ):HorizontalAlignment := - 4108 //Centrat<br />oHoja:Columns( (nContador + 1 ) ):Set( "NumberFormat", "@" )<br /><br />oHoja:Cells( nFound, nCol ):Borders():LineStyle := 1<br />oHoja:Cells( nFound, nCol ):Borders( 8 ):LineStyle := 1<br /><br />oHoja:Cells( nLinea, 3 ):AddComment()<br />oHoja:Cells( nLinea, 3 ):Comment:Text( AllTrim(oTdbfFamili:Obsefact) )<br /><br />oHoja:Columns( 1 ):ColumnWidth := 6<br />oHoja:Columns( 2 ):ColumnWidth := 12<br />oHoja:Columns( 3 ):ColumnWidth := 10.5<br /><br />oHoja:Cells( nLinea + 2, 8 ):NumberFormat := "#.##0,00"<br /><br />oHoja:Cells( nLinea, 4 ):Font:Italic := .T.<br /><br /><br />oHoja:Cells:Font:Name := "Arial" // ESPECIFICA TIPO DE LETRA PARA TODA LA HOJA<br />oHoja:Cells:Font:Size := 12 // ESPECIFICA TAMANO DE LETRA PARA TODA LA HOJA<br />oHoja:Cells( 1, 1 ):Font:Size := 16 // DETERMINA TAMAÑO DE LETRA A USAR EN UNA CELDA<br />oHoja:Cells( 1, 1 ):Font:Bold := .t. // PONE EN NEGRITAS VALOR DE UNA CELDA<br />oHoja:Cells( 1, 1 ):Font:ColorIndex := 5 // COLOR PRE-ESTABLECIDO DE EXCEL PARA EL CONTENIDO DE LA CELDA<br />oHoja:Cells( 3, 2 ):Font:Color := RGB(255,0,0) // COLOR DEL CONTENIDO DE LA CELDA<br />oHoja:Cells( 1, 4 ):Interior:ColorIndex := 16 // COLOR PRE-ESTABLECIDO DE EXCEL PARA LA CELDA(relleno)<br />oHoja:Cells( 3, 2 ):Interior:Color := RGB(200,160,35) // COLOR DE LA CELDA(relleno)<br />oHoja:Cells( 3, 1 ):NumberFormat := "$ ###,##0.00" // FORMATEAR CELDA NUMERICA<br /><br />/*<br />//--------------------------- imagenes en excel<br />oHoja:Shapes:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .t., .f., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA<br />oHoja:Shapes:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .t., .t., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA<br />oHoja:Shapes:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .f., .t., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA<br />oHoja:Shapes:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .f., .f., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL DA ERROR QUE NO ENTIENDO<br />//------------------------------<br /><br />METHOD FormatRange( cRange , cFont , nSize , lBold , lItalic , nAlign , nFore , nBack , nStyle , cFormat , lAutoFit )<br />&nbsp; LOCAL oRange<br /><br />&nbsp; oRange := ::oSheet:Range( cRange )<br /><br />&nbsp; IIF( cFont == Nil &nbsp;, , oRange:Font:Name := cFont )<br />&nbsp; IIF( nSize == Nil &nbsp;, , oRange:Font:Size := nSize )<br />&nbsp; IIF( lBold == Nil &nbsp;, , oRange:Font:Bold := lBold )<br />&nbsp; IIF( lItalic == Nil, , oRange:Font:Italic := lItalic )<br />&nbsp; IIF( nFore == Nil &nbsp;, , oRange:Font:Color := nFore )<br />&nbsp; IIF( nBack == Nil &nbsp;, , oRange:Interior:Color := nBack )<br />&nbsp; IIF( cFormat == Nil, , oRange:Set("NumberFormat",cFormat) )<br />&nbsp; IIF( nStyle == Nil , , oRange:Borders():LineStyle &nbsp;:= nStyle )<br />&nbsp; IIF( nAlign == Nil , , oRange:Set("HorizontalAlignment",Alltrim(Str(nAlign))) )<br />&nbsp; IIF( lAutoFit == Nil , , oRange:Columns:AutoFit() )<br /><br />RETURN ( Nil )<br /><br /><br /></span></div>[/code:1wigtuob]
crear archivo en excel con imagenes
Hola Willy Por lo que veo es usando una clase diferente a TXLS, o es la misma clase ?? de todas maneras lo veo interesante GRACIASS !!! Lubin
crear archivo excel sin tener instalado el Excel
Buenas noches con todos .. Es posible crear con fwh un archivo en excel sin tener instalado el Excel en la Maquina. Gracias por su respuesta.. Lubin
crear archivo excel sin tener instalado el Excel
Con la clase TXLS(), verifica tu correo Salu2
crear archivo excel sin tener instalado el Excel
Hola Willi Un gusto, despues de tiempo .. Estare atento del correo Gracias Lubin
crear archivo excel sin tener instalado el Excel
Agradecería si me lo pueden pasar.... muchas gracias david <!-- e --><a href="mailto:davidbarrio_arg@hotmail.com">davidbarrio_arg@hotmail.com</a><!-- e -->
crear base de datos en mysql
buenas noche como estan soy nuevo en el foro en estos momento tengo una duda el cual quiero crear una base de datos en fivewin con mysql y me a dado mucho rollo estoy creando un sistema utilitario y esto me tiene trancado quisiera saber si alquien podría aportar de su ayuda, yo ya creo la tabla dentro de la base de datos pero no se como crear la base de datos aquí le dejo un ejemplo que trae fiwewin que lo hago y me sale perfecto pero quisiera crear desde cero o desde la base de datos y luego crear las tablas y no se cuales son las intrusiones que debo usar gracias por su colaboracion y estoy usando "tdolphin" para la conexion esta son las intrucciones que uso para crear tablas pero no se como crear la base de datos: IF !oServer:tableexist( "prueba" ) cQuery := "CREATE TABLE prueba( " cQuery += "clave varchar(3) NOT NULL default '0'," cQuery += "nombre varchar(30) default 'x'," cQuery += "fecha date default '20091012'," cQuery += "saldo decimal(9,2) default 0.00," cQuery += "PRIMARY KEY (clave) " cQuery += ") ENGINE=InnoDB DEFAULT CHARSET=latin1" oServer:execute( cQuery ) ENDIF oServer:execute( "TRUNCATE TABLE prueba" ) oQry := oServer:Query( "SELECT * FROM prueba" ) oQry:gotop()
crear base de datos en mysql
bienvenido colega! para la cración de una DB en Mysql, se utiliza la instrucción "CREATE DATABASE < nombre de la base de datos >" y listo utilizando tus mismas lineas de codigo seria asi: [code=fw:37qxscxw]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><br />oServer:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"create database pruebas"</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp;</div>[/code:37qxscxw] hay mas opciones revisa en esta pagina : [url:37qxscxw]http&#58;//mysql&#46;conclase&#46;net/curso/?sqlsen=CREATE_DATABASE[/url:37qxscxw] saludos
crear base de datos en mysql
Usando Tdolphin seria asi, saludos... <!-- s:shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked" /><!-- s:shock: --> loca cDBname := "nombre_tu_database" IF oServer:DBCreate( cDBName ) // crear database MSGINFO( "Creada Correctamente a DataBase: " + cDBName, " SISINGE - ATENCIÓN" ) ENDIF oServer:SelectDB( cDBName ) // seleccionar database creada
crear base de datos en mysql
saludos gracias me funciono correctamente un saludo cordial
crear dialogos vistosos en fwh
hola, hay alguna manera de poder crear dialogos mas bonitos en fwh?.. ponerles colores, tanto a la ventana como a su contenido, como en VB?.. el work shop solo los pinta de un color escueto.. saludos.. arnulfo
crear dialogos vistosos en fwh
Arnulfo, Sí. FWH te permite usar bitmaps de fondo para las cajas de diálogo y quedan muy llamativas. Revisa samples\TestFldb.prg [url=http&#58;//imageshack&#46;us:3use8odf][img:3use8odf]http&#58;//img168&#46;imageshack&#46;us/img168/8406/foldersoa6&#46;jpg[/img:3use8odf][/url:3use8odf]
crear dialogos vistosos en fwh
Aquí tienes otro look <!-- m --><a class="postlink" href="http://img180.imageshack.us/my.php?image=capturarz3.jpg">http://img180.imageshack.us/my.php?image=capturarz3.jpg</a><!-- m -->
crear dialogos vistosos en fwh
Una mas: [img:1768pg9i]http&#58;//img116&#46;imageshack&#46;us/img116/1613/rcgw2&#46;jpg[/img:1768pg9i] Saludos.
crear dialogos vistosos en fwh
tendran un ejemplo de como poner las pantallas mas bonitas con imagenes..?? gracias arnulfo
crear dialogos vistosos en fwh
Arnulfo, Revisa el código de samples\TestFldb.prg
crear dialogos vistosos en fwh
Aqui esta.. muy similar a lo que podria ser una interfase generada con VB, pero no, es FWH <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> [img:2v2z4rqn]http&#58;//www&#46;alfasistemas&#46;net/seguridad&#46;jpg[/img:2v2z4rqn] Está generado con Resource WorkShop. ... y no son bitmaps <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->
crear dialogos vistosos en fwh
[quote="Alberto Juárez":3qrldevu]Aqui esta.. muy similar a lo que podria ser una interfase generada con VB, pero no, es FWH <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> [img:3qrldevu]http&#58;//www&#46;alfasistemas&#46;net/seguridad&#46;jpg[/img:3qrldevu] Está generado con Resource WorkShop. ... y no son bitmaps <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->[/quote:3qrldevu] Alberto, en tu ejemplo, como haces para desactivar el prime boton, el que dice "consulta". Gracias.
crear dialogos vistosos en fwh
Un poco de diseño grafico (contraten a alguien, vale la pena) y unos bitmpas de fondo para el sistema RedPDV de mi amigo Yucif Santano 100% FiveWin 100% google Consulting <!-- s8) --><img src="{SMILIES_PATH}/icon_cool.gif" alt="8)" title="Cool" /><!-- s8) --> [img:1oxqakj9]http&#58;//www&#46;google&#46;d2g&#46;com/objeto/yucif1&#46;jpg[/img:1oxqakj9] [img:1oxqakj9]http&#58;//www&#46;google&#46;d2g&#46;com/objeto/yucif2&#46;jpg[/img:1oxqakj9] Pero quien se lleva las palmas sin duda Patrick Mast: (<!-- w --><a class="postlink" href="http://www.winfakt.com">www.winfakt.com</a><!-- w -->) y eso a 16 bits aun: [img:1oxqakj9]http&#58;//www&#46;google&#46;d2g&#46;com/objeto/patrick1&#46;jpg[/img:1oxqakj9] [img:1oxqakj9]http&#58;//www&#46;google&#46;d2g&#46;com/objeto/patrick2&#46;jpg[/img:1oxqakj9] [img:1oxqakj9]http&#58;//www&#46;google&#46;d2g&#46;com/objeto/patrick3&#46;jpg[/img:1oxqakj9]
crear dialogos vistosos en fwh
Aqui les dejo otro... [img] [url=http&#58;//img286&#46;imageshack&#46;us/my&#46;php?image=busmaticmp0&#46;jpg:25l1n8ei][img=http://img286.imageshack.us/img286/3995/busmaticmp0.th.jpg][/url:25l1n8ei] [/img]
crear dialogos vistosos en fwh
[quote="leandro":2z8wjdam]Aqui les dejo otro... [/quote:2z8wjdam] Amigo, este es el correcto [img:2z8wjdam]http&#58;//www&#46;incos&#46;com&#46;mx/busmaticmp0&#46;jpg[/img:2z8wjdam]
crear dialogos vistosos en fwh
[img:2jyf6brd]http&#58;//img133&#46;imageshack&#46;us/my&#46;php?image=gturniyc9&#46;jpg[/img:2jyf6brd] thi is my application
crear dialogos vistosos en fwh
thi is my application [img:1qixgqqi]http&#58;//img133&#46;imageshack&#46;us/img133/3406/gturniyc9&#46;jpg[/img:1qixgqqi]
crear dialogos vistosos en fwh
ai va otra mas... <!-- m --><a class="postlink" href="http://img334.imageshack.us/my.php?image=pdvck9.jpg">http://img334.imageshack.us/my.php?image=pdvck9.jpg</a><!-- m --> salu2 paco[/quote]
crear dialogos vistosos en fwh
otra mas... <!-- m --><a class="postlink" href="http://img67.imageshack.us/img67/3259/moneyvv2.jpg">http://img67.imageshack.us/img67/3259/moneyvv2.jpg</a><!-- m -->
crear dialogos vistosos en fwh
[quote="Francisco Horta":y7xaccdf]otra mas... <!-- m --><a class="postlink" href="http://img67.imageshack.us/img67/3259/moneyvv2.jpg">http://img67.imageshack.us/img67/3259/moneyvv2.jpg</a><!-- m -->[/quote:y7xaccdf] Muy buena !!! Ahora Francisco como lograste los get con el estilo "FLAT"? O es un theme que estas usando ? Un abrazo. El Loco =>))
crear dialogos vistosos en fwh
Loco, son simples editbox con la btnget, uso themes de xp pero no me los toma, ya que con el xp normal se ven igual. Salu2 Paco
crear dialogos vistosos en fwh
saludos,muy bonitas pantallas, el caso es.. algun ejemplo de codigo de Como poner los diseños en las pantallas.. o de como manipular el workshop para que por ejemplo los dialogos diseñados se puedan modificar en tiempo de corrida por ejem. cambiarle el tipo y el color de la letra, etc.. no solo dejarlo como lo hace el workshop sin colores. saludos Arvisnet
crear dialogos vistosos en fwh
[quote="Francisco Horta":1rlzc8ya]Loco, son simples editbox con la btnget, uso themes de xp pero no me los toma, ya que con el xp normal se ven igual. Salu2 Paco[/quote:1rlzc8ya] Paco gracias por la aclaracion. Un abrazo. El Loco =>))
crear dialogos vistosos en fwh
Arvisnet, puedes colocar lo que gustes, si buscas código puedes revisar el mensaje 'Solo para presumir...' ahí está una imágen y una liga al código; todas lás áreas son controladas por spliters, son totalmente flexibles y pueden ser modificadas como se desee durante la ejecución. Todo es cuestión de imaginación (diseño, como sugiere René) y habilidad en el manejo de estas herramientas.
crear grupo en tiempo de ejecucion
Gracias adelantadas por su ayuda Tengo un reporte con dos grupos anidados con report se puede crear un grupo mas al 2do grupo, pero y a la vez eliminarlo y terminar con dos grupos todo eso en tiempo de ejecucion?
crear listbox durante la ejecucion del programa
Buenas tardes con todos: Tengo una consulta bastante simple seguro de LISTBOX pero no le doyyy.. Quiero crear un listbox de un conjunto de campos que tengo en un arreglo VCAMPOS, que inclusive alguno de ellos son una funcion , que tendra V_ENCABEZADOS, con el Ancho de columna para cada campo en V_ANCHO, como prodia hacerlo: Ejemplo... V_bCampos :={} AADD(V_bCampos,{|| Codigo} ) AADD(V_bCampos,{|| Nombre} ) AADD(V_bCampos,{|| fnacimiento } ) AADD(V_bCampos,{|| edad(fnacimiento) } ) V_Encabezado:={} AADD(V_Encabezado,"Cod.Personal" ) AADD(V_Encabezado,"Nombre y apellidos" ) AADD(V_Encabezado,"Fecha Nacimiento" ) AADD(V_Encabezado,"edad" ) V_ancho:={} AADD(V_ancho,40 ) AADD(V_ancho,150 ) AADD(V_ancho,60 ) AADD(V_ancho,40 ) COMO SE CREARIA EL LISTBOX DESDE RECURSOS CON UN REDEFINE EN TIEMPO DE EJECUCION, teniendo estos ARREGLOS ?? Gracias Lubin
crear pdf a partir de xml
[quote="jbrita":3dy40sgw]Hola es posibles hacer esto, tomar un xml y crear un pdf[/quote:3dy40sgw] Hasta donde sé, XML no tiene información de representación, solo datos, y es en otro archivo asociado que define la forma de representarlo. De todas maneras, es un txt, la misma formula que uses para texto te deberia servir. Y ya puestos, mira Haru PDF, es de lo mejor.
crear pdf a partir de xml
jbrita, Creo entender que lo que pretendes es imprimir un formulario a partir de la informacion contenida en un .xml. Del .xml extraerias solo los "datos". El modelo estaria aparte, de la misma manera que se puede hacer con una factura electronica. Probablemente haya por ahi programas genericos que impriman .xml, pero su ajuste en el papel no sera lo que quieras. Lo que yo haria: Diseñar un documento, con aquello que quieres imprimir. El diseño lo puedes hacer para la libreria harupdf, como indica Carlos. Leer el xml sobre un hash y recorrerlo a la vez que se imprime la informacion. Mis dos cents. Saludos
crear pdf a partir de xml
Tal vez pueda servirte esto: <!-- l --><a class="postlink-local" href="http://forums.fivetechsupport.com/viewtopic.php?f=6&t=4897&hilit=pdf">viewtopic.php?f=6&t=4897&hilit=pdf</a><!-- l -->
crear pdf a partir de xml
Hola es posibles hacer esto, tomar un xml y crear un pdf saludos
crear pdf a partir de xml
Abrelo con Word y crea el Pdf, de momento es lo que se me ocurre
crear pdf a partir de xml
Mira se ayuda ó genera una idéia. [url:32hv3bee]http&#58;//www&#46;4shared&#46;com/rar/rzuwmK6Dce/NFEWEB&#46;html[/url:32hv3bee] Saludos.
crear ruta desde fivewin
Hola Gente, necesito trazar un recorrido con hasta 4 direcciones en Google maps, se puede hacer desde fivewin? Tengo desarrollado que enviando la dirección la ubica en maps funciona perfecto, pero no encuentro como mostrar una ruta. Saludos Jorge.
crear ruta desde fivewin
[url:byjigwot]http&#58;//fivewin&#46;com&#46;br/index&#46;php?/topic/22226-como-mostrar-a-rota-no-google-maps/[/url:byjigwot] Saludos.
crear tabla con el api de harbour
Amigos, uso desde hace mucho tiempo la clase tmysql, ahora tengo la necesidad de tomar el resultado y pasarlo a una tabla, con codigo prg no es muy complicado, pero me propuesto hacerlo usando el api de ahrbour, osea usar el rdd api. alguien me podria dar una idea de como hacerlo, he revisado el contrib especificamente el sqlmix, pero no logro entenderlo, <!-- s:-( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":-(" title="Sad" /><!-- s:-( --> un ejemplo bastaria. mi idea es hace: crear el area de trabajo, y definir los campos en base a las columnas del cursor de mysql, y luego insertar las filas. salu2
crear tabla con el api de harbour
Este codigo deseo pasarlo a C para optimizar velocidad! [code=fw:2hzul0z7]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00C800;">METHOD</span> ToDbf<span style="color: #000000;">&#40;</span> cTableName, cAlias, cRdd, lShared, lReadOnly <span style="color: #000000;">&#41;</span> <span style="color: #00C800;">CLASS</span> TMySQLQuery<br />   <span style="color: #00C800;">LOCAL</span> lCreated := <span style="color: #00C800;">FALSE</span>, nRecNo, nField<br /><br />   <span style="color: #00C800;">DEFAULT</span> cRdd <span style="color: #0000ff;">TO</span> <span style="color: #ff0000;">"DBFNTX"</span>, cAlias <span style="color: #0000ff;">TO</span> cTableName, lShared <span style="color: #0000ff;">TO</span> <span style="color: #00C800;">FALSE</span>, lReadOnly <span style="color: #0000ff;">TO</span> <span style="color: #00C800;">FALSE</span><br /><br />      <span style="color: #00C800;">IF</span> !File<span style="color: #000000;">&#40;</span> cTableName <span style="color: #000000;">&#41;</span><br />      <span style="color: #00C800;">TRY</span><br />         dbCreate<span style="color: #000000;">&#40;</span> cTableName, ::<span style="color: #000000;">Struct</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, cRdd <span style="color: #000000;">&#41;</span><br />         lCreated := <span style="color: #00C800;">TRUE</span><br />      CATCH<br />         <span style="color: #00C800;">RETURN</span> lCreated<br />      END<br />   <span style="color: #00C800;">ENDIF</span><br /><br />   <span style="color: #00C800;">IF</span> lCreated .and. !<span style="color: #0000ff;">Select</span><span style="color: #000000;">&#40;</span> cAlias <span style="color: #000000;">&#41;</span> > <span style="color: #000000;">0</span><br />      dbUseArea<span style="color: #000000;">&#40;</span> <span style="color: #00C800;">TRUE</span>, cRdd, cTableName, cAlias, lShared, lReadOnly <span style="color: #000000;">&#41;</span><br />      <span style="color: #00C800;">IF</span> NetErr<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />         <span style="color: #00C800;">RETURN</span> lCreated<br />      <span style="color: #00C800;">ENDIF</span><br />   <span style="color: #00C800;">ENDIF</span><br /><br />   <span style="color: #00C800;">IF</span> <span style="color: #000000;">&#40;</span>cAlias<span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> RecCount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> > <span style="color: #000000;">0</span><br />      <span style="color: #000000;">&#40;</span>cAlias<span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> __Zap<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">ENDIF</span><br /><br />   nRecNo := ::<span style="color: #000000;">RecNo</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;::<span style="color: #000000;">GoTop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">WHILE</span> !::<span style="color: #000000;">Eof</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />      <span style="color: #000000;">&#40;</span>cAlias<span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> dbAppend<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />      <span style="color: #00C800;">FOR</span> nField := <span style="color: #000000;">1</span> <span style="color: #0000ff;">TO</span> ::<span style="color: #000000;">FCount</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />         <span style="color: #000000;">&#40;</span>cAlias<span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> FieldPut<span style="color: #000000;">&#40;</span> nField, ::<span style="color: #000000;">FieldGet</span><span style="color: #000000;">&#40;</span> nField <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />      <span style="color: #00C800;">NEXT</span><br />      ::<span style="color: #000000;">Skip</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">ENDDO</span><br /><br />   <span style="color: #00C800;">IF</span> nRecNo > <span style="color: #000000;">0</span><br />      ::<span style="color: #000000;">GoTo</span><span style="color: #000000;">&#40;</span> nRecNo <span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">ENDIF</span><br /><br />   <span style="color: #000000;">&#40;</span>cAlias<span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> dbCommit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, dbGoTop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00C800;">RETURN</span> lCreated<br /><br /> </div>[/code:2hzul0z7]
crear tabla con el api de harbour
Carlos, Creo que la principal optimización sería el bucle while ... end en lo demás no creo que vaya a haber diferencia de velocidad
crear tabla con el api de harbour
Hola, Lo que consume el tiempo es el bucle FOR, el copiado campo a campo. Recorrer UNO a UNO los campos a grabar. Habria que inventar algo para que se hiciera un traspaso en bloque... algo parecido a usar __dbTrans Mientras, usar Local nFCount:= ::FCount() en FOR nField:= 1 TO nFCount, y similares variables, puede ayudar un poco... muy poco... La clave es el bucle FOR y el copiado campo a campo... Saludos
crear tabla con el api de harbour
FWH's built-in MariaDB library has this method: [code=fw:25sbw9p0]<div class="fw" id="{CB}" style="font-family: monospace;"><br />oCn:<span style="color: #000000;">SaveToDBF</span><span style="color: #000000;">&#40;</span> cSql, cDbfName, <span style="color: #000000;">&#91;</span>lForUpdate = .f.<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span><br /> </div>[/code:25sbw9p0] This method uses RDD API at the level of "C" language. Without waiting to read the result of cSql, this method keeps writing to DBF as and when each line is read from the server and is very fast. FWH's built-in library comes for free and we do not have to link any 3rd party libraries. We may be using TMySql or Dolphin or ADO for our main program. We can still use the bulit-in library along side without disturbing the main application. For example, we are using TMySql for our main application and oServer is the connection object in TMySql. We can do: [code=fw:25sbw9p0]<div class="fw" id="{CB}" style="font-family: monospace;"><br />oCn := maria_Connect<span style="color: #000000;">&#40;</span> oServer <span style="color: #000000;">&#41;</span> <span style="color: #B900B9;">// oServer is TMySql connection</span><br />oCn:<span style="color: #000000;">SaveToDBF</span><span style="color: #000000;">&#40;</span> cSql, cDbfName <span style="color: #000000;">&#41;</span><br />oCn:<span style="color: #000000;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /> </div>[/code:25sbw9p0]
crear tabla con el api de harbour
Mira esta comparativa [img:auj72yar]https&#58;//i&#46;postimg&#46;cc/rs9cjWxg/sqlmix0&#46;png[/img:auj72yar] [img:auj72yar]https&#58;//i&#46;postimg&#46;cc/DZ2xsXf7/sqlmix1&#46;png[/img:auj72yar]
crear tabla con el api de harbour
Sip, se que la clase de fwh es muy potente, al igual que dolphin, y ado, pero es que le tengo mucho cariño a tmysql (con ella aprendi mucho de harbour, c, apis, etc. es invaluable lo que he aprendido con ella.) la tengo bastante optimizada y modificada, aparte que tengo los fuentes. <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) --> casualmente lo que indica Rao es lo que yo deseo, hacer, una metodo directo que realize la consulta y lo pase a dbf. para ellos debere pasar el metodo a tmysqlsrv en lugar de tmysqlqry .En sqlrdd existe una funcion igualmente y es muy rapido. Usualmente inicio con algo simple que funciona y luego ya lo voy optimizando. como en este caso. deseo aprender un poco del api de rdd. (seria como dos pajaron con un solo tiro) Cristobal, ese programa de prueba de velocidad esta en fwh? si no es asi puedes compratirlo. salu2 Gracias
crear tabla con el api de harbour
Ok Carlos, pero como bien sabes, en el uso de Mysql y estos temas no sólo hay que tener en cuenta la velocidad de la "herramienta" que usemos.
crear tabla en MySql
He podido conectarme con el servidor sin problemas mediante ado. Pero al momento de crear una tabla me da error. Esta es la cadena del comando: oCn : Execute( "create table alumnos( codigo int( 10 ) default 0 primary key auto_increment, nombre varchar(30), fecha_nacimiento varchar(15), Importe decimal( 10, 2 ) Default 0.00 ) TYPE=InnoDB ", "CREATE" ) Sin embargo si la creo sin la sentencia "primary key auto_increment" el comando funciona. Alguien tiene alguna punta sobre este asunto. Desde ya muchas gracias
crear tabla en MySql
Prueba cambiando el primary key al final , cQry := "CREATE TABLA IF NOT EXISTS ALUMNOS ( " cQry += "codigo INT(10) DEFAULT 0, " cQry += "nombre VARCHAR(30) NOT NULL," cQry += "auto INT NOT NULL AUTO_INCREMENT," cQry += "PRIMARY KEY (codigo))" cQry += "ENGINE = INNODB" oCn:Execute( cQry ) Saludos Cordiales..
crear tabla en MySql
Prueba a quitarle el default 0 así: oCn : Execute( "create table alumnos( codigo int( 10 ) primary key auto_increment, nombre varchar(30), fecha_nacimiento varchar(15), Importe decimal( 10, 2 ) Default 0.00 ) TYPE=InnoDB ", "CREATE" ) Un Saludo Marcelo Jingo
crear tabla en MySql
Cesar, Marcelo muchas gracias por las respuestas. He probado las dos soluciones que me propusieron pero no funcionan ( por lo menos en mi servidor ). Estoy utilizando MySql 5.0. MI pregunta si esta secuencia de comandos soporta estas instrucciones ( primary key, foreign key, etc. ). No sé si hay otra manera de hacerlo. Seguiré investigando
crear tabla en MySql
Qué error te devuelve? Porque probé tu código de la forma como te indiqué y la tabla se creó sin problema en mi base de datos. Un Saludo Marcelo Jingo
crear tabla en MySql
Gracias marcelo por tu respuesta. Te adjunto el codigo y puedes mirar que está mal. Yo no he podido hacerlo funcionar. [code][/code] Function Creatabla() Local i Local cCadena Local oCn :=CreateObject("ADODB.Connection") Local aNombres := { { "Pedro", "3222551.00", "1998-10-15" }, { "Juan", "2.21", "1998-10-15" }, { "Tadeo", "3.58", "1998-10-15" } } oCn : Open( "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=alumnos;User=root;Password=root;Option=3;") oCn : Execute( "drop database if exists alumnos", "DROP" ) oCn : Execute( "create database alumnos", "CREATE" ) oCn : Execute( "create table alumnos( codigo int( 10 ) primary key auto_increment, nombre varchar(30), fecha_nacimiento varchar(15), Importe decimal( 10, 2 ) Default 0.00 ) TYPE=InnoDB ", "CREATE" ) For i := 1 To Len( aNombres ) cCadena := "insert into alumnos(nombre,fecha_nacimiento,importe) values ( '" + aNombres[ i ][ 1 ] + "', '" + aNombres[ i ][ 3 ] + "', " + aNombres[ i ][ 2 ] + " )" oCn : Execute( cCadena, 'INSERT' ) <- aqui marca error Next i oCn : Close() Return 0 Fichero de error Path and name: C:\ado\T-REX.EXE (32 bits) Size: 1,702,400 bytes Time from start: 0 hours 0 mins 2 secs Error occurred at: 11/02/07, 17:24:42 Error description: Error ADODB.Connection/16389 E_FAIL: EXECUTE Args: [ 1] = C create table alumnos( codigo int( 10 ) primary key auto_increment, nombre varchar(30), fecha_nacimiento varchar(15), Importe decimal( 10, 2 ) Default 0.00 ) TYPE=InnoDB [ 2] = C CREATE Stack Calls =========== Called from: win32ole.prg => TOLEAUTO:EXECUTE(0) Called from: ado.prg => CREATABLA(213) Called from: ado.prg => (b)MUESTRASQL(127) Called from: TOOLBAR.PRG => TTOOLBAR:COMMAND(0) Called from: window.prg => TMDICHILD:COMMAND(949) Called from: window.prg => TWINDOW:HANDLEEVENT(0) Called from: MDICHILD.PRG => TMDICHILD:HANDLEEVENT(0) Called from: window.prg => _FWH(3159) Called from: => WINRUN(0) Called from: window.prg => TMDIFRAME:ACTIVATE(895) Called from: ado.prg => MAIN(14)
crear tabla en MySql
Amigo prueba con este a mi me funciona de maravilla [code:m1az8ym1] cCommandSql &#58;= "CREATE TABLE IF NOT EXISTS Cliente &#40;" +; "CLI_NUM INTEGER UNSIGNED COMMENT 'Número de cliente'," +; "CLI_NOM VARCHAR&#40;70&#41; DEFAULT ''COMMENT 'Nombre del cliente'," +; "PRIMARY KEY&#40;CLI_NUM&#41; &#41;" +; "ENGINE = InnoDB COMMENT = 'Maestro de clientes';" [/code:m1az8ym1] Si tienes los permisos para crear tablas? Espero te sirva..
crear tabla en MySql
Horacio Probé tu código tal cual (comentando las líneas de eliminación , creacion de la BD), creando la tabla en mi base de datos y funcionó bien insertando los registros en la tabla creada. A lo mejor tu problema es de privilegios del usuario sobre la Base de datos o algo así. Perdona por no poder ayudar más Un saludo Marcelo Jingo
crear tabla en MySql
Marcelo: Ya lo solucioné. No entiendo bien la lógica del motor. Supuse que eliminando la base de datos se eliminaba la tabla, pero parece que no es así. Si elimino solamente la tabla la crea perfectamente pero si elimino la database y vuelvo a crear la base de datos y la tabla me marca un error. Gracias a todos por haber seguido este hilo y la ayuda que me brindaron
crear tabla mysql
Amigos del Foro: No me crea la Bd, cual es el error [code=fw:33tz66kp]<div class="fw" id="{CB}" style="font-family: monospace;">  <br />  cCad := <span style="color: #ff0000;">"Provider=SQLOLEDB;"</span><br />  cCad += <span style="color: #ff0000;">"Server=PYSASERVER;"</span><br />  cCad += <span style="color: #ff0000;">"Database=PysaBD;Uid=sa;Pwd=Pysa123456;"</span><br />  <span style="color: #00C800;">TRY</span><br />    oCon := CreateObject<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"ADODB.Connection"</span> <span style="color: #000000;">&#41;</span><br />  CATCH oError<br />     MsgStop<span style="color: #000000;">&#40;</span> oError:<span style="color: #000000;">Description</span> <span style="color: #000000;">&#41;</span><br />  END<br />   <span style="color: #00C800;">TRY</span><br />     oCon:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span> cCad <span style="color: #000000;">&#41;</span><br />   CATCH oErr<br />     <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"Could not open Connection to Database "</span> <span style="color: #000000;">&#41;</span><br />     <span style="color: #00C800;">RETURN</span><span style="color: #000000;">&#40;</span>.F.<span style="color: #000000;">&#41;</span><br />   END <span style="color: #00C800;">TRY</span><br /><br />   cSql:=<span style="color: #ff0000;">"CREATE TABLE IF NOT EXISTS cabguit AS (SELECT * FROM cabguia)"</span><br /><br />   <span style="color: #00C800;">Try</span><br />      oCon:<span style="color: #000000;">Execute</span><span style="color: #000000;">&#40;</span> cSQL <span style="color: #000000;">&#41;</span><br />   Catch<br />      <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"Table Create BIN Failed"</span> <span style="color: #000000;">&#41;</span><br />   End <span style="color: #00C800;">try</span><br /><br /> </div>[/code:33tz66kp]
crear tabla mysql
Title of this topic says "MySql". But you are trying to connect to Microsoft SQL Server. (MSSQL). This is the correct connection string to be used to connect to MSSQL (not MySql) [code=fw:269vrftd]<div class="fw" id="{CB}" style="font-family: monospace;"><br />cCad := <span style="color: #ff0000;">"Provider=SQLOLEDB;Data Source=PYSASERVER;Initial Catalog=PysaBD;User ID=SA;Password=Pysa123456;"</span><br />&nbsp;</div>[/code:269vrftd]
crear tabla mysql
Mr. Rao: You have right is MSSQL, not MySQL , typing error its ok with the connection chain selects, inserts, deletes do without problem but i cant créate table it got this error Error BASE/1004 Message not found: LOGICAL:EXEC Gente: Estoy migrando mis tablas de dbf a sql, logro conectarme, hacer consultas, pero necesito crear tablas, es ahi donde no puedo sale el msje de arriba [code=fw:p9ae2108]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><br />  xPROVIDER := <span style="color: #ff0000;">"SQLOLEDB"</span>                  <br />  xSOURCE   := <span style="color: #ff0000;">"PYSASERVER"</span>                <br />  xCATALOG  := <span style="color: #ff0000;">"PysaBD"</span>                    <br />  xUSERID   := <span style="color: #ff0000;">"sa"</span><br />  xPASSWORD := <span style="color: #ff0000;">"Pysa123456"</span><br />  xConnect  := <span style="color: #ff0000;">'Provider='</span>+xPROVIDER+<span style="color: #ff0000;">';Data Source='</span>+xSOURCE+<span style="color: #ff0000;">';Initial Catalog='</span>+xCATALOG+<span style="color: #ff0000;">';User Id='</span>+xUSERID+<span style="color: #ff0000;">';Password='</span>+xPASSWORD<br /><br />  <span style="color: #00C800;">TRY</span><br />    oCon1 := CreateObject<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"ADODB.Connection"</span> <span style="color: #000000;">&#41;</span><br />    oCon1:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span> xConnect <span style="color: #000000;">&#41;</span><br />  CATCH oError<br />     MsgStop<span style="color: #000000;">&#40;</span> oError:<span style="color: #000000;">Description</span> <span style="color: #000000;">&#41;</span><br />  END<br /><span style="color: #B900B9;">// first option not run</span><br />   cSQL := <span style="color: #ff0000;">"CREATE TABLE Bin"</span><br />   cSQL += <span style="color: #ff0000;">"( "</span><br />   cSQL += <span style="color: #ff0000;">"[BIN]       char(50) NOT NULL, "</span><br />   cSQL += <span style="color: #ff0000;">"CONSTRAINT PK_BIN PRIMARY KEY ( BIN )"</span><br />   cSQL += <span style="color: #ff0000;">" )"</span><br /><br />   <span style="color: #B900B9;">// second option also not run</span><br />   <span style="color: #B900B9;">//cSql:="CREATE TABLE IF NOT EXISTS regtempo AS (SELECT * FROM cabguia)" </span><br /><br />   <span style="color: #00C800;">Try</span><br />      oCon1:<span style="color: #000000;">Execute</span><span style="color: #000000;">&#40;</span> cSQL <span style="color: #000000;">&#41;</span><br />   Catch<br />      <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"Table Create BIN Failed"</span> <span style="color: #000000;">&#41;</span><br />   End <span style="color: #00C800;">try</span><br /><br /><br /> </div>[/code:p9ae2108]
crear tabla mysql
MySql syntax does not always work in MSSql. For example, CREATE ..IF NOT EXISTS .. does not work in MsSql Please study MSSQL syntax Suggest <!-- m --><a class="postlink" href="http://www.w3schools.com">http://www.w3schools.com</a><!-- m -->
crear tabla mysql
Artu, prueba con esta instrucción a ver si te crea la tabla (funciona tanto para MySQL como MSSql) CREATE TABLE tablaprueba ( clave VARCHAR(7) NOT NULL, hechopor VARCHAR(60) NOT NULL, valorint INT(1) NOT NULL DEFAULT 1, PRIMARY KEY (clave) ); Saludos cordiales, Carlos.
crear tabla mysql
[quote="nageswaragunupudi":26e51qig]Please study MSSQL syntax[/quote:26e51qig] Thank mr. rao, i shall do so [quote="csincuir":26e51qig]CREATE TABLE tablaprueba( clave VARCHAR(7) NOT NULL, hechopor VARCHAR(60) NOT NULL, valorint INT(1) NOT NULL DEFAULT 1, PRIMARY KEY (clave) );[/quote:26e51qig] Gracias csincuir, así me funciono [code=fw:26e51qig]<div class="fw" id="{CB}" style="font-family: monospace;"><br />cSQL := <span style="color: #ff0000;">"CREATE TABLE #prueba"</span><br />cSQL += <span style="color: #ff0000;">"("</span><br />cSQL += <span style="color: #ff0000;">"clave VARCHAR(7) NOT NULL,"</span><br />cSQL += <span style="color: #ff0000;">"hechopor VARCHAR(60) NOT NULL,"</span><br />cSQL += <span style="color: #ff0000;">"valor INT NOT NULL DEFAULT 1"</span><br />cSQL += <span style="color: #ff0000;">")"</span><br /> </div>[/code:26e51qig]
crear un codigo de barras ean 128a
Hola a todos: Alguien sabe como se puede crear un código de barras con el código EAN 128A. Un saludo Carlos
create a pdf
I want to print the contents of a window in a pdf how should i do?
create a pdf
[code=fw:m9akrxmz]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">function</span> WndToPdf<span style="color: #000000;">&#40;</span> oWnd, cPdf <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> cJpg &nbsp;:= cFileSetExt<span style="color: #000000;">&#40;</span> cPdf, <span style="color: #ff0000;">"jpg"</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> oPrn<br /><br />&nbsp; &nbsp;oWnd:<span style="color: #000000;">SaveAsImage</span><span style="color: #000000;">&#40;</span> cJpg, <span style="color: #000000;">100</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">PRINT</span> oPrn PREVIEW FILE cPdf<br />&nbsp; &nbsp;<span style="color: #0000ff;">PAGE</span><br />&nbsp; &nbsp;@ <span style="color: #000000;">1</span>,<span style="color: #000000;">1</span> <span style="color: #00C800;">PRINT</span> <span style="color: #0000ff;">TO</span> oPrn <span style="color: #0000ff;">IMAGE</span> cJpg<br />&nbsp; &nbsp;<span style="color: #0000ff;">ENDPAGE</span><br />&nbsp; &nbsp;<span style="color: #0000ff;">ENDPRINT</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br />&nbsp;</div>[/code:m9akrxmz]
create a pdf
[quote="nageswaragunupudi":6npb2n3g][code=fw:6npb2n3g]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">function</span> WndToPdf<span style="color: #000000;">&#40;</span> oWnd, cPdf <span style="color: #000000;">&#41;</span><br /><br />   <span style="color: #00C800;">local</span> cJpg  := cFileSetExt<span style="color: #000000;">&#40;</span> cPdf, <span style="color: #ff0000;">"jpg"</span> <span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">local</span> oPrn<br /><br />   oWnd:<span style="color: #000000;">SaveAsImage</span><span style="color: #000000;">&#40;</span> cJpg, <span style="color: #000000;">100</span> <span style="color: #000000;">&#41;</span><br /><br />   <span style="color: #00C800;">PRINT</span> oPrn PREVIEW FILE cPdf<br />   <span style="color: #0000ff;">PAGE</span><br />   @ <span style="color: #000000;">1</span>,<span style="color: #000000;">1</span> <span style="color: #00C800;">PRINT</span> <span style="color: #0000ff;">TO</span> oPrn <span style="color: #0000ff;">IMAGE</span> cJpg<br />   <span style="color: #0000ff;">ENDPAGE</span><br />   <span style="color: #0000ff;">ENDPRINT</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /> </div>[/code:6npb2n3g][/quote:6npb2n3g] Nages, Now I made a test [b:6npb2n3g] WndToPdf( oApp():oSpiaggia, "test.pdf" )[/b:6npb2n3g] and I have a pdf with the image is blurred that is not clear [img:6npb2n3g]https&#58;//i&#46;postimg&#46;cc/NMdTqQ1n/fffffffffffffffffffffffff&#46;png[/img:6npb2n3g] any solution ?
create a pdf
The function must have saved test.jpg before creating test.pdf. Check the quality of test.jpg
create a pdf
[quote="nageswaragunupudi":2ksnrbzj]The function must have saved test.jpg before creating test.pdf. Check the quality of test.jpg[/quote:2ksnrbzj] good quality I sent you now
create a pdf
Nages, the function give me a white page pdf today!!!! ( while test.jpg is created)
create a pdf
Nages, the function create a jpg but when it create a pdf [b:2tjufu6c] insert a blurred image in the pdf sheet[/b:2tjufu6c] [code=fw:2tjufu6c]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">function</span> WndToPdf<span style="color: #000000;">&#40;</span> oWnd, cPdf <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> cJpg &nbsp;:= cFileSetExt<span style="color: #000000;">&#40;</span> cPdf, <span style="color: #ff0000;">"jpg"</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> oPrn<br /><br />&nbsp; &nbsp;oWnd:<span style="color: #000000;">SaveAsImage</span><span style="color: #000000;">&#40;</span> cJpg, <span style="color: #000000;">100</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">PRINT</span> oPrn PREVIEW FILE cPdf<br />&nbsp; &nbsp;<span style="color: #0000ff;">PAGE</span><br />&nbsp; &nbsp;@ <span style="color: #000000;">1</span>,<span style="color: #000000;">1</span> <span style="color: #00C800;">PRINT</span> <span style="color: #0000ff;">TO</span> oPrn <span style="color: #0000ff;">IMAGE</span> cJpg<br />&nbsp; &nbsp;<span style="color: #0000ff;">ENDPAGE</span><br />&nbsp; &nbsp;<span style="color: #0000ff;">ENDPRINT</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span></div>[/code:2tjufu6c] the image created [img:2tjufu6c]https&#58;//i&#46;postimg&#46;cc/dtG3xC8d/beach&#46;jpg[/img:2tjufu6c] the image on pdf [img:2tjufu6c]https&#58;//i&#46;postimg&#46;cc/ZKLZNx8f/gg&#46;png[/img:2tjufu6c] How I can resolve it ?
create a pdf
On Fivewin there is a function FWJPGTOPDF that write basic PDF with the jpg, can you try [code=fw:z3ie6lps]<div class="fw" id="{CB}" style="font-family: monospace;">procedure WndToPdf<span style="color: #000000;">&#40;</span> oWnd, cPdf <span style="color: #000000;">&#41;</span><br /><br />   <span style="color: #00C800;">local</span> cJpg  := cFileSetExt<span style="color: #000000;">&#40;</span> cPdf, <span style="color: #ff0000;">"jpg"</span> <span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">local</span> oPrn<br /><br />   oWnd:<span style="color: #000000;">SaveAsImage</span><span style="color: #000000;">&#40;</span> cJpg, <span style="color: #000000;">100</span> <span style="color: #000000;">&#41;</span><br /><br />   FwJpgToPdf<span style="color: #000000;">&#40;</span>cJpg, cPdf<span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00C800;">return</span></div>[/code:z3ie6lps] edit: it comes stretched.
create a pdf
[code=fw:2e7y5e25]<div class="fw" id="{CB}" style="font-family: monospace;"> FwJpgToPdf<span style="color: #000000;">&#40;</span>cJpg, cPdf<span style="color: #000000;">&#41;</span></div>[/code:2e7y5e25] I did not propose this because of the problems in resizing the image. This works well if the proportions of the image fit into the paper size.
create a pdf
I see, the problem is that calls PGJPEG1 with the size of the page, instead of with the size of image... it is should be quick fix... maybe with the new lib haru interface, is possible create a pdf without change the quality of jpg
create a pdf
[quote="AntoninoP":12kmryw7]I see, the problem is that calls PGJPEG1 with the size of the page, instead of with the size of image... it is should be quick fix... maybe with the new lib haru interface, is possible create a pdf without change the quality of jpg[/quote:12kmryw7] The proposed function, if used with haru, will produce better results. Add this at the beginning the program [code=fw:12kmryw7]<div class="fw" id="{CB}" style="font-family: monospace;"><br />REQUEST FWHARU<br />&nbsp;</div>[/code:12kmryw7] and anywhere in the program [code=fw:12kmryw7]<div class="fw" id="{CB}" style="font-family: monospace;"><br />TPrinter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #000000;">lUseHaruPDF</span> := .t.<br />&nbsp;</div>[/code:12kmryw7] With these two changes, the same function I posted will give better results.
create .res files and compile into DLL for load using res://
I searching some app for create a dll file using various .res files created with resourcing tools. for using in html content via res:// protocol
create PDF from tprint without preview
Hi I need to create a pdf from a document without any PDF Printer. Is not possible to generate a PDF instead of sending the document to a preview or directly to printer ?. I saw in the forum that some use tpdf to do so , but i didn't saw any example. best regards
create a Harbour class from C code
This is an example, in next posts we will check more advanced techniques from Manuel Expósito: [code=fw:1k9e44vm]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00D7D7;">#include</span> <hbapi.h><br /><span style="color: #00D7D7;">#include</span> <hbapicls.h><br /><span style="color: #00D7D7;">#include</span> <hbapiitm.h><br /><span style="color: #00D7D7;">#include</span> <hbstack.h><br /><br />typedef struct <span style="color: #000000;">&#123;</span><br />    int x;<br />    int y;<br /><span style="color: #000000;">&#125;</span> Point;<br /><br /><span style="color: #B900B9;">// Set the x value for the Point object</span><br />HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> POINT_SETX <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   PHB_ITEM pSelf = hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />   Point * p;<br /><br />   hb_arrayGet<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, hb_stackReturnItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />   p = hb_parptr<span style="color: #000000;">&#40;</span> <span style="color: #000000;">-1</span> <span style="color: #000000;">&#41;</span>;<br /><br />   <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span><br />   <span style="color: #000000;">&#123;</span><br />      hb_retni<span style="color: #000000;">&#40;</span> p->x <span style="color: #000000;">&#41;</span>;<br />      p->x = hb_parni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br />   <span style="color: #000000;">&#125;</span><br />   <span style="color: #00C800;">else</span> <br />      hb_retni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>; <span style="color: #B900B9;">// raise an error ?   </span><br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">// Get the x value from the Point object</span><br />HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> POINT_GETX <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   PHB_ITEM pSelf = hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />   Point * p;<br /><br />   hb_arrayGet<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, hb_stackReturnItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />   p = hb_parptr<span style="color: #000000;">&#40;</span> <span style="color: #000000;">-1</span> <span style="color: #000000;">&#41;</span>;<br /><br />   <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span><br />      hb_retni<span style="color: #000000;">&#40;</span> p->x <span style="color: #000000;">&#41;</span>;<br />   <span style="color: #00C800;">else</span> <br />      hb_retni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>; <span style="color: #B900B9;">// raise an error ? </span><br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">// Set the y value for the Point object</span><br />HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> POINT_SETY <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   PHB_ITEM pSelf = hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />   Point * p;<br /><br />   hb_arrayGet<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, hb_stackReturnItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />   p = hb_parptr<span style="color: #000000;">&#40;</span> <span style="color: #000000;">-1</span> <span style="color: #000000;">&#41;</span>;<br /><br />   <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span><br />   <span style="color: #000000;">&#123;</span><br />      hb_retni<span style="color: #000000;">&#40;</span> p->y <span style="color: #000000;">&#41;</span>;<br />      p->y = hb_parni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br />   <span style="color: #000000;">&#125;</span><br />   <span style="color: #00C800;">else</span> <br />      hb_retni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>; <span style="color: #B900B9;">// raise an error ?   </span><br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">// Get the y value from the Point object</span><br />HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> POINT_GETY <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   PHB_ITEM pSelf = hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />   Point * p;<br /><br />   hb_arrayGet<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, hb_stackReturnItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />   p = hb_parptr<span style="color: #000000;">&#40;</span> <span style="color: #000000;">-1</span> <span style="color: #000000;">&#41;</span>;<br /><br />   <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span><br />      hb_retni<span style="color: #000000;">&#40;</span> p->y <span style="color: #000000;">&#41;</span>;<br />   <span style="color: #00C800;">else</span> <br />      hb_retni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>; <span style="color: #B900B9;">// raise an error ? </span><br /><span style="color: #000000;">&#125;</span><br /><br />HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> POINT_NEW <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />    PHB_ITEM pSelf = hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />    Point * p = <span style="color: #000000;">&#40;</span> Point * <span style="color: #000000;">&#41;</span> hb_xgrab<span style="color: #000000;">&#40;</span> sizeof<span style="color: #000000;">&#40;</span> Point <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><br />    p->x = hb_parni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br />    p->y = hb_parni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span>;<br /><br />    hb_arraySetPtr<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, p <span style="color: #000000;">&#41;</span>;<br />    hb_itemReturn<span style="color: #000000;">&#40;</span> pSelf <span style="color: #000000;">&#41;</span>;  <span style="color: #B900B9;">// return Self</span><br /><span style="color: #000000;">&#125;</span><br /><br />HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> POINT_DESTROY <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   PHB_ITEM pSelf = hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />   PHB_ITEM p = hb_itemNew<span style="color: #000000;">&#40;</span> <span style="color: #00C800;">NULL</span> <span style="color: #000000;">&#41;</span>;<br /><br />   hb_arrayGet<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, p <span style="color: #000000;">&#41;</span>;<br />   <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> hb_itemGetPtr<span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />   <span style="color: #000000;">&#123;</span><br />      hb_xfree<span style="color: #000000;">&#40;</span> hb_itemGetPtr<span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />      hb_arraySetPtr<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, <span style="color: #00C800;">NULL</span> <span style="color: #000000;">&#41;</span>;<br />   <span style="color: #000000;">&#125;</span>   <br />   hb_itemRelease<span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br />HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> POINT_GETPOINTDATA <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   PHB_ITEM pSelf = hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br /><br />   hb_arrayGet<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, hb_stackReturnItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;  <span style="color: #B900B9;">// 1 for first DATA</span><br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">// class creation</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> POINT <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   <span style="color: #00C800;">static</span> HB_USHORT uiClass = <span style="color: #000000;">0</span>;<br /><br />   <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> uiClass == <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span><br />   <span style="color: #000000;">&#123;</span><br />      uiClass = hb_clsCreate<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span>, <span style="color: #ff0000;">"POINT"</span> <span style="color: #000000;">&#41;</span>; <span style="color: #B900B9;">// just one DATA</span><br />      <span style="color: #B900B9;">// Add methods to the class</span><br />      hb_clsAdd<span style="color: #000000;">&#40;</span> uiClass, <span style="color: #ff0000;">"POINTDATA"</span>, HB_FUNCNAME<span style="color: #000000;">&#40;</span> POINT_GETPOINTDATA <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;  <span style="color: #B900B9;">// the only DATA we are using</span><br />      hb_clsAdd<span style="color: #000000;">&#40;</span> uiClass, <span style="color: #ff0000;">"_X"</span>, HB_FUNCNAME<span style="color: #000000;">&#40;</span> POINT_SETX <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />      hb_clsAdd<span style="color: #000000;">&#40;</span> uiClass, <span style="color: #ff0000;">"X"</span>, HB_FUNCNAME<span style="color: #000000;">&#40;</span> POINT_GETX <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />      hb_clsAdd<span style="color: #000000;">&#40;</span> uiClass, <span style="color: #ff0000;">"_Y"</span>, HB_FUNCNAME<span style="color: #000000;">&#40;</span> POINT_SETY <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />      hb_clsAdd<span style="color: #000000;">&#40;</span> uiClass, <span style="color: #ff0000;">"Y"</span>, HB_FUNCNAME<span style="color: #000000;">&#40;</span> POINT_GETY <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />      hb_clsAdd<span style="color: #000000;">&#40;</span> uiClass, <span style="color: #ff0000;">"DESTROY"</span>, HB_FUNCNAME<span style="color: #000000;">&#40;</span> POINT_DESTROY <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />      hb_clsAdd<span style="color: #000000;">&#40;</span> uiClass, <span style="color: #ff0000;">"NEW"</span>, HB_FUNCNAME<span style="color: #000000;">&#40;</span> POINT_NEW <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />   <span style="color: #000000;">&#125;</span><br /><br />   <span style="color: #B900B9;">// create the object</span><br />   hb_clsAssociate<span style="color: #000000;">&#40;</span> uiClass <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span></div>[/code:1k9e44vm]
create a Harbour class from C code
Para facilitar el uso de la creación de clases Harbour desde lenguaje C yo uso este fichero include [code=fw:1e0yi447]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #B900B9;">/***<br />&nbsp;* Proyecto: Clases HARBOUR desde C<br />&nbsp;* Fichero: myclass.h<br />&nbsp;* Descripcion: Implementacion clases HARBOUR en C<br />&nbsp;* Autor: Manu Exposito 2014-22<br />&nbsp;* Version 22.10<br />&nbsp;* Fecha: 07/10/2022<br />&nbsp;*/</span><br /><br /><span style="color: #00D7D7;">#pragma</span> once<br />#ifndef MYCLASS_H<br /><span style="color: #00D7D7;">#define</span> MYCLASS_H<br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"hbapicls.h"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"hbdefs.h"</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Declaracion de clases desde C</span><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><br /><span style="color: #00D7D7;">#define</span> DEFINE_CLASS<span style="color: #000000;">&#40;</span> clsName, uiVar <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; <span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> clsName <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #00C800;">static</span> HB_USHORT usClassH = <span style="color: #000000;">0</span>; \<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> usClassH == <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> usClassH = hb_clsCreate<span style="color: #000000;">&#40;</span> uiVar, #clsName <span style="color: #000000;">&#41;</span>;<br /><span style="color: #00D7D7;">#define</span> CREATE_CLASS<span style="color: #000000;">&#40;</span> clsName, uiVar <span style="color: #000000;">&#41;</span>&nbsp; DEFINE_CLASS<span style="color: #000000;">&#40;</span> clsName , uiVar <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">/* Esta es para DATAs que van a tener una funcion get y otra set */</span><br /><span style="color: #00D7D7;">#define</span> <span style="color: #0000ff;">VAR</span><span style="color: #000000;">&#40;</span> clsName, szDataName, pGetFuncName, pSetFuncName <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; hb_clsAdd<span style="color: #000000;">&#40;</span> usClassH, #szDataName, HB_FUNCNAME<span style="color: #000000;">&#40;</span> clsName##_##pGetFuncName <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>; \<br />&nbsp; &nbsp; hb_clsAdd<span style="color: #000000;">&#40;</span> usClassH, <span style="color: #ff0000;">"_"</span>#szDataName, HB_FUNCNAME<span style="color: #000000;">&#40;</span> clsName##_##pSetFuncName <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><span style="color: #00D7D7;">#define</span> <span style="color: #00C800;">DATA</span><span style="color: #000000;">&#40;</span> szDataName, pGetFuncName, pSetFuncName <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; <span style="color: #0000ff;">VAR</span><span style="color: #000000;">&#40;</span> szDataName, pGetFuncName, pSetFuncName <span style="color: #000000;">&#41;</span>;<br /><span style="color: #B900B9;">/* Esta es para DATAs que van a tener una funcion unica para get y set */</span><br /><span style="color: #00D7D7;">#define</span> SETGETVAR<span style="color: #000000;">&#40;</span> clsName, szDataName, pFuncName <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; <span style="color: #0000ff;">VAR</span><span style="color: #000000;">&#40;</span> clsName, szDataName, pFuncName, pFuncName <span style="color: #000000;">&#41;</span>;<br /><span style="color: #00D7D7;">#define</span> SETGETDATA<span style="color: #000000;">&#40;</span> clsName, szDataName, pFuncName <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; <span style="color: #0000ff;">VAR</span><span style="color: #000000;">&#40;</span> clsName, szDataName, pFuncName, pFuncName <span style="color: #000000;">&#41;</span>;<br /><br /><span style="color: #B900B9;">/* Metodos */</span><br /><span style="color: #00D7D7;">#define</span> <span style="color: #00C800;">METHOD</span><span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; hb_clsAdd<span style="color: #000000;">&#40;</span> usClassH, #szName, HB_FUNCNAME<span style="color: #000000;">&#40;</span> clsName##_##szName <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><span style="color: #00D7D7;">#define</span> <span style="color: #0000ff;">MESSAGE</span><span style="color: #000000;">&#40;</span> clsName, szName, szMethod <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; hb_clsAdd<span style="color: #000000;">&#40;</span> usClassH, #szName, HB_FUNCNAME<span style="color: #000000;">&#40;</span> clsName##_##szMethod <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><span style="color: #00D7D7;">#define</span> EXTERNAL_METHOD<span style="color: #000000;">&#40;</span> szName, pFuncName <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; hb_clsAdd<span style="color: #000000;">&#40;</span> usClassH, #szName, HB_FUNCNAME<span style="color: #000000;">&#40;</span> pFuncName <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><br /><span style="color: #00D7D7;">#define</span> END_CLASS <span style="color: #000000;">&#125;</span> hb_clsAssociate<span style="color: #000000;">&#40;</span> usClassH <span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Definicion de objetos de una clase</span><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><br /><span style="color: #B900B9;">/* Crea un objeto */</span><br /><span style="color: #00D7D7;">#define</span> HB_CREATE_OBJECT<span style="color: #000000;">&#40;</span> pCls, o <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; HB_FUNC_EXEC<span style="color: #000000;">&#40;</span> pCls <span style="color: #000000;">&#41;</span>; o = hb_itemNew<span style="color: #000000;">&#40;</span> hb_stackReturnItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">/* Crea un objeto a partir de un item ya existente */</span><br /><span style="color: #00D7D7;">#define</span> HB_CREATE_OBJECT_ITEM<span style="color: #000000;">&#40;</span> pCls, o <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; HB_FUNC_EXEC<span style="color: #000000;">&#40;</span> pCls <span style="color: #000000;">&#41;</span>; hb_itemMove<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>, hb_stackReturnItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// &nbsp;Varios</span><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><br /><span style="color: #B900B9;">/* Añade metodos a una clase pCls ya existente */</span><br /><span style="color: #00D7D7;">#define</span> ADD_METHOD<span style="color: #000000;">&#40;</span> pCls, szMethodName, pFuncName <span style="color: #000000;">&#41;</span> \<br />&nbsp; &nbsp; <span style="color: #000000;">&#40;</span> hb_clsAdd<span style="color: #000000;">&#40;</span> hb_objGetClass<span style="color: #000000;">&#40;</span> pCls <span style="color: #000000;">&#41;</span>, szMethodName, HB_FUNCNAME<span style="color: #000000;">&#40;</span> pFuncName <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">/* Obtiene Self en la implemantacion de los metodos de la clase */</span><br /><span style="color: #00D7D7;">#define</span> HB_PSELF<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_RETURNOBJ<span style="color: #000000;">&#40;</span> pSelf <span style="color: #000000;">&#41;</span>&nbsp; &nbsp;&nbsp; &nbsp; hb_itemReturnForward<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> pSelf <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_RETURNSELF<span style="color: #000000;">&#40;</span> pSelf <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; &nbsp; HB_RETURNOBJ<span style="color: #000000;">&#40;</span> pSelf <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">/* Implementacion */</span><br /><span style="color: #00D7D7;">#define</span> HB_METHOD<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; HB_FUNC_STATIC<span style="color: #000000;">&#40;</span> clsName##_##szName <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_PROCEDURE<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span>&nbsp;HB_METHOD<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00D7D7;">#define</span> HB_VAR<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span>&nbsp; &nbsp;HB_METHOD<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_DATA<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span>&nbsp; HB_METHOD<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">/* Propiedad reflexiva */</span><br /><span style="color: #00D7D7;">#define</span> HB_ISCLSOBJ<span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HB_IS_OBJECT<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_CLASSNAME<span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hb_objGetClsName<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_CLASSNAMESELF<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hb_stackSelfItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">/* Ejecuta un metodo del objeto pasado */</span><br /><span style="color: #00D7D7;">#define</span> HB_SENDMSG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hb_objSendMsg<br /><br /><span style="color: #B900B9;">/* Ejecuta metodos dentro de la clase */</span><br /><span style="color: #00D7D7;">#define</span> HB_SELF_EXEC<span style="color: #000000;">&#40;</span> clsName, mtd <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; HB_FUNC_EXEC<span style="color: #000000;">&#40;</span> clsName##_##mtd <span style="color: #000000;">&#41;</span> <br /><br /><span style="color: #B900B9;">/* Devuelve el nombre interno del metodo */</span><br /><span style="color: #00D7D7;">#define</span> HB_METHODNAME<span style="color: #000000;">&#40;</span> clsName, pName <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#40;</span> clsName##_##pName <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">/* Clona un objeto "o" con otro objeto "wo" */</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJCLONE<span style="color: #000000;">&#40;</span> o, wo <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hb_arrayCloneTo<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> wo <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">/* Obtiene el valor de una data directamente por su posicion */</span><br /><span style="color: #B900B9;">/* Nota: Devuelve un puntero.<br />&nbsp; &nbsp;void *HB_OBJGETPTR( PHB_ITEM obj, HB_UINT nPosData ) */</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJGETPTR<span style="color: #000000;">&#40;</span> o, n <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hb_arrayGetPtr<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> n <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">/* Nota: Devuelve un PHB_ITEM.<br />&nbsp; &nbsp;PHB_ITEM HB_OBJGETITEM( PHB_ITEM obj, HB_UINT nPosData ) */</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJGETITEM<span style="color: #000000;">&#40;</span> o, n <span style="color: #000000;">&#41;</span>&nbsp; &nbsp;&nbsp; &nbsp; hb_arrayGetItemPtr<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> n <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJGETDATA<span style="color: #000000;">&#40;</span> o, n <span style="color: #000000;">&#41;</span>&nbsp; &nbsp;&nbsp; &nbsp; HB_OBJGETITEM<span style="color: #000000;">&#40;</span> o, n <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJGETVAR<span style="color: #000000;">&#40;</span> o, n <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; HB_OBJGETITEM<span style="color: #000000;">&#40;</span> o, n <span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">/* Asigna un valor directamente a una data del objeto por su posicion */</span><br /><span style="color: #B900B9;">/* Este para asignar un puntero */</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJSETPTR<span style="color: #000000;">&#40;</span> o, n, p <span style="color: #000000;">&#41;</span>&nbsp;&nbsp; &nbsp; hb_arraySetPtr<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> n <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">/* Este para asignar un ITEM */</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJSETITEM<span style="color: #000000;">&#40;</span> o, n, v <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; hb_arraySet<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> o <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> n <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> v <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJSETDATA<span style="color: #000000;">&#40;</span> o, n, v <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; HB_OBJSETITEM<span style="color: #000000;">&#40;</span> o, n, v <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_OBJSETVAR<span style="color: #000000;">&#40;</span> o, n, v <span style="color: #000000;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HB_OBJSETITEM<span style="color: #000000;">&#40;</span> o, n, v <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br />#endif <span style="color: #B900B9;">/* MYCLASS_H */</span><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span></div>[/code:1e0yi447]
create a Harbour class from C code
Antonio me pidió que pusiese un ejemplo de myClass.h y aquí va, por cierto te neis que agregar una linea en myClass.h [code=fw:22ku25r4]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00D7D7;">#define</span> HB_VAR<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span>   HB_METHOD<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_DATA<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span>  HB_METHOD<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#define</span> HB_SETGETDATA<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span> HB_METHOD<span style="color: #000000;">&#40;</span> clsName, szName <span style="color: #000000;">&#41;</span> <span style="color: #B900B9;">// Esta linea hay que agregarla</span><br /> </div>[/code:22ku25r4] Vamos ver como se diseña una clase para usar desde PRG en C, se trata de un ejemplo de la clase TPoint [code=fw:22ku25r4]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00D7D7;">#include</span> <hbapi.h><br /><span style="color: #00D7D7;">#include</span> <hbapicls.h><br /><span style="color: #00D7D7;">#include</span> <hbapiitm.h><br /><span style="color: #00D7D7;">#include</span> <hbstack.h><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"myClass.h"</span><br /><br />typedef struct<br /><span style="color: #000000;">&#123;</span><br />    int x;<br />    int y;<br /><span style="color: #000000;">&#125;</span> Point;<br /><br /><span style="color: #B900B9;">//-----------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Predefinicion de las datas y metodos para poder usarlos en cualquier lugar </span><br /><span style="color: #B900B9;">// del codigo</span><br /><span style="color: #B900B9;">//-----------------------------------------------------------------------------</span><br /><br />HB_DATA<span style="color: #000000;">&#40;</span> TPOINT, GET_X <span style="color: #000000;">&#41;</span>;<br />HB_DATA<span style="color: #000000;">&#40;</span> TPOINT, SET_X <span style="color: #000000;">&#41;</span>;<br />HB_SETGETDATA<span style="color: #000000;">&#40;</span> TPOINT, GETSET_Y <span style="color: #000000;">&#41;</span>;<br />HB_METHOD<span style="color: #000000;">&#40;</span> TPOINT, <span style="color: #0000ff;">INIT</span> <span style="color: #000000;">&#41;</span>;<br />HB_METHOD<span style="color: #000000;">&#40;</span> TPOINT, END <span style="color: #000000;">&#41;</span>;<br /><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> QOUT <span style="color: #000000;">&#41;</span>;<br /><br /><span style="color: #B900B9;">//-----------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Definicion de la clase (funcion de clase)</span><br /><br />DEFINE_CLASS<span style="color: #000000;">&#40;</span> TPOINT, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span><br />    <span style="color: #B900B9;">// Datas:</span><br />    <span style="color: #0000ff;">VAR</span><span style="color: #000000;">&#40;</span> TPOINT, X, GET_X, SET_X <span style="color: #000000;">&#41;</span><br />    SETGETDATA<span style="color: #000000;">&#40;</span> TPOINT, Y, GETSET_Y <span style="color: #000000;">&#41;</span><br /><br />    <span style="color: #B900B9;">// Metodo constructor</span><br />    <span style="color: #00C800;">METHOD</span><span style="color: #000000;">&#40;</span> TPOINT, <span style="color: #0000ff;">INIT</span> <span style="color: #000000;">&#41;</span><br />    <span style="color: #0000ff;">MESSAGE</span><span style="color: #000000;">&#40;</span> TPOINT, <span style="color: #00C800;">NEW</span>, <span style="color: #0000ff;">INIT</span> <span style="color: #000000;">&#41;</span>   <span style="color: #B900B9;">// Sinonimo de init</span><br /><br />    EXTERNAL_METHOD<span style="color: #000000;">&#40;</span> <span style="color: #00C800;">DISPLAY</span>, QOUT <span style="color: #000000;">&#41;</span><br /><br />    <span style="color: #00C800;">METHOD</span><span style="color: #000000;">&#40;</span> TPOINT, END <span style="color: #000000;">&#41;</span><br />END_CLASS<br /><br /><span style="color: #B900B9;">//-----------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// DATAS</span><br /><span style="color: #B900B9;">//-----------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Por separado el GET y el SET</span><br /><br />HB_DATA<span style="color: #000000;">&#40;</span> TPOINT, GET_X <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />    PHB_ITEM pSelf = HB_PSELF<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />    Point *p = HB_OBJGETPTR<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br /><br />    hb_retni<span style="color: #000000;">&#40;</span> p->x <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><br />HB_DATA<span style="color: #000000;">&#40;</span> TPOINT, SET_X <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />    PHB_ITEM x = hb_param<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span>, HB_IT_INTEGER <span style="color: #000000;">&#41;</span>;<br /><br />    <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> x <span style="color: #000000;">&#41;</span><br />    <span style="color: #000000;">&#123;</span><br />        PHB_ITEM pSelf = HB_PSELF<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />        Point *p = HB_OBJGETPTR<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br /><br />        p->x = hb_itemGetNI<span style="color: #000000;">&#40;</span> x <span style="color: #000000;">&#41;</span>;<br />    <span style="color: #000000;">&#125;</span><br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Juntos el get y el set</span><br /><br />HB_SETGETDATA<span style="color: #000000;">&#40;</span> TPOINT, GETSET_Y <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />    PHB_ITEM pSelf = HB_PSELF<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />    Point *p = HB_OBJGETPTR<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br />    PHB_ITEM y = hb_param<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span>, HB_IT_INTEGER <span style="color: #000000;">&#41;</span>;<br /><br />    <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> y <span style="color: #000000;">&#41;</span> <span style="color: #B900B9;">// Si se pasa un valor es asignar</span><br />    <span style="color: #000000;">&#123;</span><br />        p->y = hb_itemGetNI<span style="color: #000000;">&#40;</span> y <span style="color: #000000;">&#41;</span>;<br />    <span style="color: #000000;">&#125;</span><br /><br />    <span style="color: #B900B9;">// Siempre vamos a devolver el valor de Y</span><br />    hb_retni<span style="color: #000000;">&#40;</span> p->y <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// METODOS</span><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><br />HB_METHOD<span style="color: #000000;">&#40;</span> TPOINT, <span style="color: #0000ff;">INIT</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />    PHB_ITEM pSelf = HB_PSELF<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />    Point *p = <span style="color: #000000;">&#40;</span> Point * <span style="color: #000000;">&#41;</span> hb_xgrab<span style="color: #000000;">&#40;</span> sizeof<span style="color: #000000;">&#40;</span> Point <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><br />    <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span><br />    <span style="color: #000000;">&#123;</span><br />        p->x = <span style="color: #000000;">0</span>;<br />        p->y = <span style="color: #000000;">0</span>;<br />    <span style="color: #000000;">&#125;</span><br /><br />    <span style="color: #B900B9;">// Asigna la estructura recien creada a la clase</span><br />    HB_OBJSETPTR<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, p <span style="color: #000000;">&#41;</span>;<br /><br />    <span style="color: #B900B9;">// Un constructor siempre devuelve SELF</span><br />    HB_RETURNSELF<span style="color: #000000;">&#40;</span> pSelf <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /><br />HB_METHOD<span style="color: #000000;">&#40;</span> TPOINT, END <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />    PHB_ITEM pSelf = HB_PSELF<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />    Point *p = <span style="color: #000000;">&#40;</span> Point * <span style="color: #000000;">&#41;</span> HB_OBJGETPTR<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br /><br />    <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span><br />    <span style="color: #000000;">&#123;</span><br />        hb_xfree<span style="color: #000000;">&#40;</span> p <span style="color: #000000;">&#41;</span>;<br />        HB_OBJSETPTR<span style="color: #000000;">&#40;</span> pSelf, <span style="color: #000000;">1</span>, <span style="color: #00C800;">NULL</span> <span style="color: #000000;">&#41;</span>;<br />    <span style="color: #000000;">&#125;</span><br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//------------------------------------------------------------------------------</span><br /> </div>[/code:22ku25r4] y ahora un ejemplo de uso en el que se ve que funciona como una clase hecha en PRG: [code=fw:22ku25r4]<div class="fw" id="{CB}" style="font-family: monospace;">procedure main<br /><br />    <span style="color: #00C800;">local</span> p := Tpoint<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #00C800;">new</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />    Cls<br /><br />    p:<span style="color: #00C800;">display</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"Antes de asignar"</span> <span style="color: #000000;">&#41;</span><br />    p:<span style="color: #00C800;">display</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"x"</span>, p:<span style="color: #000000;">x</span> <span style="color: #000000;">&#41;</span><br />    p:<span style="color: #00C800;">display</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"y"</span>, p:<span style="color: #000000;">y</span> <span style="color: #000000;">&#41;</span><br /><br />    p:<span style="color: #000000;">x</span> := <span style="color: #000000;">10</span><br />    p:<span style="color: #000000;">y</span> := <span style="color: #000000;">25</span><br /><br />    p:<span style="color: #00C800;">display</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"Despues de asignar"</span> <span style="color: #000000;">&#41;</span><br />    p:<span style="color: #00C800;">display</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"x"</span>, p:<span style="color: #000000;">x</span> <span style="color: #000000;">&#41;</span><br />    p:<span style="color: #00C800;">display</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"y"</span>, p:<span style="color: #000000;">y</span> <span style="color: #000000;">&#41;</span><br /><br />    p:<span style="color: #000000;">end</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />    inkey<span style="color: #000000;">&#40;</span> <span style="color: #000000;">100</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00C800;">return</span><br /> </div>[/code:22ku25r4] Posiblemente sólo deberíais hacer eso en clases crítica para acelerar el proceso o si estais familiarizados con el Lenguaje C. Salu2
create a desktop shortcut directly from the program
I have a program that will set up 4 identical programs (exes) in 4 folders on a net work. Is there a way to set up a shortcut on the network directly from the program to the copies of the exes in their separate folders???
create a desktop shortcut directly from the program
Harvey, Can you just do that with the install program? Regards, James
create a desktop shortcut directly from the program
James took your advice and programmed the install to do what I wank. Thanks.
create a desktop shortcut directly from the program
Try: cUser:= GetEnv( "USERPROFILE" ) I f Left(cUser,8)="C:\Users" //Language of SO cEscritorio:=cUser+"\desktop\file.lnk" Else cEscritorio:=cUser+"\escritorio\file.lnk" Endif COPY FILE C:\FILE.LNK TO (cEscritorio)
create a desktop shortcut directly from the program
You can try:: File: "shortcut.c" [code=fw:2xq917ou]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00D7D7;">#pragma</span> BEGINDUMP<br /><br /><span style="color: #00D7D7;">#define</span> _WIN32_IE 0x0500<br /><span style="color: #00D7D7;">#define</span> HB_OS_WIN_32_USED<br /><span style="color: #00D7D7;">#define</span> _WIN32_WINNT 0x0400<br /><br /><br /><span style="color: #00D7D7;">#include</span> <windows.h><br /><span style="color: #00D7D7;">#include</span> <commctrl.h><br /><span style="color: #00D7D7;">#include</span> <shlobj.h><br /><span style="color: #00D7D7;">#include</span> <hbapi.h><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"hbstack.h"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"hbapiitm.h"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"winreg.h"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"tchar.h"</span><br /><br /><br /><span style="color: #00D7D7;">#define</span> HB_OS_WIN_32_USED<br /><br /><span style="color: #00D7D7;">#define</span> _WIN32_WINNT 0x0400<br /><span style="color: #B900B9;">// #define OEMRESOURCE</span><br /><span style="color: #00D7D7;">#include</span> <windows.h><br /><span style="color: #00D7D7;">#include</span> <shlobj.h><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"hbapi.h"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"hbapiitm.h"</span><br /><br /><span style="color: #00D7D7;">#define</span>  ID_NOTIFYICON   <span style="color: #000000;">1</span><br /><span style="color: #00D7D7;">#define</span>  WM_NOTIFYICON   WM_USER<span style="color: #000000;">+1000</span><br /><br />#ifndef BIF_USENEWUI<br />#ifndef BIF_NEWDIALOGSTYLE<br /><span style="color: #00D7D7;">#define</span> BIF_NEWDIALOGSTYLE     0x0040   <span style="color: #B900B9;">// Use the new dialog layout with the ability to resize</span><br />#endif<br /><span style="color: #00D7D7;">#define</span> BIF_USENEWUI           <span style="color: #000000;">&#40;</span>BIF_NEWDIALOGSTYLE | BIF_EDITBOX<span style="color: #000000;">&#41;</span><br />#endif<br /><br /><br /><br /><span style="color: #B900B9;">// link executor *******************</span><br />void ChangePIF<span style="color: #000000;">&#40;</span>LPCSTR cPIF<span style="color: #000000;">&#41;</span>;<br />HRESULT WINAPI CreateLink<span style="color: #000000;">&#40;</span>LPSTR lpszLink, LPSTR lpszPathObj,LPSTR szWorkPath,LPSTR lpszIco, int nIco,LPSTR szDescription<span style="color: #000000;">&#41;</span>;<br /><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> CREATEFILELINK <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   hb_retnl<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span>LONG<span style="color: #000000;">&#41;</span> CreateLink<span style="color: #000000;">&#40;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>, hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span>, hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000;">&#41;</span>,hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">4</span><span style="color: #000000;">&#41;</span>, hb_parni<span style="color: #000000;">&#40;</span><span style="color: #000000;">5</span><span style="color: #000000;">&#41;</span> ,hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">6</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br />void ChangePIF<span style="color: #000000;">&#40;</span>LPCSTR cPIF<span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   UCHAR buffer<span style="color: #000000;">&#91;</span><span style="color: #000000;">1024</span><span style="color: #000000;">&#93;</span>;<br />   HFILE h;<br />   long filesize;<br />   <br />   strcpy<span style="color: #000000;">&#40;</span>buffer, cPIF<span style="color: #000000;">&#41;</span>;<br />   strcat<span style="color: #000000;">&#40;</span>buffer, <span style="color: #ff0000;">".pif"</span><span style="color: #000000;">&#41;</span>;<br />   <span style="color: #00C800;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>h=_lopen<span style="color: #000000;">&#40;</span>buffer, <span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span><br />   <span style="color: #000000;">&#123;</span><br />      filesize=_hread<span style="color: #000000;">&#40;</span>h, &buffer, <span style="color: #000000;">1024</span><span style="color: #000000;">&#41;</span>;<br />      buffer<span style="color: #000000;">&#91;</span>0x63<span style="color: #000000;">&#93;</span>=0x10; <span style="color: #B900B9;">// Cerrar al salir</span><br />      buffer<span style="color: #000000;">&#91;</span>0x1ad<span style="color: #000000;">&#93;</span>=0x0a; <span style="color: #B900B9;">// Pantalla completa</span><br />      buffer<span style="color: #000000;">&#91;</span>0x2d4<span style="color: #000000;">&#93;</span>=0x01;<br />      buffer<span style="color: #000000;">&#91;</span>0x2c5<span style="color: #000000;">&#93;</span>=0x22; <span style="color: #B900B9;">// No Permitir protector de pantalla</span><br />      buffer<span style="color: #000000;">&#91;</span>0x1ae<span style="color: #000000;">&#93;</span>=0x11; <span style="color: #B900B9;">// Quitar ALT+ENTRAR</span><br />      buffer<span style="color: #000000;">&#91;</span>0x2e0<span style="color: #000000;">&#93;</span>=0x01;<br />      _llseek<span style="color: #000000;">&#40;</span>h, <span style="color: #000000;">0</span>, <span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span>;<br />      _hwrite<span style="color: #000000;">&#40;</span>h, buffer, filesize<span style="color: #000000;">&#41;</span>;<br />      _lclose<span style="color: #000000;">&#40;</span>h<span style="color: #000000;">&#41;</span>;<br />   <span style="color: #000000;">&#125;</span><br /><span style="color: #000000;">&#125;</span><br /><br /><br /><span style="color: #B900B9;">// Canviem el pif</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> CHANGE_PIF <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   ChangePIF<span style="color: #000000;">&#40;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>   ;<br /><span style="color: #000000;">&#125;</span><br /><br /><br />HRESULT WINAPI CreateLink<span style="color: #000000;">&#40;</span>LPSTR lpszLink, LPSTR lpszPathObj,LPSTR  szWorkPath,LPSTR lpszIco, int nIco,LPSTR szDescription<span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   long hres;<br />   IShellLink * psl;<br /><br />   hres = CoInitialize<span style="color: #000000;">&#40;</span><span style="color: #00C800;">NULL</span><span style="color: #000000;">&#41;</span>;<br />   <span style="color: #00C800;">if</span> <span style="color: #000000;">&#40;</span>SUCCEEDED<span style="color: #000000;">&#40;</span>hres<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />   <span style="color: #000000;">&#123;</span><br />      hres = CoCreateInstance<span style="color: #000000;">&#40;</span>&CLSID_ShellLink, <span style="color: #00C800;">NULL</span>, CLSCTX_INPROC_SERVER, &IID_IShellLink, <span style="color: #000000;">&#40;</span> LPVOID <span style="color: #000000;">&#41;</span> &psl<span style="color: #000000;">&#41;</span>;<br /><br />      <span style="color: #00C800;">if</span> <span style="color: #000000;">&#40;</span>SUCCEEDED<span style="color: #000000;">&#40;</span>hres<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />      <span style="color: #000000;">&#123;</span><br /><br />         IPersistFile * ppf;<br /><br />         psl->lpVtbl->SetPath<span style="color: #000000;">&#40;</span>psl, lpszPathObj<span style="color: #000000;">&#41;</span>;<br />         psl->lpVtbl->SetIconLocation<span style="color: #000000;">&#40;</span>psl, lpszIco, nIco<span style="color: #000000;">&#41;</span>;<br />         psl->lpVtbl->SetWorkingDirectory<span style="color: #000000;">&#40;</span>psl, szWorkPath<span style="color: #000000;">&#41;</span>;<br />         psl->lpVtbl->SetDescription<span style="color: #000000;">&#40;</span>psl,szDescription<span style="color: #000000;">&#41;</span>;<br /><br />         hres = psl->lpVtbl->QueryInterface<span style="color: #000000;">&#40;</span>psl, &IID_IPersistFile,<span style="color: #000000;">&#40;</span> LPVOID <span style="color: #000000;">&#41;</span> &ppf<span style="color: #000000;">&#41;</span>;<br /><br />         <span style="color: #00C800;">if</span> <span style="color: #000000;">&#40;</span>SUCCEEDED<span style="color: #000000;">&#40;</span>hres<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />         <span style="color: #000000;">&#123;</span><br />            WORD wsz<span style="color: #000000;">&#91;</span>MAX_PATH<span style="color: #000000;">&#93;</span>;<br />            char appPath<span style="color: #000000;">&#91;</span>MAX_PATH<span style="color: #000000;">&#93;</span>;<br />   <br />            strcpy<span style="color: #000000;">&#40;</span>appPath, lpszLink<span style="color: #000000;">&#41;</span>;<br />            strcat<span style="color: #000000;">&#40;</span>appPath, <span style="color: #ff0000;">".lnk"</span><span style="color: #000000;">&#41;</span>;<br /><br />            MultiByteToWideChar<span style="color: #000000;">&#40;</span>CP_ACP, <span style="color: #000000;">0</span>, appPath, <span style="color: #000000;">-1</span>, wsz, MAX_PATH<span style="color: #000000;">&#41;</span>;<br /><br />            hres = ppf->lpVtbl->Save<span style="color: #000000;">&#40;</span>ppf, wsz, <span style="color: #00C800;">TRUE</span><span style="color: #000000;">&#41;</span>;<br />            ppf->lpVtbl->Release<span style="color: #000000;">&#40;</span>ppf<span style="color: #000000;">&#41;</span>;<br /><br />            <span style="color: #B900B9;">// modificar el PIF para los programas MS-DOS</span><br />            ChangePIF<span style="color: #000000;">&#40;</span>lpszLink<span style="color: #000000;">&#41;</span>;<br /><br />         <span style="color: #000000;">&#125;</span><br />         psl->lpVtbl->Release<span style="color: #000000;">&#40;</span>psl<span style="color: #000000;">&#41;</span>;<br />      <span style="color: #000000;">&#125;</span><br />      CoUninitialize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />   <span style="color: #000000;">&#125;</span><br />   <span style="color: #00C800;">return</span> hres;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> C_GETSPECIALFOLDER <span style="color: #000000;">&#41;</span> <span style="color: #B900B9;">// Contributed By Ryszard RyRko</span><br /><span style="color: #000000;">&#123;</span><br />    char *lpBuffer = <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_xgrab<span style="color: #000000;">&#40;</span> MAX_PATH<span style="color: #000000;">+1</span><span style="color: #000000;">&#41;</span>;<br />    LPITEMIDLIST pidlBrowse;    <span style="color: #B900B9;">// PIDL selected by user</span><br />    SHGetSpecialFolderLocation<span style="color: #000000;">&#40;</span>GetActiveWindow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, hb_parni<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>, &pidlBrowse<span style="color: #000000;">&#41;</span>  <br />;<br />    SHGetPathFromIDList<span style="color: #000000;">&#40;</span>pidlBrowse, lpBuffer<span style="color: #000000;">&#41;</span>;<br />    hb_retc<span style="color: #000000;">&#40;</span>lpBuffer<span style="color: #000000;">&#41;</span>;<br />    hb_xfree<span style="color: #000000;">&#40;</span> lpBuffer<span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">// eop link executor *******************</span><br /><br /><br /><span style="color: #00D7D7;">#pragma</span> ENDDUMP-------------------------------------------------------<br /><br /> </div>[/code:2xq917ou] Prg file : XXX.prg [code=fw:2xq917ou]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><br />*-------------------------------------------------------<br />Procedure CreateLink<span style="color: #000000;">&#40;</span> lDesk, lMenu <span style="color: #000000;">&#41;</span><br />*--------------------------------------------------------*<br /><span style="color: #00C800;">local</span> cDesktop := GetSpecialFolder<span style="color: #000000;">&#40;</span> CSIDL_DESKTOPDIRECTORY <span style="color: #000000;">&#41;</span><br /><span style="color: #00C800;">local</span> cMenuPrgs := GetSpecialFolder<span style="color: #000000;">&#40;</span> CSIDL_PROGRAMS <span style="color: #000000;">&#41;</span><br /><span style="color: #00C800;">local</span> cLinkName := <span style="color: #ff0000;">"proves"</span><br /><span style="color: #00C800;">local</span> cExeName := ExeName<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><span style="color: #00C800;">Local</span> cFilePath<br /><span style="color: #00C800;">local</span> cIco := <span style="color: #ff0000;">""</span><br /><br /><br /><span style="color: #00C800;">If</span> CurDrive<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> = <span style="color: #ff0000;">"@"</span><br />   cFilePath:= NetRmtName<span style="color: #000000;">&#40;</span> CurDrive<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>+<span style="color: #ff0000;">":"</span> <span style="color: #000000;">&#41;</span>+<span style="color: #ff0000;">"<span style="color: #000000;">\"</span>+CURDIR()<br />Else<br />   cFilePath:= CurDrive()+"</span>:\<span style="color: #ff0000;">"+CURDIR()<br />EndIf   <br /><br />cIco := cExeName<br /><br />if lDesk && desktop<br />   if CreateFileLink( cDesktop + "</span>\<span style="color: #ff0000;">" + cLinkName, cExeName,cFilePath,cIco ) # 0<br />      Duda( "</span>Create Link Error!<span style="color: #ff0000;">", "</span>Acceptar<span style="color: #ff0000;">")<br />   endif<br />endif<br /><br />if lMenu && menu start<br />   if CreateFileLink( cMenuPrgs + "</span>\<span style="color: #ff0000;">" + cLinkName, cExeName,cFilePath,cIco ) # 0<br />      Duda( "</span>Create Link Error!<span style="color: #ff0000;">", "</span>Acceptar<span style="color: #ff0000;">")<br />   endif<br />endif<br /><br />Return<br /><br /></span></div>[/code:2xq917ou] I hope that you have helped. Pere
create a desktop shortcut directly from the program
Thank you all for the help. Working great.
create a desktop shortcut directly from the program
Hi, You can even try this simple class. Works great. - Ramesh Babu [code=fw:3os4z3d4]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"FiveWin.ch"</span> <br /><br />*****************************************************************************<br />*** <span style="color: #00C800;">Class</span>         : <span style="color: #000000;">ZLnk</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>                                                ***<br />*** Descripction  : <span style="color: #0000ff;">To</span> Create Shortcut Links                              ***<br />*** Author        : <span style="color: #000000;">Carles</span> Aubia                                          *** <br />*** Created <span style="color: #0000ff;">on</span>    : <span style="color: #000000;">04.07</span><span style="color: #000000;">.2006</span>                                            ***<br />*****************************************************************************<br /><br /><span style="color: #00C800;">FUNCTION</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <br /><br /><span style="color: #00C800;">LOCAL</span> o <br /><br />o := ZLnk<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">'C:<span style="color: #000000;">\W</span>indows<span style="color: #000000;">\s</span>ystem32<span style="color: #000000;">\n</span>otepad.exe'</span> <span style="color: #000000;">&#41;</span> <br /><br />o:<span style="color: #000000;">cFolder</span> := <span style="color: #ff0000;">'Programs'</span> <span style="color: #B900B9;">//o:cFolder := 'DeskTop' or 'StartMenu' or 'StartUp' or 'Programs' </span><br /><br />o:<span style="color: #000000;">Run</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <br /><br /><span style="color: #B900B9;">/*<br />o := ZLnk():New( 'C:\xHarbour\bin\Harbour.exe' ) <br />o:cNameLnk          := 'Harbour.lnk'<br />o:cFolder           := 'DeskTop'  <br />o:cDescription      := 'xHarbour'<br />o:cWorkingDirectory := o:cFolder<br />o:cIconLocation     :='C:\xHarbour\bin' <br />o:cHotKey           := "CTRL+SHIFT+H" <br />o:Run() <br />*/</span><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">nil</span> <br /><br />*****************************************************************************<br />*** ZLnk <span style="color: #00C800;">Class</span>                                                            ***                    <br />*****************************************************************************<br /><br /><span style="color: #00C800;">CLASS</span> ZLnk <br /><br /><span style="color: #00C800;">DATA</span> cFolder            AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">'Desktop'</span> <br /><span style="color: #00C800;">DATA</span> cWindowStyle       AS NUMERIC   <span style="color: #0000ff;">INIT</span> <span style="color: #000000;">1</span> <br /><span style="color: #00C800;">DATA</span> cFile              AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span> <br /><span style="color: #00C800;">DATA</span> cWorkingDirectory  AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span> <br /><span style="color: #00C800;">DATA</span> cDescription       AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span> <br /><span style="color: #00C800;">DATA</span> cIconLocation      AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span> <br /><span style="color: #00C800;">DATA</span> cNameLnk           AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span> <br /><span style="color: #00C800;">DATA</span> cHotKey            AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span> <br /><br /><span style="color: #00C800;">METHOD</span> <span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> cFile <span style="color: #000000;">&#41;</span>  CONSTRUCTOR <br /><br /><span style="color: #00C800;">METHOD</span> Run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <br /><br /><span style="color: #00C800;">ENDCLASS</span> <br /><br />*****************************************************************************<br />*** <span style="color: #00C800;">METHOD</span> <span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> cFile <span style="color: #000000;">&#41;</span> <span style="color: #00C800;">CLASS</span> ZLnk                                        *** <br />*****************************************************************************<br /><br /><span style="color: #00C800;">METHOD</span> <span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> cFile <span style="color: #000000;">&#41;</span> <span style="color: #00C800;">CLASS</span> ZLnk <br /><br />::<span style="color: #000000;">cFile</span> := cFile <br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">Self</span> <br /><br />*****************************************************************************<br />*** <span style="color: #00C800;">METHOD</span> Run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #00C800;">CLASS</span> ZLnk                                               ***<br />*****************************************************************************<br /><br /><span style="color: #00C800;">METHOD</span> Run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #00C800;">CLASS</span> ZLnk <br /><br /><span style="color: #00C800;">LOCAL</span> oShell, oSF, o<br /><span style="color: #00C800;">LOCAL</span> cTarget <br /><br /><span style="color: #00C800;">IF</span> !File<span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cFile</span> <span style="color: #000000;">&#41;</span> <br />   <span style="color: #00C800;">RETURN</span> .F. <br /><span style="color: #00C800;">ENDIF</span> <br /><br /><span style="color: #00C800;">IF</span> Empty<span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cNameLnk</span> <span style="color: #000000;">&#41;</span> <br />   ::<span style="color: #000000;">cNameLnk</span> := cFileNoExt<span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cFile</span> <span style="color: #000000;">&#41;</span> + <span style="color: #ff0000;">'.lnk'</span> <br /><span style="color: #00C800;">ENDIF</span> <br /><br />oShell := TOleAuto<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"WScript.Shell"</span> <span style="color: #000000;">&#41;</span> <br /><br /><span style="color: #00C800;">IF</span> oShell:<span style="color: #000000;">hObj</span> == <span style="color: #000000;">0</span> <br />   <span style="color: #00C800;">RETURN</span> .F. <br /><span style="color: #00C800;">ENDIF</span> <br /><br />oSF     := oShell:<span style="color: #0000ff;">Get</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">'SpecialFolders'</span> <span style="color: #000000;">&#41;</span> <br />cTarget := oSF:<span style="color: #000000;">Item</span><span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cFolder</span> <span style="color: #000000;">&#41;</span> <br /><br /><span style="color: #00C800;">IF</span> Empty<span style="color: #000000;">&#40;</span> cTarget <span style="color: #000000;">&#41;</span> <br />   <span style="color: #00C800;">RETURN</span> .F. <br /><span style="color: #00C800;">ENDIF</span> <br /><br />o := oShell:<span style="color: #000000;">CreateShortCut</span><span style="color: #000000;">&#40;</span> cTarget + <span style="color: #ff0000;">'<span style="color: #000000;">\'</span> + ::cNameLnk ) <br /><br />o:WindowStyle      := ::cWindowStyle <br />o:TargetPath       := ::cFile <br />o:WorkingDirectory := ::cWorkingDirectory <br />o:Description      := ::cDescription <br />*o:IconLocation     := ::cIconLocation <br />o:HotKey           := ::cHotKey <br /><br />o:Save() <br /><br />RETURN .T. <br /><br />**************************<br />*** EOF() SHORTCUT.PRG ***<br />**************************<br /><br /></span></div>[/code:3os4z3d4]
create a desktop shortcut directly from the program
Ramesh Babu, Alright?, this post is from 2011, and I tried to run it on Windows 7 32bits and I did as in the example, but it does not create the shortcut. Do you remember this post? <!-- s:?: --><img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question" /><!-- s:?: --> <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: --> [code=fw:2tbk6jdy]<div class="fw" id="{CB}" style="font-family: monospace;"><br />* =======================================================================================<br /><span style="color: #00C800;">FUNCTION</span> CriaLink<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />* =======================================================================================<br />  <span style="color: #00C800;">local</span> o <br /><br />  o:= ZLnk<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> CurDrive<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> + <span style="color: #ff0000;">":"</span> + DirWin<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> + <span style="color: #ff0000;">"sisrevH.exe"</span> <span style="color: #000000;">&#41;</span>  <br />  o:<span style="color: #000000;">cWindowStyle</span>           := <span style="color: #000000;">1</span><br />  o:<span style="color: #000000;">cFolder</span>                := <span style="color: #ff0000;">"Desktop"</span><br />  o:<span style="color: #000000;">cNameLnk</span>               := <span style="color: #ff0000;">"Sisrev-Win.lnk"</span><br />  o:<span style="color: #000000;">cDescription</span>           := <span style="color: #ff0000;">"Aplicativo Sisrev-Win"</span><br />  o:<span style="color: #000000;">cWorkingDirectory</span>      := <span style="color: #ff0000;">"c:<span style="color: #000000;">\s</span>isrev<span style="color: #000000;">\w</span>in"</span><br />  o:<span style="color: #000000;">cIconLocation</span>          := DirWin<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />  o:<span style="color: #000000;">Run</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />  <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"Concluido"</span>,<span style="color: #ff0000;">"Sisrev-Ass"</span><span style="color: #000000;">&#41;</span><br />  <br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br />*=======================================================================================<br />*** ZLnk <span style="color: #00C800;">Class</span>                                                            ***                    <br />*=======================================================================================<br /><br /><span style="color: #00C800;">CLASS</span> ZLnk<br /><br /><span style="color: #00C800;">DATA</span> cFolder            AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">'Desktop'</span><br /><span style="color: #00C800;">DATA</span> cWindowStyle       AS NUMERIC   <span style="color: #0000ff;">INIT</span> <span style="color: #000000;">3</span><br /><span style="color: #00C800;">DATA</span> cFile              AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span><br /><span style="color: #00C800;">DATA</span> cWorkingDirectory  AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span><br /><span style="color: #00C800;">DATA</span> cDescription       AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span><br /><span style="color: #00C800;">DATA</span> cIconLocation      AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span><br /><span style="color: #00C800;">DATA</span> cNameLnk           AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span><br /><span style="color: #00C800;">DATA</span> cHotKey            AS CHARACTER <span style="color: #0000ff;">INIT</span> <span style="color: #ff0000;">''</span><br /><br /><span style="color: #00C800;">METHOD</span> <span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> cFile <span style="color: #000000;">&#41;</span>  CONSTRUCTOR<br /><br /><span style="color: #00C800;">METHOD</span> Run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00C800;">ENDCLASS</span><br /><br />*=======================================================================================<br /><span style="color: #00C800;">METHOD</span> <span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> cFile <span style="color: #000000;">&#41;</span> <span style="color: #00C800;">CLASS</span> ZLnk<br />*=======================================================================================<br />                              <br />  ::<span style="color: #000000;">cFile</span> := cFile<br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">Self</span><br /><br />*=======================================================================================<br /><span style="color: #00C800;">METHOD</span> Run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #00C800;">CLASS</span> ZLnk<br />*=======================================================================================<br />  <span style="color: #00C800;">local</span> oShell, oSF, o<br />  <span style="color: #00C800;">local</span> cTarget<br />  <br />  <span style="color: #00C800;">if</span> !File<span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cFile</span> <span style="color: #000000;">&#41;</span><br />     <span style="color: #00C800;">return</span> .F.<br />  <span style="color: #00C800;">Endif</span><br /><br />  <span style="color: #00C800;">if</span> Empty<span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cNameLnk</span> <span style="color: #000000;">&#41;</span><br />     ::<span style="color: #000000;">cNameLnk</span> := cFileNoExt<span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cFile</span> <span style="color: #000000;">&#41;</span> + <span style="color: #ff0000;">'.lnk'</span><br />  <span style="color: #00C800;">Endif</span><br />   <br />  <span style="color: #00C800;">TRY</span><br />    oShell := CreateObject<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"WScript.Shell"</span> <span style="color: #000000;">&#41;</span><br />  CATCH<br />      MsgAlert<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">'Error Create object WScript.Shell'</span>, <span style="color: #ff0000;">'Error'</span> <span style="color: #000000;">&#41;</span><br />      RETU  .F.<br />  END<br /><br />  oSF     := oShell:<span style="color: #0000ff;">Get</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">'SpecialFolders'</span> <span style="color: #000000;">&#41;</span><br />  cTarget := oSF:<span style="color: #000000;">Item</span><span style="color: #000000;">&#40;</span> ::<span style="color: #000000;">cFolder</span> <span style="color: #000000;">&#41;</span><br />  <br />  <span style="color: #00C800;">if</span> Empty<span style="color: #000000;">&#40;</span> cTarget <span style="color: #000000;">&#41;</span><br />     <span style="color: #00C800;">return</span> .F.<br />  <span style="color: #00C800;">Endif</span><br /><br />  o := oShell:<span style="color: #000000;">CreateShortCut</span><span style="color: #000000;">&#40;</span> cTarget + <span style="color: #ff0000;">''</span> + ::<span style="color: #000000;">cNameLnk</span> <span style="color: #000000;">&#41;</span> <br />  o:<span style="color: #000000;">WindowStyle</span>      := ::<span style="color: #000000;">cWindowStyle</span><br />  o:<span style="color: #000000;">TargetPath</span>       := ::<span style="color: #000000;">cFile</span><br />  o:<span style="color: #000000;">WorkingDirectory</span> := ::<span style="color: #000000;">cWorkingDirectory</span><br />  o:<span style="color: #000000;">Description</span>      := ::<span style="color: #000000;">cDescription</span><br />  o:<span style="color: #000000;">IconLocation</span>     := ::<span style="color: #000000;">cIconLocation</span><br />  o:<span style="color: #000000;">HotKey</span>           := ::<span style="color: #000000;">cHotKey</span><br />  <br />  o:<span style="color: #000000;">Save</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />  <br /><span style="color: #00C800;">return</span> .T.<br /><br /> </div>[/code:2tbk6jdy]
create a desktop shortcut directly from the program
hi, try this without HB_FUNC [code=fw:1pt9at6h]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> DXE_CreateLink<span style="color: #000000;">&#40;</span> cLinkTarget, cLinkFile, cWorkingDir, cCmdArgs, cDescr, aHotKey, aIcon <span style="color: #000000;">&#41;</span><br /><span style="color: #00C800;">LOCAL</span> lSuccess       := .F.<br /><span style="color: #00C800;">LOCAL</span> nPosi          := <span style="color: #000000;">0</span><br /><span style="color: #00C800;">LOCAL</span> cPath          := <span style="color: #ff0000;">""</span><br /><span style="color: #00C800;">LOCAL</span> cFile          := <span style="color: #ff0000;">""</span><br /><span style="color: #00C800;">LOCAL</span> cName          := <span style="color: #ff0000;">""</span><br /><span style="color: #00C800;">LOCAL</span> oShell<br /><span style="color: #00C800;">LOCAL</span> oFolder<br /><span style="color: #00C800;">LOCAL</span> oStorageFolder<br /><span style="color: #00C800;">LOCAL</span> oShellLink<br /><span style="color: #00C800;">LOCAL</span> nHandle<br /><span style="color: #00C800;">LOCAL</span> i, iMax<br /><span style="color: #00C800;">LOCAL</span> nLoByte<br /><span style="color: #00C800;">LOCAL</span> nHiByte<br /><br />   <span style="color: #00C800;">DEFAULT</span> cWorkingDir <span style="color: #0000ff;">TO</span> <span style="color: #ff0000;">""</span><br />   <span style="color: #00C800;">DEFAULT</span> cCmdArgs <span style="color: #0000ff;">TO</span> <span style="color: #ff0000;">""</span><br />   <span style="color: #00C800;">DEFAULT</span> cDescr <span style="color: #0000ff;">TO</span> <span style="color: #ff0000;">""</span><br />   <span style="color: #00C800;">DEFAULT</span> aHotKey <span style="color: #0000ff;">TO</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><br />   <span style="color: #00C800;">DEFAULT</span> aIcon <span style="color: #0000ff;">TO</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><br /><br />   <span style="color: #00C800;">IF</span> !EMPTY<span style="color: #000000;">&#40;</span> cLinkTarget <span style="color: #000000;">&#41;</span><br />      nPosi := RAT<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"<span style="color: #000000;">\"</span>, cLinkFile )<br />      IF nPosi > 0<br />         cPath := SUBSTR( cLinkFile, 1, nPosi - 1 )<br />         cFile := SUBSTR( cLinkFile, nPosi + 1 )<br />      ENDIF<br /><br />      // create empty file with 0 (zero) byte<br />      nHandle := FCREATE( cLinkFile, FC_NORMAL )<br />      FCLOSE( nHandle )<br />   ENDIF<br /><br />   IF !EMPTY( cPath ) .AND. !EMPTY( cFile ) .AND. FILE( cLinkFile )<br />      oShell := CreateObject( "</span>shell.application<span style="color: #ff0000;">" )<br />      oFolder := oShell:NameSpace( cPath )<br />      oStorageFolder := oFolder:ParseName( cFile )<br /><br />      IF !EMPTY( oStorageFolder )<br />         oShellLink := oStorageFolder:GetLink<br />         IF !EMPTY( oShellLink )<br />            // set Property<br />            oShellLink:Path := cLinkTarget<br />            oShellLink:WorkingDirectory := cWorkingDir<br />            oShellLink:Arguments := cCmdArgs<br />            oShellLink:Description := cDescr<br />            oShellLink:ShowCommand := 1<br /><br />            // Shortcut Hotkey<br />            IF !EMPTY( aHotKey ) .AND. VALTYPE( aHotKey ) = "</span>A<span style="color: #ff0000;">"<br />               IF LEN( aHotKey ) = 2<br />                  nLoByte := aHotKey[ 1 ]<br />                  nHiByte := aHotKey[ 2 ]<br />               ENDIF<br />            ENDIF<br /><br />            // Icon need Method<br />            IF !EMPTY( aIcon ) .AND. VALTYPE( aIcon ) = "</span>A<span style="color: #ff0000;">"<br />               IF LEN( aIcon ) = 2<br />                  oShellLink:SetIconLocation( aIcon[ 1 ], aIcon[ 2 ] )<br />               ENDIF<br />            ENDIF<br /><br />            // now save<br />            oShellLink:Save( cLinkFile )<br /><br />            lSuccess := .T.<br />         ENDIF<br />      ENDIF<br /><br />      oShellLink := NIL<br />      oStorageFolder := NIL<br />      oFolder := NIL<br />      oShell := NIL<br /><br />   ENDIF<br /><br />RETURN lSuccess</span></div>[/code:1pt9at6h] btw. here opposite Function [code=fw:1pt9at6h]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> DXE_ResolveLink<span style="color: #000000;">&#40;</span> cFull <span style="color: #000000;">&#41;</span><br /><span style="color: #00C800;">LOCAL</span> oShell<br /><span style="color: #00C800;">LOCAL</span> oFolder<br /><span style="color: #00C800;">LOCAL</span> oStorageFolder<br /><span style="color: #00C800;">LOCAL</span> oShellLink<br /><span style="color: #00C800;">LOCAL</span> cPath          := <span style="color: #ff0000;">""</span><br /><span style="color: #00C800;">LOCAL</span> cItem          := <span style="color: #ff0000;">""</span><br /><span style="color: #00C800;">LOCAL</span> nPosi          := <span style="color: #000000;">0</span><br /><span style="color: #00C800;">LOCAL</span> cTarget        := <span style="color: #ff0000;">""</span><br /><span style="color: #00C800;">LOCAL</span> cPara          := <span style="color: #ff0000;">""</span><br /><br />   <span style="color: #00C800;">IF</span> !EMPTY<span style="color: #000000;">&#40;</span> cFull <span style="color: #000000;">&#41;</span><br />      nPosi := RAT<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"<span style="color: #000000;">\"</span>, cFull )<br />      IF nPosi > 0<br />         cPath := SUBSTR( cFull, 1, nPosi )<br />         cItem := SUBSTR( cFull, nPosi + 1 )<br /><br />         oShell := CreateObject( "</span>shell.application<span style="color: #ff0000;">" )<br />         oFolder := oShell:NameSpace( cPath )<br />         oStorageFolder := oFolder:ParseName( cItem )<br /><br />         IF !EMPTY( oStorageFolder )<br />            oShellLink := oStorageFolder:GetLink<br />            IF !EMPTY( oShellLink )<br />               cTarget := oShellLink:Path<br />               cPara := oShellLink:Arguments<br />            ENDIF<br />         ENDIF<br /><br />         oStorageFolder := NIL<br />         oFolder := NIL<br />         oShell := NIL<br />      ENDIF<br />   ENDIF<br /><br />RETURN cTarget + IF( EMPTY( cPara ), "</span><span style="color: #ff0000;">", CHR( 0 ) + cPara )</span></div>[/code:1pt9at6h]
create a desktop shortcut directly from the program
Jimmy, It didn't work, how do I put the parameters <!-- s:?: --><img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question" /><!-- s:?: --> [code=fw:15z9y5d4]<div class="fw" id="{CB}" style="font-family: monospace;"><br />cLinkTarget    := CurDrive<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> + <span style="color: #ff0000;">":"</span> + DirWin<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> + <span style="color: #ff0000;">"sisrevH.exe"</span><br />cLinkFile      := <span style="color: #ff0000;">"SisrevWin.lnk"</span><br />cWorkingDir    := <span style="color: #ff0000;">"c:<span style="color: #000000;">\s</span>isrev<span style="color: #000000;">\w</span>in<span style="color: #000000;">\"</span> <br />cDescr         := "</span>Aplicativo<span style="color: #ff0000;">"<br /><br />DXE_CreateLink( cLinkTarget , cLinkFile  , cWorkingDir  )<br /><br /></span></div>[/code:15z9y5d4]
create a desktop shortcut directly from the program
hi Ari, try this [code=fw:33bhh72t]<div class="fw" id="{CB}" style="font-family: monospace;">PROCEDURE MAIN<br /><span style="color: #00C800;">LOCAL</span> cLinkTarget := Getenv<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"windir"</span><span style="color: #000000;">&#41;</span>+<span style="color: #ff0000;">"<span style="color: #000000;">\N</span>otepad.exe"</span>            <span style="color: #B900B9;">// EXE, BAT</span><br /><span style="color: #00C800;">LOCAL</span> cLinkFile   := Getenv<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"USERPROFILE"</span><span style="color: #000000;">&#41;</span>+<span style="color: #ff0000;">"<span style="color: #000000;">\D</span>esktop<span style="color: #000000;">\T</span>est1.LNK"</span> <span style="color: #B900B9;">// where create</span><br /><span style="color: #00C800;">LOCAL</span> cWorkingDir := Getenv<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"USERPROFILE"</span><span style="color: #000000;">&#41;</span>+<span style="color: #ff0000;">"<span style="color: #000000;">\D</span>esktop"</span>           <span style="color: #B900B9;">// working Dir</span><br /><span style="color: #00C800;">LOCAL</span> cCmdArgs    := <span style="color: #ff0000;">"README.TXT"</span>                               <span style="color: #B900B9;">// Parameter</span><br /><span style="color: #00C800;">LOCAL</span> cDescr      := <span style="color: #ff0000;">"Test Create Link with Icon and Hotkey"</span>    <span style="color: #B900B9;">// Description</span><br /><br /><span style="color: #B900B9;">/***************************************<br />* aHotKey[1] -> ASCI Number e.g. ASC("Z")<br />* aHotKey[2] -> CTRL+ALT -> 2+4<br />*<br />* (1)   SHIFT key<br />* (2)   CTRL key<br />* (4)   ALT key<br />* (8)   Extended key<br />***************************************/</span><br /><span style="color: #00C800;">LOCAL</span> aHotKey     := <span style="color: #000000;">&#123;</span><span style="color: #0000ff;">ASC</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"Z"</span><span style="color: #000000;">&#41;</span>,<span style="color: #000000;">2</span><span style="color: #000000;">+4</span><span style="color: #000000;">&#125;</span>        <span style="color: #B900B9;">// UPPER(A-Z)</span><br /><span style="color: #00C800;">LOCAL</span> aIcon       := <span style="color: #000000;">&#123;</span> AppName<span style="color: #000000;">&#40;</span>.T.<span style="color: #000000;">&#41;</span>, <span style="color: #000000;">1</span> <span style="color: #000000;">&#125;</span>   <span style="color: #B900B9;">// { FullpathName, Index }</span><br /><br /><span style="color: #B900B9;">// Shell Resource Icon Index zero-based</span><br /><span style="color: #B900B9;">//</span><br /><span style="color: #B900B9;">// aIcon := {"shell32.dll", 3 }</span><br /><span style="color: #B900B9;">// aIcon := {cAppPath+"Strait.ico", 0 }</span><br /><br />   CLS<br /><br />   <span style="color: #00C800;">IF</span> FILE<span style="color: #000000;">&#40;</span>cLinkFile<span style="color: #000000;">&#41;</span><br />      FErase<span style="color: #000000;">&#40;</span>cLinkFile<span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">ENDIF</span><br /><br />   DXE_CreateLink<span style="color: #000000;">&#40;</span>cLinkTarget,cLinkFile,cWorkingDir,cCmdArgs,cDescr, aHotKey,aIcon<span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00C800;">RETURN</span></div>[/code:33bhh72t]
create a desktop shortcut directly from the program
Jimmy, Thank you very much it worked out <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
create a dockpanel
I wish create this dockpanel but I not Understood How create it [img:ojyetqfl]https&#58;//i&#46;postimg&#46;cc/nLN2BrZj/gadget&#46;jpg[/img:ojyetqfl] i made a test but I not understood How modify it [code=fw:ojyetqfl]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fivewin.ch"</span><br /><br /><br /><br /><span style="color: #00C800;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> oWnd<br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">WINDOW</span> oWnd <span style="color: #0000ff;">TITLE</span> <span style="color: #ff0000;">"Test"</span><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">WINDOW</span> oWnd;<br />&nbsp; &nbsp; <span style="color: #0000ff;">ON</span> <span style="color: #0000ff;">INIT</span> Dock<span style="color: #000000;">&#40;</span>oWnd<span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><br /><br /><span style="color: #00C800;">Function</span> Dock<span style="color: #000000;">&#40;</span>oWindow <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> oFont<br />&nbsp; &nbsp;<span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">FONT</span> oFont <span style="color: #0000ff;">NAME</span> <span style="color: #ff0000;">"Tahoma"</span> &nbsp;<span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">0</span>, <span style="color: #000000;">-11</span><br /><br />oDock1 &nbsp;:= TDockPnel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> oWindow <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;WITH OBJECT oDock1<br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetHeightCaption</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">40</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetCoors</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span> | o | <span style="color: #000000;">10</span> <span style="color: #000000;">&#125;</span>, <span style="color: #000000;">&#123;</span> | o | <span style="color: #000000;">10</span> <span style="color: #000000;">&#125;</span>, ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#123;</span> | o | Int<span style="color: #000000;">&#40;</span> o:<span style="color: #000000;">oWnd</span>:<span style="color: #000000;">nHeight</span> / <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span> + <span style="color: #000000;">54</span> <span style="color: #000000;">&#125;</span>, ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#123;</span> | o | Int<span style="color: #000000;">&#40;</span> o:<span style="color: #000000;">oWnd</span>:<span style="color: #000000;">nWidth</span> / <span style="color: #000000;">3</span> <span style="color: #000000;">&#41;</span> - XEVal<span style="color: #000000;">&#40;</span> o:<span style="color: #000000;">nLeft</span>, o <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetCaption</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span> | o | <span style="color: #ff0000;">"Partite da incassare"</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetColors</span><span style="color: #000000;">&#40;</span>CLR_WHITE,CLR_GRAY, CLR_GREEN, CLR_WHITE <span style="color: #000000;">&#41;</span><br /><br /><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetFont</span><span style="color: #000000;">&#40;</span> oFont <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetBorderSize</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetImgsFiles</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#123;</span> <span style="color: #ff0000;">"c:<span style="color: #000000;">\w</span>ork<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\b</span>itmaps<span style="color: #000000;">\1</span>6x16<span style="color: #000000;">\p</span>anel.bmp"</span>, ;<br />&nbsp; &nbsp; <span style="color: #000000;">&#123;</span> || oDock1:<span style="color: #000000;">aBtnBmps</span><span style="color: #000000;">&#91;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#93;</span>:<span style="color: #000000;">SetImages</span><span style="color: #000000;">&#40;</span> <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> oDock1:<span style="color: #000000;">lSelected</span>, <span style="color: #ff0000;">"c:<span style="color: #000000;">\w</span>ork<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\b</span>itmaps<span style="color: #000000;">\1</span>6x16<span style="color: #000000;">\p</span>anel.bmp"</span>, <span style="color: #ff0000;">"c:<span style="color: #000000;">\w</span>ork<span style="color: #000000;">\F</span>wh<span style="color: #000000;">\b</span>itmaps<span style="color: #000000;">\1</span>6x16<span style="color: #000000;">\c</span>heck.bmp"</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>, ;<br />&nbsp; &nbsp; &nbsp; &nbsp;ock1:<span style="color: #000000;">lSelected</span> := !oDock1:<span style="color: #000000;">lSelected</span> <span style="color: #000000;">&#125;</span>, <span style="color: #ff0000;">"ToolTip"</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><br /><br /><br />&nbsp; &nbsp; &nbsp;* :<span style="color: #000000;">SetCtrlsPnel</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span> | o, nT, nL, nH, nW, oB | oB := Test1<span style="color: #000000;">&#40;</span> o, nT, nL, nH, nW <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><br /><br /><br />&nbsp; &nbsp; &nbsp;:<span style="color: #000000;">bRClicked</span> &nbsp; := <span style="color: #000000;">&#123;</span> || <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">&#40;</span> oDock1:<span style="color: #000000;">oWnd</span>:<span style="color: #000000;">aControls</span><span style="color: #000000;">&#91;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#93;</span>:<span style="color: #000000;">ClassName</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">//</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">// Controls predefined in :oPnelH ( interior Panel )</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">//</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">lBottomH</span> &nbsp; &nbsp;:= .F.<br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetTypeCtrl</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// Control TTitle</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetHeightCtrl</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">45</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">SetColorsCtrl</span><span style="color: #000000;">&#40;</span> &nbsp;CLR_WHITE,CLR_GREEN <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">aRectText</span> &nbsp; := <span style="color: #000000;">&#123;</span> <span style="color: #000000;">1</span>, <span style="color: #000000;">60</span> <span style="color: #000000;">&#125;</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #000000;">cTitH</span> &nbsp; &nbsp; &nbsp; := <span style="color: #ff0000;">"Totale in scadenza da incassare"</span>+CRLF+<span style="color: #ff0000;">"€ 8.359,15"</span><br />&nbsp; &nbsp; &nbsp; :<span style="color: #0000ff;">Activate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;END<br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><br />&nbsp;</div>[/code:ojyetqfl]
create a document with the tword
Hello, everyone, Thanks to Kleyber by Tword indicate the class. The examples found in the forum are restricted to fill in the fields of a document ready, like a mail merge. Now I want to convert a text file for standard word (doc, rtf), but with some settings that I will pass this text file, such as color, font, size, etc.. Ex: LIST OF CUSTOMERS I would like to Source Arial, 20, Blue color, bold, italic, underline. I tried this way and not succeeded. DEFINE FONT oFont1 NAME 'Arial' SIZE 0, -12 OF oWord oWord: Say (2, 45, 'Class TWORD Say method. Displays text in a box.', oFont1) Someone could help me or suggest any hint. Grateful Farley
create a document with the tword
Farley,Whats the Class TWord source code that you are using ?Please copy it here, thanks
create a document with the tword
Antônio,See the source of class tword that I use.[code:8msvx1a8] // Clase TWord // Mira el documento TWord&#46;doc para información // 2003 Sebastián Almirón /* 5-Diciembre-2003 Clase TWord Modificada por &#58; Víctor Manuel Tomás Díaz &#91; Vikthor &#93; vikthor@creswin&#46;com He quitado todas las llamadas a las funciones OleGetProperty&#40;&#41; , OleSetProperty&#40;&#41; , OleInvoke&#40;&#41;&#46; Ahora es usada la clase TOleAuto&#40;&#41; y sus Metodos &#58;Get , &#58;Set , &#58;Invoke ++ METHOD Sendmail&#40; lAttach &#41; ++ METHOD HeaderFooter&#40; nOption &#41; ++ METHOD OpenDataSource&#40; cFile &#41; ++ METHOD AddField&#40; cField &#41; ++ METHOD WebPagePreview&#40;&#41; 09-Mar-2004 ++ Data oTables ++ METHOD AddTables&#40;&#41; 08-Jun-2004 ++ METHOD View&#40; nView &#41; oWord&#58;View&#40; 1 &#41; Vista Normal oWord&#58;View&#40; 3 &#41; Vista Diseño oWord&#58;View&#40; 6 &#41; Vista Web ++ METHOD Zoom&#40; nPercent &#41; 03-Dic-2004 ** Modificación al Metodo New usando TRY y CATCH para recuperar una instacia abierta crearla o enviar un mensaje de error&#46; */ #include "FiveWin&#46;Ch" #define TAB chr&#40;9&#41; #define ENTER chr&#40;13&#41; #define ALI_LEFT 0 #define ALI_CENTER 1 #define ALI_RIGHT 2 #define ALI_JUSTIFY 3 #define LOGPIXELSX 88 #define LOGPIXELSY 90 // Registros y delimitadores de campos de la estructura GTF #define SP_REG Chr&#40; 5 &#41; #define SP_FIELD Chr&#40; 7 &#41; #define TP_FONT Chr&#40; 15 &#41; #define TP_COLOR Chr&#40; 16 &#41; #define TP_ALIGN Chr&#40; 17 &#41; // Identificador y versión de las ficheros GTF #define FORMAT_TEXT_TYPE "GTF" #define FORMAT_TEXT_VERSION "1" // LA CLASE TWORD CLASS TWord DATA oWord DATA oDocs DATA oActiveDoc DATA oTexto DATA oSelection DATA cNombreDoc DATA nLinea,nCol, nPage DATA nYoffset, nXoffset DATA lstartpag DATA oLastSay DATA lOverflowing DATA nlastrow DATA cTextOverflow DATA lSetCm DATA oOptions // Objeto Options DATA oMailMerge // Combinar correspondencia DATA oDataSource // Objeto MailMergeDataSource DATA oDataFields // Objeto MailMergeDataFields DATA oFields // Objeto MailMergeFields DATA oTables // Objeto Tables DATA lWord METHOD AddImagen&#40; nTop, nLeft, nBottom, nRight, cImagen, alinea, ntipo, nrotacion &#41; METHOD addtabulador&#40;npos, ocuadrotext&#41; METHOD Box&#40; nTop, nLeft, nBottom, nRight, afondo, alinea, ntipo, nrotation, lsimple &#41; METHOD close&#40;&#41; METHOD CmSay&#40; nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad, naltura, nColorIndex, lVertAdjust &#41; METHOD CheckSpelling&#40;&#41; METHOD End&#40;&#41; METHOD EndPage&#40;&#41; METHOD FillRect&#40; aRect, oBrush &#41; METHOD GetTextHeight&#40; oFont &#41; METHOD GetTextWidth&#40;cText, oFont&#41; METHOD GoBottom&#40;&#41; INLINE &#58;&#58;oTexto&#58;Invoke&#40; 'EndKey', 6&#41; METHOD GoTop&#40;&#41; INLINE &#58;&#58;oTexto&#58;Invoke&#40; 'HomeKey', 6&#41; METHOD JustificaDoc&#40; nJustify, otext &#41; METHOD Line&#40; nTop, nLeft, nBottom, nRight, oPen, nColor, nStyle &#41; METHOD New&#40;&#41; METHOD NewDoc&#40; cNombreDoc &#41; METHOD nLogPixelX&#40;&#41; INLINE 55&#46;38 METHOD nLogPixelY&#40;&#41; INLINE 55&#46;38 METHOD OpenDoc&#40; cNombreDoc &#41; METHOD Preview&#40;&#41; METHOD PrintDoc&#40;lbackground, lappend, nRange, cOutputFile, nfrom, nto, nitem, ncopias, cpages&#41; METHOD Protect&#40;cpassword,nmodo&#41; METHOD Replace&#40; cOld, cNew &#41; METHOD Combinar&#40; cWildCards &#41; METHOD Save&#40;cnombredoc&#41; METHOD Say&#40; nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad, naltura, nColorIndex, lvertadjust &#41; METHOD Say2&#40; nLin,nCol,cTexto,oFuente, nSize, lBold, lShadow, nColor &#41; METHOD SayGTF&#40; nTop,nLeft, cTextFormat, nBottom,nRight &#41; METHOD SetCm&#40;&#41; METHOD SetHeader&#40;&#41; METHOD SetLandScape&#40;&#41; METHOD SetMainDoc&#40;&#41; METHOD SetPortrait&#40;&#41; METHOD SetUl&#40;&#41; METHOD StartPage&#40;&#41; METHOD TabClearAll&#40;ocuadrotext&#41; METHOD TabPredeterminado&#40;ncada&#41; METHOD TextBox&#40; nTop, nLeft, nBottom, nRight, cTexto, oFuente, nclrtext, nClrBack, nJustify, afondo, alinea, lvertadjust, norientacion&#41; METHOD UnProtect&#40;cpassword&#41; METHOD VistaCompleta&#40;&#41; METHOD Visualizar INLINE &#58;&#58;oWord&#58;Visible &#58;= &#46;T&#46; METHOD Write&#40; cTexto, cFuente, cSize, lBold, lShadow, nColor &#41; METHOD Sendmail&#40; lAttach &#41; // Vikthor METHOD HeaderFooter&#40; nOption &#41; // Vikthor METHOD OpenDataSource&#40; cFile &#41; // Vikthor METHOD AddField&#40; cField &#41; // Vikthor METHOD WebPagePreview&#40;&#41; INLINE &#58;&#58;oActiveDoc&#58;Invoke&#40;"WebPagePreview"&#41; // &#91; Vikthor &#93; Genera una vista en HTML del libro&#46; METHOD AddTables&#40; aDatos , nPos &#41; // &#91; Vikthor &#93; METHOD AddBar&#40;aDatos&#41; METHOD Find&#40; cText &#41; // &#91; Vikthor &#93; METHOD Hide&#40;&#41; INLINE &#58;&#58;oWord&#58;Visible &#58;= &#46;F&#46; // &#91; Vikthor &#93; METHOD IsVisible&#40;&#41; INLINE &#58;&#58;oWord&#58;Visible // &#91; Vikthor &#93; METHOD View&#40; nView &#41; // &#91; Vikthor &#93; METHOD Zoom&#40; nPercent &#41; // &#91; Vikthor &#93; ENDCLASS METHOD AddImagen&#40; nTop, nLeft, nBottom, nRight, cImagen, alinea, ntipo, nrotacion &#41; CLASS TWord &#58;&#58;Box&#40;nTop, nLeft, nBottom, nRight, &#123;,,,,,,,cImagen&#125;, alinea, ntipo, nrotacion, &#46;t&#46;&#41; RETURN nil METHOD addtabulador&#40;npos, ocuadrotext&#41; CLASS TWord local otabstop, oParagraphFormat DEFAULT ocuadrotext &#58;= &#58;&#58;oTexto if &#58;&#58;lsetcm npos &#58;= nnpos*28&#46;35 endif oParagraphFormat &#58;= oCuadroText&#58;Get&#40; 'ParagraphFormat'&#41; otabstop &#58;= oParagraphFormat&#58;Get&#40; 'TabStops'&#41; oTabstop&#58;Invoke&#40;'Add',npos&#41; release oParagraphFormat, otabstop RETURN nil METHOD Box&#40; nTop, nLeft, nBottom, nRight, afondo, alinea, ntipo, nrotation, lPicTextured &#41; CLASS TWord LOCAL oShapes,oShapBox, oFill, oFillColor, olinea , n DEFAULT afondo &#58;= &#123;&#125;, alinea &#58;= &#123;&#125;, ntipo &#58;= 1, nrotation &#58;= 0, lPicTextured &#58;= &#46;f&#46; &#58;&#58;nLastRow &#58;= nBottom if &#58;&#58;lsetcm nTop &#58;= nTop*28&#46;35 nLeft &#58;= nLeft*28&#46;35 nBottom &#58;= nBottom*28&#46;35 nRight &#58;= nRight*28&#46;35 endif nRight &#58;= nRight - nLeft nBottom &#58;= nBottom - nTop oShapes &#58;= &#58;&#58;oSelection&#58;Get&#40; "Shapes" &#41; oShapBox &#58;= oShapes&#58;Invoke&#40; "AddShape",ntipo,nLeft,nTop,nRight,nBottom &#41; //oShapBox&#58;Set&#40;'RelativeHorizontalPosition', 1 &#41; // No //oShapBox&#58;Set&#40;'RelativeVerticalPosition', 1 &#41; // No oFill &#58;= oShapBox&#58;Get&#40; "Fill" &#41; oShapBox&#58;Set&#40;'Rotation', nRotation &#41; for n = 1 to len&#40;afondo&#41; do case case n = 1 &#46;and&#46; afondo&#91;n&#93; <> NIL oFillColor &#58;= oFill&#58;Get&#40;"ForeColor"&#41; oFillColor&#58;Set&#40; 'RGB', aFondo&#91;1&#93; &#41; case n = 2 &#46;and&#46; afondo&#91;n&#93; <> NIL oFillColor &#58;= oFill&#58;Get&#40;"BackColor"&#41; oFillColor&#58;Set&#40; 'RGB', afondo&#91;2&#93; &#41; case n = 3 &#46;and&#46; afondo&#91;n&#93; <> NIL oFillColor&#58;Set&#40; 'Transparency', afondo&#91;3&#93;&#41; case n = 4 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Invoke&#40; 'TwoColorGradient', afondo&#91;4&#93;, afondo&#91;5&#93; &#41; case n = 6 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Invoke&#40; 'Patterned', afondo&#91;6&#93; &#41; case n = 7 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Invoke&#40; 'PresetTextured', afondo&#91;7&#93; &#41; case n = 8 &#46;and&#46; afondo&#91;n&#93; <> NIL if lPicTextured = &#46;t&#46; oFill&#58;Invoke&#40; 'UserPicture', afondo&#91;8&#93; &#41; else oFill&#58;Invoke&#40; 'UserTextured' , afondo&#91;8&#93; &#41; endif endcase next n oLinea &#58;= oShapBox&#58;Get&#40; "Line" &#41; for n = 1 to len&#40;alinea&#41; do case case n = 1 oLinea&#58;Set&#40; "Weight", alinea&#91;1&#93; &#41; case n = 2 oLinea&#58;Set&#40; "ForeColor", alinea&#91;2&#93; &#41; case n = 3 oLinea&#58;Set&#40; "BackColor", alinea&#91;3&#93; &#41; case n = 4 oLinea&#58;Set&#40; "Transparency", alinea&#91;4&#93;&#41; case n = 5 oLinea&#58;Set&#40; "DashStyle", alinea&#91;5&#93; &#41; case n = 5 oLinea&#58;Set&#40; "Style", alineas&#91;6&#93; &#41; endcase next n release oShapes,oShapBox, oFill, oFillColor, olinea RETURN nil METHOD close&#40;oDoc&#41; CLASS TWord DEFAULT oDoc &#58;= &#58;&#58;oActiveDoc oDoc&#58;Invoke&#40;'Close',0&#41; RETURN METHOD CmSay&#40; nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad, naltura, nColorIndex, lVertAdjust &#41; CLASS TWord local lsetcm &#58;= &#58;&#58;lsetcm &#58;&#58;lSetCm &#58;= &#46;t&#46; &#58;&#58;Say&#40; nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad, naltura, nColorIndex, lVertAdjust &#41; &#58;&#58;lSetcm &#58;= lsetcm RETURN Nil METHOD CheckSpelling&#40;&#41; CLASS TWord &#58;&#58;oActiveDoc&#58;Invoke&#40; 'CheckSpelling'&#41; RETURN nil METHOD End&#40;&#41; CLASS TWord &#58;&#58;oDocs&#58;Invoke&#40;'Close'&#41; &#58;&#58;oWord&#58;Invoke&#40; "Quit",0&#41; &#58;&#58;oTexto &#58;= NIL &#58;&#58;oActiveDoc &#58;= NIL &#58;&#58;oDocs &#58;= NIL &#58;&#58;oWord &#58;= NIL #IFNDEF __XHARBOUR__ OleUninitialize&#40;&#41; #ENDIF RETURN nil METHOD EndPage&#40;&#41; CLASS TWord RETURN nil METHOD FillRect&#40; aRect, oBrush &#41; CLASS TWord LOCAL oShapes,oShapBox, oFill, oFillColor if &#58;&#58;lsetcm arect&#91;1&#93; &#58;= arect&#91;1&#93;*28&#46;35 arect&#91;2&#93; &#58;= arect&#91;2&#93;*28&#46;35 arect&#91;3&#93; &#58;= arect&#91;3&#93;*28&#46;35 arect&#91;4&#93; &#58;= arect&#91;4&#93;*28&#46;35 endif oShapes &#58;= &#58;&#58;oSelection&#58;Get&#40; "Shapes" &#41; oShapBox &#58;= oShapes&#58;Invoke&#40; "AddShape",1,arect&#91;2&#93;,arect&#91;1&#93;,arect&#91;4&#93;-arect&#91;2&#93;,aRect&#91;3&#93;-arect&#91;1&#93; &#41; oCuadro&#58;Set&#40; 'RelativeHorizontalPosition',1&#41; oCuadro&#58;Set&#40; 'RelativeVerticalPosition',1&#41; oFill &#58;= oShapBox&#58;Get&#40; "Fill"&#41; oFillColor &#58;= oFill&#58;Get&#40; "ForeColor"&#41; oFillColor&#58;Set&#40; "RGB",oBrush&#58;nRGBColor &#41; oBrush&#58;End&#40;&#41; release oFillColor,oFill,oShapBox,oShapes RETURN nil METHOD GetTextHeight&#40; oFont &#41; CLASS TWord local sal if &#58;&#58;lsetcm sal &#58;= oFont&#58;nHeight/28&#46;35 else sal &#58;= oFont&#58;nHeight endif RETURN sal METHOD GetTextWidth&#40;cText, oFont&#41; CLASS TWord local nancho if oFont&#58;nHeight > 0 nancho &#58;= &#40;oFont&#58;nHeight/1&#46;6&#41;*len&#40;ctext&#41; else nancho &#58;=&#40;&#40;oFont&#58;nHeight*-1&#41;/1&#46;6&#41;*len&#40;ctext&#41; endif RETURN nancho METHOD JustificaDoc&#40; nJustify, otext &#41; CLASS TWord LOCAL oParagraph DEFAULT oText &#58;= &#58;&#58;oTexto oParagraph &#58;= oText&#58;Get&#40;"ParagraphFormat"&#41; oParagraph&#58;Set&#40; "Alignment", nJustify &#41; RELEASE oParagraph RETURN &#40; Nil &#41; METHOD Line&#40; nTop, nLeft, nBottom, nRight, oPen, nColor, nStyle &#41; CLASS TWord local oShapes,oShapLinea, oLinea, oRGB if &#58;&#58;lsetcm nTop &#58;= nTop*28&#46;35 nLeft &#58;= nLeft*28&#46;35 nBottom &#58;= nBottom*28&#46;35 nRight &#58;= nRight*28&#46;35 endif if oPen = NIL DEFINE PEN oPen if nStyle = Nil nStyle &#58;= 1 endif if nColor = Nil nColor &#58;= nRGB&#40;0,0,0&#41; endif else if nStyle = Nil do case case oPen&#58;nStyle = 0 nStyle &#58;= 1 case oPen&#58;nStyle = 1 nStyle &#58;= 4 case oPen&#58;nStyle = 2 nstyle &#58;= 2 case oPen&#58;nStyle = 3 nstyle &#58;= 5 case oPen&#58;nStyle = 4 nstyle &#58;= 6 endcase endif if nColor = Nil nColor &#58;= oPen&#58;nColor endif endif oShapes &#58;= &#58;&#58;oSelection&#58;Get&#40; "Shapes" &#41; oShapLinea &#58;= oShapes&#58;Invoke&#40; "AddLine", nLeft,nTop,nRight,nBottom &#41; oShapLinea&#58;Set&#40; 'RelativeHorizontalPosition',1&#41; oShapLinea&#58;Set&#40; 'RelativeVerticalPosition',1&#41; oLinea &#58;= oShapLinea&#58;Get&#40; "Line" &#41; * oLinea&#58;Set&#40; "Weight", oPen&#58;nWidth-2 &#41; // No anda OK oRGB &#58;= oLinea&#58;Get&#40; 'ForeColor'&#41; oRGB&#58;Set&#40;'RGB', nColor &#41; oLinea&#58;Set&#40; "DashStyle", nStyle&#41; oPen&#58;End&#40;&#41; release oLinea,oShapLinea,oShapes, oRGB RETURN nil METHOD NEW&#40;&#41; CLASS TWord &#58;&#58;lWord &#58;= &#46;T&#46; #IFDEF __XHARBOUR__ TRY &#58;&#58;oWord &#58;= GetActiveObject&#40; "Word&#46;Application" &#41; CATCH TRY &#58;&#58;oWord &#58;= CreateObject&#40; "Word&#46;Application" &#41; CATCH Alert&#40; "ERROR! Word no está instaldo en esta PC&#46;"&#41; &#58;&#58;lWord &#58;= &#46;F&#46; END END #ELSE &#58;&#58;oWord &#58;= TOleAuto&#40;&#41;&#58;New&#40;"Word&#46;Application"&#41; IF &#58;&#58;oWord&#58;hObj == 0 Alert&#40; "ERROR! Word no está instaldo en esta PC&#46;"&#41; &#58;&#58;lWord &#58;= &#46;F&#46; ENDIF #ENDIF RETURN&#40; Self &#41; METHOD NewDoc&#40; cNombreDoc &#41; CLASS TWord DEFAULT cNombreDoc &#58;= 'Documento1' &#58;&#58;oDocs &#58;= &#58;&#58;oWord&#58;Get&#40; "Documents"&#41; &#58;&#58;oDocs&#58;Invoke&#40; "Add" &#41; &#58;&#58;oActiveDoc &#58;= &#58;&#58;oWord&#58;Get&#40;"ActiveDocument"&#41; &#58;&#58;oTexto &#58;= &#58;&#58;oWord&#58;Get&#40;"Selection"&#41; &#58;&#58;oOptions &#58;= &#58;&#58;oWord&#58;Get&#40;"Options"&#41; // Vikthor &#58;&#58;oTables &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "Tables"&#41; // Vikthor &#58;&#58;oMailMerge &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "MailMerge"&#41; // Vikthor &#58;&#58;cNombreDoc &#58;= cNombreDoc &#58;&#58;nLinea &#58;= 0 &#58;&#58;nCol &#58;= 0 &#58;&#58;nPage &#58;= 0 &#58;&#58;nYoffset &#58;= 0 &#58;&#58;nXoffset &#58;= 0 &#58;&#58;lstartpag &#58;= &#46;t&#46; &#58;&#58;oSelection &#58;= &#58;&#58;oActiveDoc &#58;&#58;lSetcm &#58;= &#46;f&#46; &#58;&#58;lOverflowing &#58;= &#46;f&#46; &#58;&#58;nlastrow &#58;= 0 &#58;&#58;ctextoverflow &#58;= '' RETURN nil *METHOD nLogPixelX&#40;&#41; * RETURN 55&#46;38 *METHOD nLogPixelY&#40;&#41; * RETURN 55&#46;38 METHOD OpenDoc&#40; cNombreDoc &#41; CLASS TWord local sal &#58;= &#46;t&#46; &#58;&#58;oDocs &#58;= &#58;&#58;oWord&#58;Get&#40; "Documents" &#41; if file&#40; cNombreDoc &#41; &#58;&#58;oActiveDoc &#58;= &#58;&#58;oDocs&#58;Invoke&#40; "Open",cNombreDoc &#41; if valtype&#40;&#58;&#58;oActiveDoc&#41; <> 'O' sal &#58;= &#46;f&#46; endif else sal &#58;= &#46;f&#46; endif &#58;&#58;oTexto &#58;= &#58;&#58;oWord&#58;Get&#40; "Selection" &#41; &#58;&#58;oOptions &#58;= &#58;&#58;oWord&#58;Get&#40;"Options"&#41; // Vikthor &#58;&#58;oMailMerge &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "MailMerge"&#41; // Vikthor &#58;&#58;oTables &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "Tables"&#41; // Vikthor &#58;&#58;cNombreDoc &#58;= cNombreDoc &#58;&#58;nLinea &#58;= 0 &#58;&#58;nCol &#58;= 0 &#58;&#58;nPage &#58;= 0 &#58;&#58;nYoffset &#58;= 0 &#58;&#58;nXoffset &#58;= 0 &#58;&#58;oSelection &#58;= &#58;&#58;oActiveDoc &#58;&#58;lstartpag &#58;= &#46;t&#46; &#58;&#58;lsetcm &#58;= &#46;f&#46; &#58;&#58;lOverflowing &#58;= &#46;f&#46; &#58;&#58;nlastrow &#58;= 0 &#58;&#58;ctextoverflow &#58;= '' RETURN sal METHOD Preview&#40;&#41; CLASS TWord &#58;&#58;oWord&#58;Set&#40; "PrintPreview", &#46;F&#46;&#41; &#58;&#58;oActiveDoc&#58;Invoke&#40; "PrintPreview"&#41; &#58;&#58;Visualizar&#40;&#41; RETURN nil METHOD PrintDoc&#40;lbackground, lappend, nRange, cOutputFile, nfrom, nto, nitem, ncopias, cpages&#41; CLASS TWord local csinpath, cpath DEFAULT lbackground &#58;= &#46;f&#46;, lappend &#58;= &#46;f&#46;, nRange &#58;= 0, cOutputFile &#58;= '',; nfrom &#58;= '', nto &#58;= '' ,; nitem &#58;= 0, ncopias &#58;= 1, cpages &#58;= '' if !empty&#40;nFrom&#41; &#46;or&#46; !empty&#40;nTo&#41; nRange &#58;= 3 nFrom &#58;= alltrim&#40;str&#40;int&#40;nFrom&#41;&#41;&#41; nTo &#58;= alltrim&#40;str&#40;int&#40;nTo&#41;&#41;&#41; endif if empty&#40;cOutputFile&#41; &#58;&#58;oActiveDoc&#58;Invoke&#40; "PrintOut" , lbackground,lappend,int&#40;nRange&#41;,'',nfrom, nto, nitem,ncopias, cpages &#41; else cpath &#58;= cFilePath&#40;cOutputFile&#41; if !empty&#40;cpath&#41; &#46;and&#46; cpath <>'\' &#58;&#58;oWord&#58;Invoke&#40; 'ChangeFileOpenDirectory',cpath&#41; endif csinpath &#58;= cFileNoPath&#40;cOutputFile&#41; &#58;&#58;oWord&#58;Invoke&#40; "PrintOut",lbackground,lappend,int&#40;nRange&#41;,csinpath, nfrom, nto, nitem, ncopias, cpages &#41; endif RETURN nil METHOD Protect&#40;cpassword,nmodo&#41; CLASS TWord DEFAULT nmodo &#58;= 1 &#58;&#58;oActiveDoc&#58;Invoke&#40; "Protect", nmodo, &#46;F&#46;, cpassword &#41; RETURN nil METHOD Replace&#40; cOld, cNew &#41; CLASS TWord LOCAL oTexto, oFind, oReplace //&#58;&#58;oSelection &#58;= &#58;&#58;oActiveDoc // Vikthor oTexto &#58;= &#58;&#58;oSelection&#58;Range&#40;&#41; oFind &#58;= oTexto&#58;Get&#40; "Find" &#41; oFind&#58;Set&#40; "Text", cOld &#41; oFind&#58;Set&#40; "Forward", &#46;T&#46; &#41; oFind&#58;Set&#40; "Wrap", INT&#40;1&#41; &#41; oFind&#58;Set&#40; "Format", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchCase", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchWholeWord", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchWildcards", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchSoundsLike", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchAllWordForms", &#46;f&#46; &#41; oFind&#58;Invoke&#40; "Execute"&#41; DO WHILE oFind&#58;Get&#40; "Found" &#41; // Reemplaza todas las ocurrencias que coincidan oTexto&#58;Set&#40; "Text", cNew &#41; oFind&#58;Invoke&#40; "Execute"&#41; Enddo Release oReplace,oFind,oTexto RETURN nil METHOD Combinar&#40; cOld, cNew &#41; CLASS TWord LOCAL oTexto, oFind, oReplace LOCAL cFound, x_pos //&#58;&#58;oSelection &#58;= &#58;&#58;oActiveDoc // Vikthor oTexto &#58;= &#58;&#58;oSelection&#58;Range&#40;&#41; oFind &#58;= oTexto&#58;Get&#40; "Find" &#41; oFind&#58;Set&#40; "Text", cOld &#41; oFind&#58;Set&#40; "Forward", &#46;T&#46; &#41; oFind&#58;Set&#40; "Wrap", INT&#40;1&#41; &#41; oFind&#58;Set&#40; "Format", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchCase", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchWholeWord", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchWildcards", &#46;t&#46; &#41; oFind&#58;Set&#40; "MatchSoundsLike", &#46;f&#46; &#41; oFind&#58;Set&#40; "MatchAllWordForms", &#46;f&#46; &#41; oFind&#58;Invoke&#40; "Execute"&#41; DO WHILE oFind&#58;Get&#40; "Found" &#41; // Reemplaza todas las ocurrencias que coincidan cFound&#58;=Alltrim&#40;SubStr&#40;oTexto&#58;Text,2,Len&#40;Alltrim&#40;oTexto&#58;Text&#41;&#41;-2&#41;&#41; //Extrae el nombre de los campos cNew &#58;= search_tab&#40;cFound&#41; //? cNew oTexto&#58;Set&#40; "Text", cNew &#41; oFind&#58;Invoke&#40; "Execute"&#41; Enddo Release oReplace,oFind,oTexto RETURN nil /* METHOD Combinar&#40; cWildCards , cNew&#41; CLASS TWord //Busca todas las ocurrencias con comodines LOCAL oTexto, oFind, oReplace //&#58;&#58;oSelection &#58;= &#58;&#58;oActiveDoc // Vikthor oTexto &#58;= &#58;&#58;oSelection&#58;Range&#40;&#41; oFind &#58;= oTexto&#58;Get&#40; "Find" &#41; //oFind&#58;Set&#40;"ClearFormatting"&#41; //Quita todos los formatos especificados como parte de una operación de búsqueda y sustitución&#46; oFind&#58;Set&#40; "Text", cWilCards &#41; oFind&#58;Set&#40; "Forward", &#46;T&#46; &#41; //True para buscar hacia abajo es decir hacia el final del documento&#46; oFind&#58;Set&#40; "Wrap", INT&#40;1&#41; &#41; //Establece lo que ocurre si la búsqueda se inicia en un punto distinto al principio del documento&#46; oFind&#58;Set&#40; "Format", &#46;f&#46; &#41; //Devuelve o establece el formato del objeto especificado oFind&#58;Set&#40; "MatchCase", &#46;f&#46; &#41; //True si la búsqueda distingue mayúsculas de minúsculas&#46; oFind&#58;Set&#40; "MatchWholeWord", &#46;f&#46; &#41; //True si la operación de búsqueda sólo busca palabras completas y no texto que forme parte de una palabra&#46; oFind&#58;Set&#40; "MatchWildcards", &#46;t&#46; &#41; //True si el texto va a buscarse contiene comodines de búsqueda oFind&#58;Set&#40; "MatchSoundsLike", &#46;f&#46; &#41; //Recibe el valor True si la operación de búsqueda encuentra las palabras que tienen un sonido parecido al del texto buscado oFind&#58;Set&#40; "MatchAllWordForms", &#46;f&#46; &#41; //Recibe el valor True si la operación de búsqueda encuentra todas las formas del texto que se debe buscar oFind&#58;Invoke&#40; "Execute"&#41; //Ejecuta la operación de busqueda específica&#46; Devuelve true si la operación de busqueda tuvo éxito&#46; DO WHILE oFind&#58;Get&#40; "Found" &#41; //Objeto Find&#58; True si la búsqueda produce una coincidencia&#46; Antes hay que ejecutar el comando find&#46; /* */ // oTexto&#58;Set&#40; "ReplaceWith", "Encontrado"&#41; // oTexto&#58;Set&#40; "Text", cNew &#41; // oFind&#58;Invoke&#40; "Execute"&#41; // Enddo // Release oReplace,oFind,oTexto // RETURN nil METHOD Save&#40;cnombredoc&#41; CLASS TWord DEFAULT cnombredoc &#58;= &#58;&#58;cNombreDoc &#58;&#58;oActiveDoc&#58;Invoke&#40; "SaveAs", cNombreDoc &#41; RETURN nil METHOD Say&#40; nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad, naltura, nClrIndex, lvertadjust &#41; CLASS TWord if oFuente = Nil DEFINE FONT oFuente NAME 'Arial' SIZE 0, -12 OF Self endif DEFAULT nBkMode &#58;= 2 DEFAULT nSizeHorz &#58;= &#58;&#58;GetTextWidth&#40;ctexto,oFuente&#41; DEFAULT naltura &#58;= if&#40;&#58;&#58;lsetcm, 1, 28&#46;35&#41; if &#58;&#58;lsetcm nSizeHorz &#58;= nSizeHorz/28&#46;35 endif if nBkMode = 2 nBkMode = 0 else nBkMode = 1 endif do case case npad = 1 ncol &#58;= ncol - nSizeHorz npad &#58;= 2 case npad = 2 ncol = ncol - &#40;nSizeHorz/2&#41; npad &#58;= 1 endcase &#58;&#58;TextBox&#40;nLin, nCol, nLin+nAltura, nCol+nSizeHorz, ctexto, oFuente, nClrText, nClrIndex, npad,&#123;,,nPad&#125;,&#123;0&#125;,lVertAdjust&#41; RETURN Nil METHOD Say2&#40; nLin,nCol,cTexto,oFuente, nSize, lBold, lShadow, nColor &#41; CLASS TWord local cfuente &#58;= oFuente&#58;cFaceName do whil &#58;&#58;nLinea < nLin &#58;&#58;oTexto&#58;Invoke&#40; "TypeText", chr&#40;13&#41; &#41; &#58;&#58;nlinea &#58;= &#58;&#58;nlinea + 1 enddo &#58;&#58;nCol &#58;= 0 do whil &#58;&#58;nCol < nCol &#58;&#58;oTexto&#58;Invoke&#40; "TypeText", chr&#40;9&#41; &#41; &#58;&#58;nCol &#58;= &#58;&#58;nCol + 1 enddo &#58;&#58;Write&#40; cTexto, cFuente, nSize, lBold, lShadow, nColor &#41; RETURN nil METHOD SayGTF&#40; nTop,nLeft, cTextFormat, nBottom,nRight &#41; CLASS TWord local cText &#58;= "", nPos &#58;= 1, nLen &#58;= 0, nCrLf, cFormat, cVersion, cType local afuentes &#58;= &#123;&#125;, nColorText &#58;= 0 local cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeout local nJustify, nFont local oShapes, oCuadro, oFill, oLine, oCuadrotext local oFont &#58;= &#58;&#58;oTexto&#58;Get&#40; "Font" &#41; local aSal &#58;= &#123;&#46;f&#46;,''&#125;, lnocabe &#58;= &#46;f&#46; if &#58;&#58;lsetcm nTop &#58;= nTop*28&#46;35 nLeft &#58;= nLeft*28&#46;35 nBottom &#58;= nBottom*28&#46;35 nRight &#58;= nRight*28&#46;35 endif nLen &#58;= AT&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; cFormat &#58;= SubStr&#40; cTextFormat, nPos, nLen - 1 &#41; nPos += nLen nLen &#58;= At&#40; SP_FIELD, SubStr&#40; cTextFormat, nPos &#41; &#41; cVersion &#58;= SubStr&#40; cTextFormat, nPos, nLen - 1 &#41; nPos += nLen if !&#40; cFormat == FORMAT_TEXT_TYPE &#41; asal&#91;1&#93; &#58;= &#46;f&#46; RETURN asal endif do whil &#46;t&#46; if Substr&#40; cTextFormat, npos, 1 &#41; == SP_FIELD nPos += 1 exit endif cFacename &#58;= Substr&#40; cTextFormat, npos, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41; nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen cHeight &#58;= Substr&#40; cTextFormat, npos, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41; nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen cWidth &#58;= Substr&#40; cTextFormat, npos, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41; nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen lBold &#58;= if&#40;val&#40;Substr&#40; cTextFormat, npos, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41;&#41; = 0, &#46;f&#46;,&#46;t&#46;&#41; nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen lItalic &#58;= if&#40;val&#40;Substr&#40; cTextFormat, npos, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41;&#41; = 0, &#46;f&#46;,&#46;t&#46;&#41; nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen lUnderline &#58;= if&#40;val&#40;Substr&#40; cTextFormat, npos, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41;&#41; = 0, &#46;f&#46;,&#46;t&#46;&#41; nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen lStrikeOut &#58;= if&#40;val&#40;Substr&#40; cTextFormat, npos, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41;&#41; = 0, &#46;f&#46;,&#46;t&#46;&#41; nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen aadd&#40; afuentes, &#123;cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeOut&#125;&#41; enddo oShapes &#58;= &#58;&#58;oSelection&#58;Get&#40; "Shapes" &#41; oCuadro &#58;= oShapes&#58;Invoke&#40; "AddTextbox", 1,INT&#40;nLeft&#41;,INT&#40;nTop&#41;,INT&#40;nRight-nLeft&#41;,INT&#40;nBottom-nTop&#41;&#41; oCuadro&#58;Set&#40; 'RelativeHorizontalPosition',1&#41; oCuadro&#58;Set&#40; 'RelativeVerticalPosition',1&#41; oFill &#58;= oCuadro&#58;Get&#40; "Fill" &#41; oFill&#58;Set&#40; "Transparency",0&#41; oFill&#58;Set&#40; "Visible",0&#41; oLine &#58;= oCuadro&#58;Get&#40; "Line" &#41; oLine&#58;Set&#40; "Transparency",0&#41; oLine&#58;Set&#40; "Visible",0&#41; oCuadroText &#58;= oCuadro&#58;Get&#40; "TextFrame" &#41; oText &#58;= oCuadroText&#58;Get&#40; "TextRange" &#41; oCuadro&#58;Invoke&#40;'Select'&#41; do while &#40; cType &#58;= SubStr&#40; cTextFormat, nPos, 1 &#41; &#41; != SP_FIELD if cType == TP_ALIGN &#46;or&#46; cType == TP_FONT &#46;or&#46; cType == TP_COLOR if cType == TP_ALIGN njustify &#58;= Val&#40;Substr&#40; cTextFormat, npos +1, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41;&#41; &#58;&#58;Justificadoc&#40;njustify&#41; endif if cType == TP_FONT nfont &#58;= val&#40;SubStr&#40; cTextFormat, nPos + 1, nLen -1 &#41;&#41; oFont&#58;Set&#40; "Name", afuentes&#91;nfont,1&#93; &#41; oFont&#58;Set&#40; "Size", if&#40; val&#40;afuentes&#91;nfont,2&#93;&#41; < 0, val&#40;afuentes&#91;nfont,2&#93;&#41;*-1, val&#40;afuentes&#91;nfont,2&#93;&#41; &#41; &#41; oFont&#58;Set&#40; "Bold", afuentes&#91;nfont,4&#93; &#41; oFont&#58;Set&#40; "Italic", afuentes&#91;nfont,5&#93; &#41; oFont&#58;Set&#40; "Underline", afuentes&#91;nfont,6&#93; &#41; oFont&#58;Set&#40; "StrikeThrough", afuentes&#91;nfont,7&#93; &#41; endif if cType == TP_COLOR ncolortext &#58;= Val&#40;Substr&#40; cTextFormat, npos +1, At&#40; SP_REG, Substr&#40; cTextFormat, nPos &#41; &#41; -1 &#41;&#41; oFont&#58;Set&#40; "Color", ncolortext &#41; endif nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nPos += nLen else nLen &#58;= At&#40; SP_REG, SubStr&#40; cTextFormat, nPos &#41; &#41; nCrLf &#58;= At&#40; CRLF, SubStr&#40; cTextFormat, nPos &#41; &#41; if nLen == 0 if nCrLf == 0 nLen &#58;= At&#40; SP_FIELD, SubStr&#40; cTextFormat, nPos &#41; &#41; - 1 else nLen &#58;= nCrLf + 1 endif else if nCrLf == 0 &#46;or&#46; nCrLf > nLen do while SubStr&#40; ctextformat, nPos + --nLen - 1, 1 &#41; > Chr&#40; 32 &#41; enddo --nLen else nLen &#58;= nCRLf + 1 endif endif cText = SubStr&#40; cTextFormat, nPos, nLen &#41; &#58;&#58;oActiveDoc&#58;Invoke&#40; 'ComputeStatistics',2,&#46;t&#46;&#41; lnocabe &#58;= oCuadroText&#58;Get&#40; 'Overflowing'&#41; if lnocabe asal&#91;2&#93; &#58;= substr&#40; ctextformat,1, 4 &#41; asal&#91;2&#93; &#58;= asal&#91;2&#93; + substr&#40; ctextformat, 5, At&#40; SP_FIELD, Substr&#40; cTextformat, 5&#41; &#41;&#41; asal&#91;2&#93; &#58;= asal&#91;2&#93; + substr&#40; ctextformat, nPos + nLen&#41; exit endif cText = SubStr&#40; cTextFormat, nPos, nLen &#41; &#58;&#58;oTexto&#58;Invoke&#40; "Typetext", cText &#41; nPos += nLen endif enddo oFont&#58;Invoke&#40; "Reset" &#41; release oShapes, oCuadro, oFill, oLine, oCuadrotext, oFont RETURN asal METHOD SetCm&#40;&#41; CLASS TWord &#58;&#58;lSetCm &#58;= &#46;t&#46; RETURN METHOD SetHeader&#40;&#41; CLASS TWord local oWindow &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "ActiveWindow" &#41; local oView &#58;= oWindow&#58;Get&#40; "View"&#41; oView&#58;Set&#40; "SeekView" , 10 &#41; // 9 Header 10 Footer &#58;&#58;oSelection &#58;= &#58;&#58;oTexto&#58;Get&#40; "HeaderFooter"&#41; release oWindow, oView RETURN nil METHOD SetLandScape&#40;&#41; CLASS TWord local oPageSetup &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; 'PageSetup'&#41; oPageSetup&#58;Set&#40; 'Orientation','1'&#41; release oPageSetup RETURN nil METHOD SetMainDoc&#40;&#41; CLASS TWord local oWindow &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "ActiveWindow" &#41; local oView &#58;= oWindow&#58;Get&#40; "View"&#41; oView&#58;Set&#40; "SeekView" , 0 &#41; &#58;&#58;oSelection &#58;= &#58;&#58;oActiveDoc release oWindow, oView RETURN nil METHOD SetPortrait&#40;&#41; CLASS TWord local oPageSetup &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; 'PageSetup'&#41; oPageSetup&#58;Set&#40; 'Orientation','0'&#41; release oPageSetup RETURN nil METHOD SetUl&#40;&#41; CLASS TWord &#58;&#58;lSetCm &#58;= &#46;f&#46; RETURN METHOD StartPage&#40;&#41; CLASS TWord if &#58;&#58;lstartpag = &#46;t&#46; &#58;&#58;lstartpag &#58;= &#46;f&#46; else &#58;&#58;oTexto&#58;Invoke&#40; "EndKey" , 6 , 0 &#41; &#58;&#58;oTexto&#58;Invoke&#40; "InsertBreak" &#41; &#58;&#58;oTexto&#58;Invoke&#40; "GotoNext" , 1 &#41; &#58;&#58;nPage++ &#58;&#58;nLinea&#58;=0 &#58;&#58;nCol &#58;=0 endif &#58;&#58;Write&#40;chr&#40;31&#41;&#41; //Es necesario para ponder vincular los cuadros de texto a una pagina determinada&#46; RETURN nil METHOD TabClearAll&#40;ocuadrotext&#41; CLASS TWord local oparagraphformat, otabstop DEFAULT ocuadrotext &#58;= &#58;&#58;oTexto oParagraphformat &#58;= oCuadroText&#58;Get&#40; 'ParagraphFormat'&#41; oTabstop &#58;= oParagraphformat&#58;Get&#40; 'TabStops'&#41; oTabstop&#58;Invoke&#40;'ClearAll'&#41; release oparagraphformat, otabstop RETURN nil METHOD TabPredeterminado&#40;ncada&#41; CLASS TWord if &#58;&#58;lsetcm ncada &#58;= ncada*28&#46;35 endif &#58;&#58;oActiveDoc&#58;Set&#40; 'DefaultTabStop', ncada &#41; RETURN nil METHOD TextBox&#40; nTop, nLeft, nBottom, nRight, cTexto, oFuente, nclrtext, nClrBack, nJustify, afondo, alinea, lvertadjust, norientacion&#41; CLASS TWord local oShapes,oCuadro,oFill,oLinea, oFontC, oText, oCuadroText local nPad &#58;= 0, n, oWrap, nheighttext,; lnocabe &#58;= &#46;f&#46;, nheightbox&#58;= 0 DEFAULT nTop &#58;= 0, nLeft &#58;= 0, nBottom &#58;= 10, nRight &#58;= 10,; cTexto &#58;= ' ', oFuente &#58;= TFont&#40;&#41;&#58;New&#40;&#41;,; nClrText &#58;= nRGB&#40;0,0,0&#41;, nJustify &#58;= 0,; afondo &#58;= &#123;&#125;, alinea &#58;= &#123;&#125;, lvertadjust &#58;= &#46;f&#46;,; norientacion &#58;= 1 nheighttext &#58;= oFuente&#58;nHeight if norientacion > 3 norientacion &#58;= 1 endif do case case nJustify = 1 nPad &#58;= 2 case nJustify = 2 nPad &#58;= 1 case nJustify = 6 nPad &#58;= 0 endcase if &#58;&#58;lsetcm nTop &#58;= nTop*28&#46;35 nLeft &#58;= nLeft*28&#46;35 nBottom &#58;= nBottom*28&#46;35 nRight &#58;= nRight*28&#46;35 endif oShapes &#58;= &#58;&#58;oSelection&#58;Get&#40; "Shapes" &#41; oCuadro &#58;= oShapes&#58;Invoke&#40; "AddTextbox", norientacion,INT&#40;nLeft&#41;,INT&#40;nTop&#41;,INT&#40;nRight-nLeft&#41;,INT&#40;nBottom-nTop&#41; &#41; oFill &#58;= oCuadro&#58;Get&#40; "Fill" &#41; oCuadro&#58;Set&#40; 'RelativeHorizontalPosition',1&#41; oCuadro&#58;Set&#40; 'RelativeVerticalPosition',1&#41; //Fill for n = 1 to len&#40;afondo&#41; do case case n = 1 &#46;and&#46; afondo&#91;n&#93; <> NIL oFillColor &#58;= oFill&#58;Get&#40; "ForeColor"&#41; oFillColor&#58;Set&#40; 'RGB', afondo&#91;1&#93; &#41; case n = 2 &#46;and&#46; afondo&#91;n&#93; <> NIL oFillColor &#58;= oFill&#58;Get&#40; "BackColor"&#41; oFillColor&#58;Set&#40; 'RGB', afondo&#91;2&#93; &#41; case n = 3 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Set&#40; 'Transparency', afondo&#91;3&#93;&#41; case n = 4 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Invoke&#40; 'TwoColorGradient', afondo&#91;4&#93;, afondo&#91;5&#93; &#41; case n = 6 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Invoke&#40; 'Patterned', afondo&#91;6&#93; &#41; case n = 7 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Invoke&#40; 'PresetTextured', afondo&#91;7&#93; &#41; case n = 8 &#46;and&#46; afondo&#91;n&#93; <> NIL oFill&#58;Invoke&#40; 'UserTextured' , afondo&#91;8&#93; &#41; endcase next n //Linea de contorno oLinea &#58;= oCuadro&#58;Get&#40; "Line" &#41; for n = 1 to len&#40;alinea&#41; do case case n = 1 oLinea&#58;Set&#40; "Weight", alinea&#91;1&#93; &#41; case n = 2 oLinea&#58;Set&#40; "ForeColor", alinea&#91;2&#93; &#41; case n = 3 oLinea&#58;Set&#40; "BackColor", alinea&#91;3&#93; &#41; case n = 4 oLinea&#58;Set&#40; "Transparency", alinea&#91;4&#93;&#41; case n = 5 oLinea&#58;Set&#40; "DashStyle", alinea&#91;5&#93; &#41; case n = 5 oLinea&#58;Set&#40; "Style", alineas&#91;6&#93; &#41; endcase next n oCuadroText &#58;= oCuadro&#58;Get&#40; "TextFrame" &#41; oText &#58;= oCuadroText&#58;Get&#40; "TextRange" &#41; oFontC &#58;= oText&#58;Get&#40; "Font"&#41; oFontC&#58;Set&#40; "Name" , oFuente&#58;cFaceName &#41; oFontC&#58;Set&#40; "Size" , INT&#40;oFuente&#58;nHeight&#41; &#41; oFontC&#58;Set&#40; "Bold" , oFuente&#58;lBold &#41; oFontC&#58;Set&#40; "Color" , nclrtext &#41; oText&#58;Set&#40; 'HighlightColorIndex', nClrBack &#41; oText&#58;Set&#40; "Text", cTexto &#41; oParagraph &#58;= oText&#58;Get&#40; "ParagraphFormat"&#41; oParagraph&#58;Set&#40; "Alignment", nPad &#41; if lvertadjust nheightbox &#58;= 0 oCuadro&#58;Set&#40; 'Height', nheightbox&#41; &#58;&#58;oActiveDoc&#58;Invoke&#40; 'ComputeStatistics',2,&#46;t&#46;&#41; lnocabe &#58;= oCuadroText&#58;Get&#40; 'Overflowing'&#41; nheightbox &#58;= nheightbox + nHeighttext //+ OleGetProperty&#40;oParagraph,'SpaceBefore'&#41; do whil lnocabe = &#46;t&#46; &#46;and&#46; nheightbox <= nBottom - nTop oCuadro&#58;Set&#40; 'Height', nheightbox&#41; oText&#58;Set&#40; "Text", cTexto &#41; &#58;&#58;oActiveDoc&#58;Invoke&#40; 'ComputeStatistics',2,&#46;t&#46;&#41; lnocabe &#58;= oCuadroText&#58;Get&#40; 'Overflowing'&#41; nheightbox &#58;= nheightbox + nHeighttext //+ OleGetProperty&#40;oParagraph,'SpaceBefore'&#41; enddo else &#58;&#58;oActiveDoc&#58;Invoke&#40; 'ComputeStatistics',2,&#46;t&#46;&#41; lnocabe &#58;= oCuadroText&#58;Get&#40; 'Overflowing'&#41; nheightbox &#58;= nBottom endif lcorta &#58;= lnocabe ctexto2 &#58;= ctexto do whil lcorta &#46;and&#46; !empty&#40;ctexto2&#41; ctexto2 &#58;= Dellastword&#40;ctexto2&#41; oText&#58;Set&#40; 'Text', ctexto2&#41; &#58;&#58;oActiveDoc&#58;Invoke&#40;'ComputeStatistics',2,&#46;t&#46;&#41; lcorta &#58;= oCuadroText&#58;Get&#40; 'Overflowing'&#41; enddo &#58;&#58;ctextoverflow &#58;= strtran&#40;ctexto, ctexto2, ''&#41; &#58;&#58;loverflowing &#58;= lnocabe &#58;&#58;oLastSay &#58;= otext release oParagraph, OLinea, oFillColor, oFill, oFontC, oText,oCuadroText, oCuadro if &#58;&#58;lsetcm &#58;&#58;nlastrow &#58;= nBottom/28&#46;35 else &#58;&#58;nlastrow &#58;= nBottom endif RETURN Nil METHOD UnProtect&#40;cpassword&#41; CLASS TWord &#58;&#58;oActiveDoc&#58;Invoke&#40; "UnProtect", cpassword &#41; RETURN nil METHOD VistaCompleta&#40;&#41; CLASS TWord LOCAL oWindow, oView oWindow &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "ActiveWindow" &#41; oView &#58;= oWindow&#58;Get&#40; "View" &#41; oView&#58;Set&#40; "FullScreen", &#46;T&#46; &#41; &#58;&#58;Visualizar&#40;&#41; release oView RETURN nil METHOD Write&#40; cTexto, cFuente, nSize, lBold, lShadow, nColor &#41; CLASS TWord LOCAL oFont &#58;= &#58;&#58;oTexto&#58;Get&#40;"Font"&#41; oFont&#58;Set&#40; "Name", cFuente &#41; oFont&#58;Set&#40; "Size", nSize &#41; oFont&#58;Set&#40; "Bold", lBold &#41; oFont&#58;Set&#40; "Emboss", lShadow &#41; oFont&#58;Set&#40; "Color", nColor &#41; &#58;&#58;oTexto&#58;Invoke&#40; "TypeText", cTexto &#41; oFont&#58;Invoke&#40; "Reset" &#41; RELEASE oFont RETURN&#40; Nil &#41; static function dellastword&#40;ctexto&#41; sal &#58;= rtrim&#40;ctexto&#41; do whil !empty&#40;sal&#41; sal &#58;= substr&#40;sal,1, len&#40;sal&#41;-1&#41; if substr&#40;sal, len&#40;sal&#41;, 1&#41; = chr&#40;32&#41; &#46;or&#46; substr&#40;sal, len&#40;sal&#41;, 1&#41; = chr&#40;13&#41; exit endif enddo RETURN sal METHOD SendMail&#40; lAttach &#41; CLASS TWord // &#91; Vikthor &#93; DEFAULT lAttach &#58;= &#46;T&#46; &#58;&#58;oOptions&#58;Set&#40; "SendMailAttach" , lAttach &#41; &#58;&#58;oActiveDoc&#58;Invoke&#40; "SendMail" &#41; RETURN Self METHOD HeaderFooter&#40; nOption &#41; CLASS TWord // Vikthor /* wdSeekCurrentPageFooter 10 wdSeekCurrentPageHeader 9 wdSeekEndnotes 8 wdSeekEvenPagesFooter 6 wdSeekEvenPagesHeader 3 wdSeekFirstPageFooter 5 wdSeekFirstPageHeader 2 wdSeekFootnotes 7 wdSeekMainDocument 0 wdSeekPrimaryFooter 4 wdSeekPrimaryHeader 1 */ LOCAL oWindow &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "ActiveWindow" &#41; LOCAL oView &#58;= oWindow&#58;Get&#40; "View" &#41; DEFAULT nOption &#58;= 9 oView&#58;Set&#40; "SeekView", nOption &#41; IF&#40; nOption == 0 , ; &#58;&#58;oSelection &#58;= &#58;&#58;oActiveDoc , ; // Graba los datos al Documento &#58;&#58;oSelection &#58;= &#58;&#58;oTexto&#58;Get&#40; "HeaderFooter"&#41; &#41; // Abre el metodo para escritura release oWindow, oView RETURN&#40; Nil &#41; METHOD OpenDataSource&#40; cFile &#41; CLASS TWord // Vikthor /****** * Adjunta un origen de datos al documento especificado, que se convierte en documento principal si aún no lo es&#46; * <cFile> &#58; Nombre del archivo del origen de datos ******/ LOCAL oDField LOCAL cText, nItem , i , oRange DEFAULT cFile &#58;= "file&#46;xls" &#58;&#58;oMailMerge&#58;Invoke&#40; 'OpenDataSource' , cFile , 0 , &#46;F&#46; &#41; &#58;&#58;oDataSource &#58;= &#58;&#58;oMailMerge&#58;Get&#40;"DataSource"&#41; // Regresa el Objeto MailMergeDataSource &#58;&#58;oDataFields &#58;= &#58;&#58;oDataSource&#58;Get&#40;"DataFields"&#41; // Regresa el Objeto MailMergeDataFields &#58;&#58;oFields &#58;= &#58;&#58;oMailMerge&#58;Get&#40;"Fields"&#41; // Regresa el Objeto MailMergeFields /* cText &#58;= "Hay " nItem &#58;= &#58;&#58;oDataFields&#58;Count&#40;&#41; // Devuelve cuantos campos hay cText += Ltrim&#40;Str&#40; nItem &#41;&#41; + " campos para combinar correspondecia "+ CRLF + CRLF FOR i &#58;= 1 TO nItem oDField &#58;= &#58;&#58;oDataFields&#58;Item&#40; i &#41; // Regresa el Objeto MailMergeDataField cText += Str&#40; i &#41; + "&#46;-"+ oDField&#58;Name&#40;&#41; + CRLF NEXT &#58;&#58;Write&#40; chr&#40;13&#41;+chr&#40;13&#41;+ cText &#41; */ RETURN&#40; Nil &#41; METHOD AddField&#40; cField , cFuente, nSize, lBold, lShadow, nColor &#41; CLASS TWord // Vikthor LOCAL oRange &#58;= &#58;&#58;oSelection&#58;Range&#40;&#41; LOCAL nEnd &#58;= oRange&#58;Get&#40;"End"&#41; LOCAL oFont oRange&#58;SetRange&#40; nEnd , nEnd &#41; oFont &#58;= oRange&#58;Get&#40;"Font"&#41; DEFAULT cFuente &#58;= "Tahoma" ,; nSize &#58;= 10 ,; lBold &#58;= &#46;F&#46; ,; lShadow &#58;= &#46;F&#46; ,; nColor &#58;= 0 oFont&#58;Set&#40; "Name", cFuente &#41; oFont&#58;Set&#40; "Size", nSize &#41; oFont&#58;Set&#40; "Bold", lBold &#41; oFont&#58;Set&#40; "Emboss", lShadow &#41; oFont&#58;Set&#40; "Color", nColor &#41; &#58;&#58;oFields&#58;Invoke&#40;"Add", oRange , cField &#41; oFont&#58;Invoke&#40; "Reset" &#41; RELEASE oFont , oRange RETURN&#40; Nil &#41; METHOD AddTables&#40; aDatos , nPos &#41; CLASS TWord // Vikthor LOCAL oRange &#58;= &#58;&#58;oSelection&#58;Range&#40;&#41; LOCAL oTable , oCell , oCellRange , oCells LOCAL nRows , nCols LOCAL x , y nRows&#58;=Len&#40; aDatos &#41; nCols&#58;=Len&#40; aDatos&#91;1&#93; &#41; oRange&#58;SetRange&#40; nPos , nPos &#41; oTable&#58;= &#58;&#58;oTables&#58;Invoke&#40;"Add", oRange , nRows , nCols &#41; FOR x &#58;= 1 TO nRows FOR y &#58;= 1 TO nCols oCell &#58;= oTable&#58;Cell&#40; x , y&#41; oCellRange &#58;= oCell&#58;Range&#40;&#41; oCellRange&#58;Invoke&#40; 'InsertAfter' , aDatos&#91;x,y&#93; &#41; SysRefresh&#40;&#41; NEXT NEXT oColumns&#58;=oTable&#58;Columns&#58;Select&#40;&#41; oSelection&#58;= &#58;&#58;oWord&#58;Get&#40;"Selection"&#41; oFont&#58;=oSelection&#58;Font&#40;&#41; oFont&#58;Name&#58;='Tahoma' oFont&#58;Size&#58;=9 oColumns&#58;=oTable&#58;Columns&#58;AutoFit&#40;&#41; oCol&#58;=oTable&#58;Columns&#58;Item&#40;3&#41; oCol&#58;Select&#40;&#41; oSelection&#58;= &#58;&#58;oWord&#58;Get&#40;"Selection"&#41; oFont&#58;=oSelection&#58;Font&#40;&#41; oFont&#58;Name&#58;='Tahoma' oFont&#58;Size&#58;=9 FOR x &#58;= 1 TO nCols // Len&#40; aDatos &#41; oCol&#58;=oTable&#58;Columns&#58;Item&#40;x&#41; oCol&#58;Select&#40;&#41; oParagraph &#58;= oSelection&#58;Get&#40;"ParagraphFormat"&#41; oParagraph&#58;Set&#40; "Alignment", 2 &#41; SysRefresh&#40;&#41; NEXT oTable&#58;AutoFormat&#40;1&#41; RETURN&#40; oTable &#41; METHOD AddBar&#40; cName, Position, MenuBar, Temporary &#41; /*************** * * Crea una nueva barra de comandos y la agrega a la colección de barras de comandos&#46; * <Name> &#58; Variant opcional&#46; Nombre de la nueva barra de comandos&#46; Si se omite este argumento, Word asignará un nombre predeterminado a la barra de comandos, por ejemplo, Custom 1&#46; * <Position> &#58; Variant opcional&#46; Posición o tipo de la nueva barra de comandos&#46; * Puede ser una de las constantes MsoBarPosition que aparecen en la siguiente tabla&#58; * - msoBarLeft, msoBarTop, msoBarRight, msoBarBottom Indica las coordenadas izquierda, derecha, superior e inferior de la nueva barra de comandos&#46; * - msoBarFloating Indica que la nueva barra de comandos no estará acoplada&#46; * - msoBarPopup Indica que la nueva barra de comandos será un menú contextual&#46; * - msoBarMenuBar Sólo para Macintosh&#46; * <MenuBar> &#58; Variant opcional&#46; True para reemplazar la barra de menú activa con la nueva barra de comandos&#46; El valor predeterminado es False&#46; * <Temporary> &#58; Variant opcional&#46; True para que la nueva barra de comandos sea temporal&#46; Las barras de comandos temporales se eliminan al cerrar la aplicación contenedora&#46; El valor predeterminado es False&#46; ***************/ LOCAL oCommandBar&#58;= oWord&#58;Get&#40; "CommandBars" &#41; //LOCAL oNewButton &#58;= oWord&#58;Get&#40; "CommandBarsButton"&#41; oCommandBar&#58;Set&#40;"Name",cName&#41; oCommandBar&#58;Set&#40;"Position", msoBarFloting&#41; oCommandBar&#58;Set&#40;"MenuBar",&#46;f&#46;&#41; oCommandBar&#58;Set&#40;"Temporary", &#46;t&#46;&#41; RETURN&#40; Nil &#41; METHOD View&#40; nView &#41; CLASS TWord // Vikthor local oWindow &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "ActiveWindow" &#41; local oView &#58;= oWindow&#58;Get&#40; "View"&#41; oView&#58;Set&#40; "Type" , nView &#41; release oWindow, oView RETURN &#40; Nil &#41; METHOD Zoom&#40; nPercent &#41; CLASS TWord // Vikthor local oWindow &#58;= &#58;&#58;oActiveDoc&#58;Get&#40; "ActiveWindow" &#41; local oView &#58;= oWindow&#58;Get&#40; "View"&#41; DEFAULT nPercent &#58;= 100 oView&#58;Set&#40; "Zoom" , nPercent &#41; release oWindow, oView RETURN &#40; Nil &#41; METHOD Find&#40; cText &#41; CLASS TWord // Vikthor LOCAL oTexto, oFind, nEnd oTexto &#58;= &#58;&#58;oSelection&#58;Range&#40;&#41; oFind &#58;= oTexto&#58;Get&#40; "Find" &#41; oFind&#58;Set&#40;"ClearFormatting"&#41; oFind&#58;Set&#40; "Text", cText &#41; oFind&#58;Set&#40; "Forward", &#46;T&#46; &#41; oFind&#58;Set&#40; "Wrap", INT&#40;1&#41; &#41; //Establece lo que ocurre si la búsqueda se inicia en un punto distinto al principio del documento oFind&#58;Set&#40; "Format", &#46;f&#46; &#41; //Devuelve o establece el formato del objeto especificado oFind&#58;Set&#40; "MatchCase", &#46;f&#46; &#41; //True si la búsqueda distingue mayúsculas de minúsculas&#46; oFind&#58;Set&#40; "MatchWholeWord", &#46;f&#46; &#41; //True si la operación de búsqueda sólo busca palabras completas y no texto que forme parte de una palabra&#46; oFind&#58;Set&#40; "MatchWildcards", &#46;t&#46; &#41; //True si el texto va a buscarse contiene comodines de búsqueda oFind&#58;Set&#40; "MatchSoundsLike", &#46;f&#46; &#41; //Recibe el valor True si la operación de búsqueda encuentra las palabras que tienen un sonido parecido al del texto buscado oFind&#58;Set&#40; "MatchAllWordForms", &#46;f&#46; &#41; //Recibe el valor True si la operación de búsqueda encuentra todas las formas del texto que se debe buscar oFind&#58;Invoke&#40; "Execute"&#41; DO WHILE oFind&#58;Get&#40; "Found" &#41; oTexto&#58;Set&#40; "Text",cText &#41; oFind&#58;Invoke&#40; "Execute"&#41; Enddo nEnd &#58;= oTexto&#58;Get&#40;"End"&#41; Release oTexto , oFind RETURN&#40; nEnd &#41; ********************************* STATIC Function sSwap&#40; cChar, c1, c2 &#41; LOCAL n1,n2&#58;=-1,ac1,f IF ValType&#40;c1&#41;="A" ac1&#58;=c1 FOR f=1 TO Len&#40;ac1&#41; c1&#58;=ac1&#91;f&#93; WHILE &#46;T&#46; n1&#58;=At&#40;Upper&#40; c1 &#41;,Upper&#40; cChar &#41;&#41; IF n1=0 &#46;OR&#46; n1=n2 EXIT ENDIF cChar&#58;=SubStr&#40; cChar, 1, n1-1 &#41;+c2+SubStr&#40; cChar, n1+Len&#40;c1&#41;, Len&#40;cChar&#41;-Len&#40;c1&#41; &#41; n2&#58;=n1 ENDDO NEXT ELSE WHILE &#46;T&#46; n1&#58;=At&#40;Upper&#40; c1 &#41;,Upper&#40; cChar &#41;&#41; IF n1=0 &#46;OR&#46; n1=n2 EXIT ENDIF cChar&#58;=SubStr&#40; cChar, 1, n1-1 &#41;+c2+SubStr&#40; cChar, n1+Len&#40;c1&#41;, Len&#40;cChar&#41;-Len&#40;c1&#41; &#41; n2&#58;=n1 ENDDO ENDIF RETU cChar ******************************** Function sBreak&#40;o,c,x,lShowAlert,lQuit&#41; DEFAULT c&#58;="ERROR",x&#58;="",lQuit&#58;=&#46;f&#46; IF lShowAlert=NIL MsgStop&#40;If&#40;Empty&#40;x&#41;,"",x+CRLF+CRLF&#41;+AllTrim&#40;o&#58;Description&#41;+"&#58; "+AllTrim&#40;o&#58;Operation&#41;,c&#41; ENDIF IF lQuit MemoWrit&#40;"Error&#46;log",If&#40;Empty&#40;x&#41;,"",x+CRLF+CRLF&#41;+AllTrim&#40;o&#58;Description&#41;+"&#58; "+AllTrim&#40;o&#58;Operation&#41;&#41; QUIT ENDIF BREAK RETU NIL ******************************** Function V&#40;x&#41; LOCAL y&#58;=ValType&#40;x&#41;,cRetu&#58;="" DO CASE CASE y=="C" ; RETU x CASE y=="M" ; RETU x CASE y=="N" ; RETU If&#40;Empty&#40;x&#41;,"",LTrim&#40;Str&#40;x&#41;&#41;&#41; CASE y=="D" ; RETU If&#40;Empty&#40;x&#41;,"",DtoC&#40;x&#41;&#41; CASE y=="A" ; RETU &#40;AEval&#40;x,&#123;|a|cRetu+=RTrim&#40;V&#40;a&#41;&#41;+","&#125;&#41;,SubStr&#40;cRetu,1,Len&#40;cRetu&#41;-1&#41;&#41; CASE y=="L" ; RETU If&#40;x,"&#46;T&#46;","&#46;F&#46;"&#41; CASE y=="U" ; RETU "_NIL_!" CASE y=="B" ; RETU V&#40;&#123;Eval&#40;x&#41;&#125;&#41; CASE y=="O" ; RETU "_OBJECT_!" OTHER ; RETU "?" ENDCASE RETU x [/code:8msvx1a8]ThanksFarley
create a function with Tdatabase
I would like to have a function that opens an archive and sets a series of indexes I tried to do this function but it doesn't turn me at all I don't understand where I'm wrong sample of Usage oCustomers:Open_Db( "customer", , {FIRST,LAST} ) oCustomers:SetOrder( "FIRST" ) oCustomers:GoTop() [code=fw:34sqg72s]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00C800;">FUNCTION</span> Open_Db<span style="color: #000000;">&#40;</span> cArchivio, aIdx <span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">LOCAL</span> cAlias<br />   <span style="color: #00C800;">LOCAL</span> oDbf<br />   <span style="color: #00C800;">LOCAL</span> i<br />   <span style="color: #00C800;">STATIC</span> _Select_<br />   <span style="color: #00C800;">DEFAULT</span> _Select_ := <span style="color: #000000;">0</span><br /><br />   cAlias := <span style="color: #ff0000;">"TD"</span> + PADL<span style="color: #000000;">&#40;</span> ++_Select_, <span style="color: #000000;">3</span>, <span style="color: #ff0000;">"0"</span> <span style="color: #000000;">&#41;</span><br /><br />   DbUseArea<span style="color: #000000;">&#40;</span> .T. ,, cArchivio, cAlias, .T. <span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">IF</span> VALTYPE<span style="color: #000000;">&#40;</span> aIdx <span style="color: #000000;">&#41;</span> == <span style="color: #ff0000;">"A"</span><br />      <span style="color: #00C800;">FOR</span> i := <span style="color: #000000;">1</span> <span style="color: #0000ff;">TO</span> LEN<span style="color: #000000;">&#40;</span> aIdx <span style="color: #000000;">&#41;</span><br />         DBSETINDEX<span style="color: #000000;">&#40;</span> aIdx<span style="color: #000000;">&#91;</span> i <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span><br />      <span style="color: #00C800;">NEXT</span><br />   <span style="color: #00C800;">ENDIF</span><br /><br />   oDbf := TDatabase<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span>,cAlias<span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00C800;">RETURN</span> oDbf</div>[/code:34sqg72s] [b:34sqg72s]return me a message "TD0001.dbf not avaible"[/b:34sqg72s] then I tried with [code=fw:34sqg72s]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> Open_Db<span style="color: #000000;">&#40;</span> cArchivio, aIdx <span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">LOCAL</span> cAlias<br />   <span style="color: #00C800;">LOCAL</span> oDbf<br />   <span style="color: #00C800;">LOCAL</span> i<br />   <span style="color: #00C800;">STATIC</span> _Select_<br />   <span style="color: #00C800;">DEFAULT</span> _Select_ := <span style="color: #000000;">0</span><br /><br />   oDbf := TDatabase<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span>,cArchivio<span style="color: #000000;">&#41;</span><br /><br />   <span style="color: #00C800;">IF</span> VALTYPE<span style="color: #000000;">&#40;</span> aIdx <span style="color: #000000;">&#41;</span> == <span style="color: #ff0000;">"A"</span><br />      <span style="color: #00C800;">FOR</span> i := <span style="color: #000000;">1</span> <span style="color: #0000ff;">TO</span> LEN<span style="color: #000000;">&#40;</span> aIdx <span style="color: #000000;">&#41;</span><br />         DBSETINDEX<span style="color: #000000;">&#40;</span> aIdx<span style="color: #000000;">&#91;</span> i <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span><br />      <span style="color: #00C800;">NEXT</span><br />   <span style="color: #00C800;">ENDIF</span><br /><span style="color: #00C800;">RETURN</span> oDbf<br /> </div>[/code:34sqg72s] [b:34sqg72s]but make error because Error description: Error DBCMD/2001 Workarea not in use: ORDLISTADD Stack Calls =========== Called from: => ORDLISTADD( 0 ) Called from: ../../../rddord.prg => DBSETINDEX( 0 ) what do you recommend?[/b:34sqg72s]