tag:blogger.com,1999:blog-9549266544897536012024-02-08T07:28:52.003-08:00Delphi Master'sO Delphi foi minha primeira experiência séria em desenvolvimento.
Erick Almeida.Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-954926654489753601.post-77701607210760121912007-04-18T04:18:00.000-07:002007-04-18T04:19:26.896-07:00INFO Online: Borland troca Vale do Silício pelo Texas<font style="font-family: Georgia;" size="2">Será que o Vale do Silício não é mais aquele? A Borland está mudando de Cupertino, na Califórnia, para Austin, no Texas. </font><p style="font-family: Georgia;"> </p><p style="font-family: Georgia;"><font size="2">A informação está num documento publicado nesta segunda-feira, 16/4, no site da empresa. “Estamos mudando para aproveitar as vantagens de uma área que combina um forte pólo de talentos com um ambiente de menor custo para a Borland”, diz Tod Nielsen, presidente e CEO. </font></p><p style="font-family: Georgia;"> </p><p style="font-family: Georgia;"><font size="2">Na visão de Nielsen, as condições de Austin são melhores para os planos de expansão da Borland. “No Vale do Silício, somos um peixinho num lago enorme. Em Austin, poderemos nos tornar um nome líder em software e atrair grandes talentos”, disse ele ao jornal The Austin American Statesman.<br><br></font><a title="Saiba mais" href="http://info.abril.com.br/aberto/infonews/042007/17042007-28.shl">Saiba mais</a><font size="2"> (info.abril.com.br)<br> </font></p>Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.com0tag:blogger.com,1999:blog-954926654489753601.post-15949710937954110922007-03-17T19:13:00.000-07:002007-03-17T19:13:35.873-07:00Usando VCL for PHP para criar aplicações de banco de dados e usando dicionários de dados em Delphi for PHP<P STYLE=FONT-FAMILY:Georgia> <FONT SIZE=2><SPAN LANG=ES-MX><FONT SIZE=2>English Version <A HREF=http://blogs.codegear.com/andreanolanusse/archive/2007/02/24/32334.aspx><STRONG><FONT COLOR=#770000>click here</FONT></STRONG></A><BR> Versión en Español <A HREF=http://blogs.codegear.com/andreanolanusse/archive/2007/02/24/32333.aspx><STRONG><FONT COLOR=#770000>clic acá</FONT></STRONG></A><BR> <BR> A VCL para PHP está integrada a tecnologia AJAX, com este recurso podemos atualizações as informações em um DBGrid sem ter que enviar(submit) a página ao servidor.<BR> <BR> Outro fantástico recurso na VCL para PHP é o suporte a dicionários de dados, você pode definir os valores de algumas propriedades como DisplayLabel e DisplayWidth no dicionário de dados e os componentes da VCL para PHP automaticamente atualizam os valores de cada propiedade, quando a aplicação é executada.<BR> <BR> <A HREF=http://dn.codegear.com/article/34090>Assista este Vídeo</A> e veja como é rápido criar aplicações de banco de dados em <A HREF=http://www.codegear.com/Products/Delphi/DelphiforPHP/tabid/237/Default.aspx>Delphi para PHP</A></FONT></SPAN></FONT> </P>Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.com2tag:blogger.com,1999:blog-954926654489753601.post-50693175822950778522007-03-17T19:06:00.000-07:002007-03-17T19:09:52.094-07:00DBX 4 Framework (Delphi 2007 para Win32)<P STYLE=FONT-FAMILY:Georgia> D<FONT SIZE=2>efinitivamente DBX 4 facilita a vida do desenvolvedor, é muito fácil utilizar o framework.<BR> <BR> Abaixo um exemplo que mostra o quão fácil é utilizar o Framework do DBX, este exemplo conecta ao banco de dados, lê os parâmetros de conexão, inicia uma transação, executa uma consulta e comita a transação.<BR> </FONT> </P> <DIV> <TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%> <TBODY> <TR> <TD WIDTH=100%> <FONT FACE=Verdana SIZE=2><FONT SIZE=1><FONT COLOR=#000080><STRONG>program</STRONG></FONT> DBX4Example;<BR> <BR> </FONT></FONT><FONT COLOR=#008000 FACE=Verdana SIZE=1>{$APPTYPE CONSOLE}<BR> <BR> </FONT><FONT FACE=Verdana><FONT SIZE=1><FONT COLOR=#000080><STRONG>uses</STRONG></FONT><BR> SysUtils,<BR> DBXDynalink,<BR> Dialogs,<BR> DBXCommon;<BR> <BR> </FONT></FONT><FONT COLOR=#000080 FACE=Verdana><FONT SIZE=1><STRONG>var</STRONG><BR> </FONT></FONT><FONT FACE=Verdana SIZE=1> aConnName: <FONT COLOR=#000080><STRONG>string</STRONG></FONT>;<BR> aDBXConn: TDBXConnection;<BR> aDBXTrans : TDBXTransaction;<BR> aCmnd: TDBXCommand;<BR> aReader: TDBXReader;<BR> aColCount: integer;</FONT> <P> <FONT SIZE=1><FONT FACE=Verdana><FONT COLOR=#000080><STRONG>begin</STRONG></FONT><BR> </FONT><FONT FACE=Verdana> aDBXConn := TDBXConnectionFactory.GetConnectionFactory.GetConnection('<FONT COLOR=#000080>EMPLOYEE</FONT>','<FONT COLOR=#000080>sysdba</FONT>','<FONT COLOR=#000080>masterkey</FONT>');</FONT></FONT> </P> <P> <FONT FACE=Verdana><FONT SIZE=1> <STRONG><FONT COLOR=#000080>if</FONT></STRONG> aDBXConn <> <FONT COLOR=#000080><STRONG>nil</STRONG></FONT> then<BR> <STRONG><FONT COLOR=#000080>begin<BR> </FONT></STRONG></FONT></FONT><FONT FACE=Verdana SIZE=1><BR> <FONT COLOR=#000000> </FONT><FONT COLOR=#008000>// Write the all connection parameters</FONT><BR> <FONT COLOR=#000000> Writeln( '</FONT><FONT COLOR=#000080>===================== Connection Properties ===============</FONT><FONT COLOR=#000000>' );<BR> WriteLn( aDBXConn.ConnectionProperties.Properties.Text);<BR> Writeln( '</FONT><FONT COLOR=#000080>====================================================</FONT><FONT COLOR=#000000>' );<BR> Writeln( '' );<BR> <BR> </FONT> aCmnd := aDBXConn.CreateCommand;</FONT> </P> <P> <FONT FACE=Verdana SIZE=1> <FONT COLOR=#008000>// Start transaction</FONT><BR> aDBXTrans:= aDBXConn.BeginTransaction(TDBXIsolations.ReadCommitted);</FONT> </P> <P> <FONT FACE=Verdana SIZE=1> <FONT COLOR=#008000>// Prepare and execute the SQL Statement</FONT><BR> aCmnd.Text := 'SELECT * FROM Country';<BR> aCmnd.Prepare;<BR> aReader := aCmnd.ExecuteQuery;</FONT> </P> <P> <FONT FACE=Verdana SIZE=1> aColCount := aReader.ColumnCount;<BR> Writeln( '<FONT COLOR=#000080>Results from Query: </FONT>' + aCmnd.Text );<BR> Writeln( '<FONT COLOR=#000080>Number of Columns: </FONT>' + IntToStr(aColCount) );</FONT> </P> <P> <FONT FACE=Verdana SIZE=1> <FONT COLOR=#000080><STRONG>while</STRONG></FONT> aReader.Next <FONT COLOR=#000080><STRONG>do</STRONG></FONT><BR> <STRONG><FONT COLOR=#000080>begin</FONT></STRONG><BR> Writeln( aReader.Value['<FONT COLOR=#000080>Country</FONT>'].GetAnsiString );<BR> <FONT COLOR=#000080><STRONG>end</STRONG></FONT>;</FONT> </P> <P> <FONT FACE=Verdana SIZE=1> Writeln( '<FONT COLOR=#000080>====================================================</FONT>' );<BR> Writeln( '' );</FONT> </P> <P> <FONT FACE=Verdana SIZE=1> <FONT COLOR=#008000>// Commit transaction</FONT><BR> aDBXConn.CommitFreeAndNil(aDBXTrans);</FONT> </P> <P> <FONT FACE=Verdana SIZE=1> Readln;<BR> aReader.Free;<BR> aCmnd.Free;<BR> aDbxConn.Free;<BR> </FONT><FONT SIZE=1><FONT FACE=Verdana> <STRONG><FONT COLOR=#000080>end</FONT></STRONG>;<BR> </FONT><FONT COLOR=#000080 FACE=Verdana><STRONG>end.</STRONG></FONT></FONT> </P> </TD> </TR> </TBODY> </TABLE> </DIV> <P STYLE=FONT-FAMILY:Georgia> <FONT SIZE=2>O resultado é:<BR> <BR> ================= Connection Properties ============<BR> DelegateConnection=<BR> DriverName=Interbase<BR> DriverUnit=DBXDynalink<BR> DriverPackageLoader=TDBXDynalinkDriverLoader<BR> DriverPackage=DBXCommonDriver110.bpl<BR> DriverAssemblyLoader=Borland.Data.TDBXDynalinkDriverLoader<BR> DriverAssembly=Borland.Data.DbxCommonDriver,Version=11.0.5000.0,Culture=neutral,PublicKeyToken=a91a7c5705831a4f<BR> Database=localhost:C:CodeGearInterBaseexamplesdatabaseemployee.ib<BR> RoleName=RoleName<BR> User_Name=sysdba<BR> Password=masterkey<BR> ServerCharSet=<BR> SQLDialect=3<BR> BlobSize=-1<BR> CommitRetain=False<BR> WaitOnLocks=True<BR> ErrorResourceFile=<BR> LocaleCode=0000<BR> Interbase TransIsolation=ReadCommited<BR> Trim Char=False<BR> ConnectionName=Employee</FONT> </P> <FONT SIZE=2 STYLE=FONT-FAMILY:Georgia>====================================================<BR> <BR> Results from Query: SELECT * FROM Country<BR> Number of Columns: 2<BR> USA<BR> England<BR> Canada<BR> Switzerland<BR> Japan<BR> Italy<BR> France<BR> Germany<BR> Australia<BR> Hong Kong<BR> Netherlands<BR> Belgium<BR> Austria<BR> Fiji<BR> teste<BR> ss<BR> aaaa<BR> aaa1<BR> brazil<BR> ====================================================<BR> <BR STYLE=FONT-FAMILY:Georgia> </FONT><HR STYLE=WIDTH:100%;HEIGHT:2px;FONT-FAMILY:Georgia><SPAN STYLE=FONT-WEIGHT:bold>Outros artigos do mesmo autor:</SPAN><BR> <FONT SIZE=2><A HREF=http://blogs.codegear.com/andreanolanusse/archive/2007/03/04/32689.aspx>DBX 4 Framework - Class Diagram - Delphi 2007 for Win32<BR> <BR> </A></FONT><SPAN STYLE=FONT-WEIGHT:bold>Traduções deste artigo:</SPAN><BR STYLE=FONT-FAMILY:Georgia> <FONT COLOR=#000080 SIZE=1><FONT COLOR=#000000 STYLE=FONT-FAMILY:Georgia><FONT SIZE=2>Versión en Español <A HREF=http://blogs.codegear.com/andreanolanusse/archive/2007/03/13/32978.aspx><STRONG><FONT COLOR=#770000><FONT SIZE=2>clic acá</FONT></FONT></STRONG></A></FONT></FONT><BR STYLE=FONT-FAMILY:Georgia> <FONT COLOR=#000000 FACE=Verdana SIZE=2 STYLE=FONT-FAMILY:Georgia>English Version </FONT><A HREF=http://blogs.codegear.com/andreanolanusse/archive/2007/03/13/32975.aspx STYLE=FONT-FAMILY:Georgia><STRONG><FONT COLOR=#770000><FONT SIZE=2>click here</FONT></FONT></STRONG></A><BR STYLE=FONT-FAMILY:Georgia> <BR STYLE=FONT-FAMILY:Georgia> <BR> </FONT>Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.com0tag:blogger.com,1999:blog-954926654489753601.post-11467724978796908632007-03-17T18:45:00.000-07:002007-03-17T18:59:55.985-07:00Usando StringList para retornar várias Strings <font size="2"> </font> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2">Esses dias precisei criar uma função que me retornasse uma array de string. Porém não consegui achar em nenhum lugar um meio de fazer isso em delphi. Apenas vi que muitos outros programadores também estavam com o mesmo problema. Por isso resolvi postar algo que talvez ajude a contornar essa situação. O artigo é algo bem simples.</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font style="font-weight: bold;" size="2">Código da função</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"><br> </font> </p> <div style="font-family: Courier New;"> <table bgcolor="#cccccc" border="0" cellpadding="3" cellspacing="0" width="100%"> <tbody> <tr> <td width="100%"> <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2">// entrada de dados<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2">//para função “S” recebe string, “separador” recebe caracter de separação da string.</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"><span style="font-weight: bold;">function </span>Tform1.arraystring(S : String; separador : char): TStringList;<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-weight: bold; font-family: Georgia;"> <font size="2">var</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> conta : integer; // variáveis auxiliares</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> resultado : TStringList; // variáveis auxiliares</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> Saux : string; // variáveis auxiliares</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font style="font-weight: bold;" size="2">begin</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">// inicializa variavel</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> resultado := TStringList.Create;<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">//pega posição do separador</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> conta := pos(separador,S);</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">// verifica se existe o separador caso contrario trata apenas<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> // como uma única linha</font><font size="2"> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">if</span> conta <> 0 <span style="font-weight: bold;">then<br> </span></font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"><span style="font-weight: bold;"> begin <br> </span></font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"><span style="font-weight: bold;"> </span></font><font size="2">// enquanto S não for nulo executa</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">while</span> trim(S) <> '' <span style="font-weight: bold;">do</span><br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"><span style="font-weight: bold;"> begin</span> <br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"><font size="2"> </font><font size="2">// Variável Saux recebe primeiro valor</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> Saux := copy(S,1,conta-1);<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">//deleta primeiro valor</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> delete(S,1,conta);<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">//se não ouver mais separador Saux equivale ao resto da<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> //linha</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">if</span> conta = 0 <span style="font-weight: bold;">then<br> </span></font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"><span style="font-weight: bold;"> begin</span> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> Saux := S;</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> S := '';</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">end</span>;</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">// adiciona linhas na string lista</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> resultado.Add(Saux);<br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">//pega posição do separador</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> conta := pos(separador,S); </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">end</span>;</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">end</span></font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">else </span><br> </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">begin</span></font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> Saux := S;</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> resultado.Add(Saux);</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> <span style="font-weight: bold;">end</span>;</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> </font><font size="2">// retorna resultado como uma lista indexada</font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"> Result := resultado; </font> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2"><span style="font-weight: bold;">end</span>;</font> </p> </td> </tr> </tbody> </table> </div> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Courier New;"> </p> <font size="2"><br> </font> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <font size="2">Para ver a utilização do código </font><a href="http://www.delphi.eti.br/ver_artigo.php?id=49" title="acesse este site">acesse este site</a>. </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Georgia;"> <br> </p>Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.com1tag:blogger.com,1999:blog-954926654489753601.post-83303440827835042072007-03-14T05:47:00.000-07:002007-03-14T05:50:12.096-07:00Delphi para PHP Quick Start<font style="font-family: Georgia;" size="2">Delphi para PHP é o mais novo produto da CodeGear para desenvolver aplicações PHP, módulos, bibliotecas e componentes "como em Delphi." Delphi para PHP é um ambiente de desenvolvimento RAD (Desenvolvimento Rápido de Aplicações) que contém um designer, editor, debugger, wizard para distribuição da aplicação e um framework de componentes chamado "VCL para PHP."<br><br>Os usuários de Delphi terão grande familiaridade. Esperamos que os desenvolvedores PHP tenham mais produtividade, gostem da ferramenta e tenham um uso amigável.<br><br><span style="font-weight: bold;">Instalando Delphi para PHP</span><br> Enquanto as aplicações desenvolvidades em Delphi para PHP™ podem ser executadas em qualquer dispositivo que suporte PHP, o ambiente integrado de desenvolvimento (IDE) é suportado apenas em plataforma Microsoft Windows nesta versão. Depois de ter o arquivo de instalação do Delphi para PHP, você pode executar a ferramenta de instalação.<br><br>Para ler o artigo na íntegra acesse <a title="www.activedelphi.com.br" href="http://www.activedelphi.com.br/modules.php?op=modload&name=News&file=article&sid=489">www.activedelphi.com.br</a>.</font> <br><br> <br>Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.com0tag:blogger.com,1999:blog-954926654489753601.post-46367124280908599672007-03-14T05:30:00.000-07:002007-03-14T05:33:46.089-07:00Armazenando imagens, sons e vídeos em bancos de dados<font size="2"><span style="font-family: Georgia;"> Um dos recursos mais interessantes nos bancos de dados atuais é a possibilidade de armazenar recursos multimídia juntamente com outras informações. Dessa forma, é possível criar registros com informações mais ricas sobre um determinado assunto. Por exemplo, pode-se armazenar informações sobre um funcionário juntamente com a sua própria foto. No Paradox, por exemplo, existe um tipo de campo destinado especialmente para esse fim.</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> No entanto, as possibilidades vão muito além do que o simples armazenamento de imagens. É possível armazenar sons, filmes ou qualquer tipo de arquivo, usando o "obscuro" campo BLOB (Binary Large Object), que permite que qualquer arquivo seja "embutido" no banco de dados. Na verdade, o conteúdo do arquivo não é armazenado no registro em si, mas num arquivo separado que é manipulado internamente pelo banco de dados.</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Trabalhar com esse tipo de campo no Delphi é muito simples, mas não tão óbvio à primeira vista. A manipulação de campos <span style="font-weight: bold;">BLOB</span>, diferentemente dos campos comuns, não deve ser feita diretamente, mas sim por meio do objeto <span style="font-weight: bold;">TBlobField</span>, descendente do <span style="font-weight: bold;">TField</span>, que disponibiliza recursos especiais para esse fim. Para isso, você deve sempre se referir ao campo BLOB no código como sendo um <span style="font-weight: bold;">TBlobField</span>, utilizando typecasting.</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Vamos supor que você tenha um arquivo de som MyWave.wav que será armazenado no campo "SOM" da tabela "MyTable". Para carregar o conteúdo do arquivo no campo SOM, basta fazer assim:</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Courier New; color: rgb(255, 0, 0);">TBlobField(MyTable.FieldByName('SOM')).LoadFromFile('MeuWave.wav');</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Neste exemplo, você usou o recurso de typecasting para manipular o campo como sendo um objeto TBlobField, carregando o arquivo através do método LoadFromFile que existe nesse objeto. Fácil, não é?</span><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Se você quiser salvar o conteúdo do campo "SOM" no arquivo "MyWaveCopy.wav", basta fazer assim:</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Courier New; color: rgb(255, 0, 0);">TBlobField(MyTable.FieldByName('SOM')).SaveToFile('MyWaveCopy.60wav');</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Para remover o conteúdo do campo "SOM" (limpá-lo), você também deve usar um método apropriado:</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Courier New; color: rgb(255, 0, 0);">TBlobField(MyTable.FieldByName('SOM')).Clear;</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Para saber se o campo SOM possui algum conteúdo, use a propriedade IsNull:</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Courier New; color: rgb(255, 0, 0);">with MyTable do</span><br style="font-family: Courier New; color: rgb(255, 0, 0);"><span style="font-family: Courier New; color: rgb(255, 0, 0);"> if not TBlobField(FieldByName('SOM')).IsNull then</span><br style="font-family: Courier New; color: rgb(255, 0, 0);"><span style="font-family: Courier New; color: rgb(255, 0, 0);"> TBlobField(FieldByName('SOM')).SaveToFile('MyWaveCopy.wav');</span><br style="font-family: Courier New; color: rgb(255, 0, 0);"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> A maneira mais simples de utilizar o conteúdo de um campo BLOB já armazenado é primeiro gravá-lo novamente em um arquivo em disco, usando o método SaveToFile, e depois manipulá-lo normalmente. No caso de um conteúdo em formato wave, por exemplo, você deve primeiro gravá-lo num arquivo .wav, e então reproduzí-lo através do <span style="font-weight: bold;">TMediaPlayer </span>ou pela função <span style="font-weight: bold;">SndPlaySound</span>.</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Usando os mesmos métodos, você também pode armazenar e manipular filmes AVI, apresentações, documentos, enfim, o que a sua imaginação mandar. Mas tenha em mente que o armazenamento de arquivos de som ou outros tipos vai aumentar consideravelmente o tamanho do seu banco de dados, por isso esse recurso deve ser utilizado com cuidado. Uma boa medida para reduzir esse problema é compactar o arquivo antes de armazená-lo. Para utilizá-lo depois, basta gerar o arquivo novamente em disco e descompactá-lo. Para saber quanto um campo <span style="font-weight: bold;">BLOB </span>está ocupando num registro do seu arquivo, em bytes, use a propriedade BlobSize:</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Courier New; color: rgb(255, 0, 0);">TBlobField(MyTable.FieldByName('SOM')).BlobSize;</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Obs: Para armazenar imagens ou texto em formato RichText (RTF), use os tipos GRAPHIC e FORMATED MEMO do Paradox, que são destinados a esses tipos de dados. O Delphi também possui objetos para a manipulação desses campos: TGraphicField e TMemoField, ambos descendentes do TBlobField.</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Dúvidas/Sugestões favor entrar em contato.</span><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Comentem aí pessoal.</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> E-mail: markuvinicius@uol.com.br</span><br style="font-family: Georgia;"><span style="font-family: Georgia;"> msn : marku@gabtransportes.com.br</span><br style="font-family: Georgia;"><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Até a próxima pessoal.</span><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Marku Vinícius</span><br style="font-family: Georgia;"><span style="font-family: Georgia;"> Clique aqui para ler o </span><a style="font-family: Georgia;" title="Artigo original" href="http://www.delphi.eti.br/ver_artigo.php?id=126">Artigo original</a><span style="font-family: Georgia;"> </span><br style="font-family: Georgia;"></font>Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.com0tag:blogger.com,1999:blog-954926654489753601.post-60283940393694712622007-03-14T05:02:00.000-07:002007-03-14T05:04:12.689-07:00Convertendo Texto em Imagem<font style="font-family: Georgia;" size="2"> Esta é uma dica bastante interessante para geração de imagens para validação, por exemplo. Através de uma procedure, você poderá montar uma imagem com o texto que quizer, com opção de grau de inclinação, e ainda poderá salvá-la.<br> </font> <p style="font-family: Georgia;"> <font size="2"> Veja abaixo o código da procedure:<br> </font></p><div><table bgcolor="#cccccc" border="1" bordercolor="#000000" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td width="100%"><pre style="font-family: Courier New;"><font><font size="2"><strong>procedure</strong> ConvTextOut(CV: TCanvas; <strong>const</strong> sText: <strong>String</strong>; x, y, angle:integer);<br><strong>var</strong><br> LogFont: TLogFont;<br> SaveFont: TFont;<br><strong>begin</strong><br> SaveFont := TFont.Create;<br> SaveFont.Assign(CV.Font);<br> GetObject(SaveFont.Handle, sizeof(TLogFont), @LogFont);<br> <strong>with</strong> LogFont <strong>do</strong><br> <strong>begin</strong><br> lfEscapement := angle *10;<br> lfPitchAndFamily := FIXED_PITCH <strong>or</strong> FF_DONTCARE;<br> <strong>end</strong>;<br> CV.Font.Handle := CreateFontIndirect(LogFont);<br> SetBkMode(CV.Handle, TRANSPARENT);<br> CV.TextOut(x, y, sText);<br> CV.Font.Assign(SaveFont);<br> SaveFont.Free;<br><strong>end</strong>;</font></font></pre></td></tr></tbody></table></div><font style="font-family: Georgia;" size="2"><strong><br></strong></font><font style="font-family: Georgia;" size="2">Para usá-la, você precisa passar o Canvas de destino, ou seja, onde seu texto será desenhado. Qualquer componente que possua a propriedade Canvas poderá ser utilizado para tal, como o próprio form, e até um TImage, que nos permitirá salvar a imagem. Veja:</font><font style="font-family: Georgia;" size="2"><br><br>No Form: </font><p style="font-family: Georgia;"> </p> <pre style="font-family: Georgia;"><font size="2"> ConvTextOut(Canvas, Edit1.Text, 10, 70, 0);</font></pre> <p style="font-family: Georgia;"> <font size="2"> No TImage: </font> </p> <pre style="font-family: Georgia;"><font size="2"> </font><font size="2">ConvTextOut(Image1.Canvas, Edit1.Text, 20, 10, 315);<br> Image1.Picture.SaveToFile(<font color="#000066">'C:imagem.bmp'</font>);</font></pre> <p style="font-family: Georgia;"> <font size="2"> Para testar, adicionei um Edit, bois Buttons e um TImage, programando cada um dos códigos acima do seu respectivo botão. O resultado foi como a figura abaixo:<br> </font> </p> <p style="font-family: Georgia;" align="center"> <font size="2"><img src="http://docs.google.com/File?id=ajjrcvchpcnb_95gs3wm7" style="height: 189px; width: 302px;" align="middle"><br> Figura 1 - Resultado da Conversão de Texto em Imagem </font> </p> <p style="font-family: Georgia;"> <font size="2"><br> </font> </p>Anonymoushttp://www.blogger.com/profile/08230169093134748965noreply@blogger.com2