<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8337375805238385969</id><updated>2024-09-24T21:33:15.905-03:00</updated><category term="Delphi"/><category term="Excel"/><category term="VBA"/><category term="Aplicativo"/><category term="C#"/><category term="Google Play"/><category term="NPOI"/><title type='text'>O Código Fonte</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8337375805238385969.post-8059236452377112014</id><published>2015-07-11T15:56:00.002-03:00</published><updated>2015-08-02T17:38:44.206-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Aplicativo"/><category scheme="http://www.blogger.com/atom/ns#" term="Google Play"/><title type='text'>Aplicativo Random no Google Play</title><content type='html'>Conheça o aplicativo &lt;a href=&quot;https://play.google.com/store/apps/details?id=br.com.mdtsolutions.random.free&quot; target=&quot;_blank&quot;&gt;Random&lt;/a&gt;, com ele você pode gerar:&lt;br /&gt;
&lt;br /&gt;
- Combinações aleatórias entre letras, números e caracteres especiais;&lt;br /&gt;
- Listas aleatórias;&lt;br /&gt;
- Nomes aleatórios; e&lt;br /&gt;
- Números aleatórios;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://play.google.com/store/apps/details?id=br.com.mdtsolutions.random.free&quot; target=&quot;_blank&quot;&gt;Clique aqui&lt;/a&gt; para ir para o aplicativo no Google Play ou se preferir, utilize o QR CODE abaixo direto no seu Smartphone.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com/2015/07/random.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;qr code aplicativo random&quot; border=&quot;0&quot; src=&quot;https://sites.google.com/site/ocodigofonte/imagens/postagens/2015_07_app_random_qrcode.jpg&quot; title=&quot;Aplicativo Random no Google Play.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/8059236452377112014/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://ocodigofonte.blogspot.com/2015/07/random.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/8059236452377112014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/8059236452377112014'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/2015/07/random.html' title='Aplicativo Random no Google Play'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8337375805238385969.post-3416974351584465939</id><published>2015-01-03T14:05:00.003-02:00</published><updated>2015-01-03T14:11:15.522-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel"/><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><title type='text'>Como executar uma macro do VBA ao ativar um planilha no Excel</title><content type='html'>O &lt;a href=&quot;http://ocodigofonte.blogspot.com.br/search/label/VBA&quot;&gt;VBA&lt;/a&gt; nos dá a possibilidade de executarmos alguma ação/macro quando ocorrem alguns eventos em uma planilha&amp;nbsp;do Excel, dentre esses eventos temos o:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Activate&lt;/b&gt; - ocorre quando uma planilha é ativada;&lt;br /&gt;
&lt;b&gt;Deactivate&lt;/b&gt; - ocorre quando uma planilha é desativada;&lt;br /&gt;
&lt;b&gt;Change&lt;/b&gt; - ocorre quando é feita alguma alteração na planilha;&lt;br /&gt;
&lt;br /&gt;
Nessa postagem irei demostrar como utilizar o evento&amp;nbsp;&lt;b&gt;Activate&lt;/b&gt;. Para começarmos devemos abrir o&amp;nbsp;&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/search/label/VBA&quot;&gt;VBA&lt;/a&gt;&amp;nbsp;(pressionando ALT + F11)&amp;nbsp;e exibir o código da planilha que queremos trabalhar, como mostra a imagem abaixo.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/2015/01/executar-macro-vba-ao-ativar-planilha-excel.html&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;executar macro ativar planilha excel&quot; border=&quot;0&quot; src=&quot;https://sites.google.com/site/ocodigofonte/imagens/postagens/2015-01_macro-vba-excel_01.png&quot; title=&quot;Como executar uma macro do VBA ao ativar um planilha no Excel.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
Feito isso devemos escolher qual objeto (Geral) e qual evento (Declaração) será utilizado.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/2015/01/executar-macro-vba-ao-ativar-planilha-excel.html&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;executar macro ativar planilha excel&quot; border=&quot;0&quot; src=&quot;https://sites.google.com/site/ocodigofonte/imagens/postagens/2015-01_macro-vba-excel_02.png&quot; title=&quot;Como executar uma macro do VBA ao ativar um planilha no Excel.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Em Geral, escolhemos &lt;b&gt;Worksheet&lt;/b&gt; (quando você selecionar &lt;b&gt;Worksheet&lt;/b&gt;, automaticamente irá aparecer um código referente a um evento qualquer, você pode apagá-lo e ir para a seleção da Declaração), e em Declaração, escolhemos o evento, nesse caso &lt;b&gt;Activate&lt;/b&gt;, seu código deve ficar desse jeito:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:vb&quot;&gt;Private Sub Worksheet_Activate()

End Sub
&lt;/pre&gt;
&lt;br /&gt;
Dentro dessa &lt;b&gt;Sub&lt;/b&gt; podemos escrever nossa macro e sempre que a planilha for ativada ela será executada. Assim como é possível executar uma ação/macro para uma planilha específica, também é possível fazer isso para todas as planilhas, para isso temos que exibir o código da &lt;b&gt;EstaPasta_de_trabalho&lt;/b&gt;, em Geral, escolher &lt;b&gt;Workbook&lt;/b&gt;, e em Declaração, escolher &lt;b&gt;SheetActivate&lt;/b&gt;, ficando desse jeito.
&lt;br /&gt;
&lt;pre class=&quot;brush:vb&quot;&gt;Private Sub Workbook_SheetActivate(ByVal Sh As Object)

End Sub
&lt;/pre&gt;
&lt;br /&gt;
Para trabalhar com outro evento, realize o mesmo procedimento, porém ao invés de selecionar &lt;b&gt;Activate&lt;/b&gt; na Declaração, selecione o evento de seu interesse.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/2015/01/executar-macro-vba-ao-ativar-planilha-excel.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;executar macro ativar planilha excel&quot; border=&quot;0&quot; src=&quot;https://sites.google.com/site/ocodigofonte/imagens/01_download.png&quot; title=&quot;Como executar uma macro do VBA ao ativar um planilha no Excel.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/open?id=0B0kPGHZIKINoZjdvOGdyT2tSUkU&quot; target=&quot;_blank&quot;&gt;Google Docs&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/3416974351584465939/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://ocodigofonte.blogspot.com/2015/01/executar-macro-vba-ao-ativar-planilha-excel.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/3416974351584465939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/3416974351584465939'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/2015/01/executar-macro-vba-ao-ativar-planilha-excel.html' title='Como executar uma macro do VBA ao ativar um planilha no Excel'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8337375805238385969.post-3757030983239378682</id><published>2014-12-07T23:23:00.000-02:00</published><updated>2014-12-07T23:31:16.282-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="NPOI"/><title type='text'>Ler arquivos XLS e XLSX utilizando NPOI em C#</title><content type='html'>Uma maneira de ler arquivos XLS e XLSX utilizando &lt;a href=&quot;http://ocodigofonte.blogspot.com/search/label/C%23&quot;&gt;C#&lt;/a&gt; é através da biblioteca &lt;a href=&quot;http://ocodigofonte.blogspot.com/search/label/NPOI&quot;&gt;NPOI&lt;/a&gt;, ela nos permite ler esses tipos de arquivos sem a necessidade de termos o Microsoft Excel instalado, o que em alguns casos pode ocorrer. Para começar, devemos baixar os arquivos binários &lt;a href=&quot;https://npoi.codeplex.com/releases&quot;&gt;nesse link&lt;/a&gt; e depois adicioná-los as referências do nosso projeto, feito isso podemos começar.
&lt;br /&gt;
&lt;br /&gt;
A primeira coisa que devemos fazer é importar os namespaces que iremos utilizar, que são:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;using NPOI.SS.UserModel;
using NPOI.HSSF.UserModel; // para arquivos XLS
using NPOI.XSSF.UserModel; // para arquivos XLSX&lt;/pre&gt;
Existe uma diferença nas classes que são utilizadas em arquivos XLS e em arquivos XLSX, quando usamos arquivos XLS as classes que devemos utilizar começam com a letra &lt;b&gt;H&lt;/b&gt;, por exemplo: HSSFWorkbook, HSSFSheet, HSSFRow, HSSFCell, etc. Para arquivos arquivos XLSX as classes começam com a letra &lt;b&gt;X&lt;/b&gt;: XSSFWorkbook, XSSFSheet, XSSFRow, XSSFCell, etc. No exemplo que vou mostrar, irei ler um arquivo XLS e escrever seu conteúdo em um RichTextBox:&lt;br /&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre class=&quot;brush:c-sharp&quot;&gt;// utiliza um OpenFileDialog para selecionar o arquivo XLS
DialogResult resultado = ofdArquivos.ShowDialog();
// verifica se o usuário selecionou um arquivo
if (resultado == DialogResult.OK)
{
    // abre o arquivo para leitura
    FileStream arquivoXLS = new FileStream(ofdArquivos.FileName, FileMode.Open, FileAccess.Read);
    // recupera o Workbook do arquivo
    HSSFWorkbook workbook = new HSSFWorkbook(arquivoXLS);
    // recupera a Sheet de nome Plan1
    HSSFSheet sheet = (HSSFSheet)workbook.GetSheet(&quot;Plan1&quot;);

    // recupera as linhas da Sheet
    IEnumerator linhas = sheet.GetRowEnumerator();
    // enquanto existirem linhas
    while (linhas.MoveNext())
    {
        // recupera as células da linha atual
        IEnumerator celulas = ((HSSFRow)linhas.Current).Cells.GetEnumerator();
        // enquanto existirem células
        while (celulas.MoveNext())
        {
            // recupera a célula atual
            HSSFCell celula = ((HSSFCell)celulas.Current);
            // verifica o tipo de célula para ler seu conteúdo
            switch (celula.CellType)
            {
                case CellType.Blank:
                    // adiciona conteúdo no RichTextBox
                    rtbPlanilha.AppendText(&quot;\t&quot;);
                    break;
                case CellType.Boolean:
                    // adiciona conteúdo no RichTextBox
                    rtbPlanilha.AppendText(celula.BooleanCellValue + &quot;\t&quot;);
                    break;
                case CellType.Error:
                    // adiciona conteúdo no RichTextBox
                    rtbPlanilha.AppendText(celula.ErrorCellValue + &quot;\t&quot;);
                    break;
                case CellType.Formula:
                    // adiciona conteúdo no RichTextBox
                    rtbPlanilha.AppendText(celula.CellFormula + &quot;\t&quot;);
                    break;
                case CellType.Numeric:
                    // adiciona conteúdo no RichTextBox
                    rtbPlanilha.AppendText(celula.NumericCellValue + &quot;\t&quot;);
                    break;
                case CellType.String:
                    // adiciona conteúdo no RichTextBox
                    rtbPlanilha.AppendText(celula.StringCellValue + &quot;\t&quot;);
                    break;
            }
        }
        // quebra de linha
        rtbPlanilha.AppendText(&quot;\n&quot;);
    }

    // fecha o arquivo XLS
    arquivoXLS.Close();
}
else
{
    // exibe mensagem
    MessageBox.Show(&quot;Nenhum arquivo foi selecionado.&quot;, &quot;Aviso&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);
}&lt;/pre&gt;
Para fazer a mesma coisa, porém com arquivos XLSX, basta trocar o &lt;b&gt;H&lt;/b&gt; pelo &lt;b&gt;X&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com/2014/12/ler-arquivos-xls-xlsx-npoi-csharp.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;ler arquivos xls xlsx npoi csharp&quot; border=&quot;0&quot; src=&quot;http://sites.google.com/site/ocodigofonte/imagens/01_download.png&quot; title=&quot;Ler arquivos XLS e XLSX utilizando NPOI em C#.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://drive.google.com/file/d/0B0kPGHZIKINoZHY1OG9lNlFyeHM/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;Google Docs&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/3757030983239378682/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://ocodigofonte.blogspot.com/2014/12/ler-arquivos-xls-xlsx-npoi-csharp.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/3757030983239378682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/3757030983239378682'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/2014/12/ler-arquivos-xls-xlsx-npoi-csharp.html' title='Ler arquivos XLS e XLSX utilizando NPOI em C#'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8337375805238385969.post-5707429780753798349</id><published>2013-02-15T19:46:00.002-02:00</published><updated>2021-11-23T00:05:31.469-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel"/><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><title type='text'>Remover senha de proteção de uma Planilha do Excel</title><content type='html'>Para remover a senha da planilha, basta executar o seguinte procedimento no &lt;a href=&quot;http://ocodigofonte.blogspot.com.br/search/label/VBA&quot;&gt;VBA&lt;/a&gt;:&lt;br /&gt;
&lt;pre class=&quot;brush:vb&quot;&gt;Sub DesprotegerPlanilhaAtiva()
    Dim i, i1, i2, i3, i4, i5, i6 As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer
    On Error Resume Next
    For i = 65 To 66
        For j = 65 To 66
            For k = 65 To 66
                For l = 65 To 66
                    For m = 65 To 66
                        For i1 = 65 To 66
                            For i2 = 65 To 66
                                For i3 = 65 To 66
                                    For i4 = 65 To 66
                                        For i5 = 65 To 66
                                            For i6 = 65 To 66
                                                For n = 32 To 126
                                                    ActiveSheet.Unprotect (Chr(i) &amp;amp; Chr(j) &amp;amp; Chr(k) &amp;amp; Chr(l) &amp;amp; Chr(m) &amp;amp; Chr(i1) &amp;amp; Chr(i2) &amp;amp; Chr(i3) &amp;amp; Chr(i4) &amp;amp; Chr(i5) &amp;amp; Chr(i6) &amp;amp; Chr(n))
                                                    If ActiveSheet.ProtectContents = False Then
                                                        MsgBox &quot;Planilha desprotegida com sucesso!&quot;, vbInformation + vbOKOnly, &quot;Informação&quot;
                                                        Exit Sub
                                                    End If
                                                Next
                                            Next
                                        Next
                                    Next
                                Next
                            Next
                        Next
                    Next
                Next
            Next
        Next
    Next
End Sub
&lt;/pre&gt;
&lt;br /&gt;
Após alguns segundos a senha é removida.&lt;br /&gt;
&lt;br /&gt;
Para aqueles que não estão muito familiarizados com o &lt;a href=&quot;http://ocodigofonte.blogspot.com.br/search/label/VBA&quot;&gt;VBA&lt;/a&gt;, criei um suplemento que contém a macro para remover a senha, basta abrir o arquivo que contém a planilha protegida e depois abrir o arquivo &lt;b&gt;DesprotegerPlanilhaAtiva.xla&lt;/b&gt;, se aparecer alguma mensagem de segurança, clique em &quot;Habilitar Macros&quot;, depois pressione ALT + F8, digite DesprotegerPlanilhaAtiva e clique em Executar.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;Download&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;https://docs.google.com/file/d/0B0kPGHZIKINoTVNjS1JaLUFxblU/edit?usp=sharing&quot; target=&quot;_blank&quot;&gt;Google Docs&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;Vídeo&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;https://youtu.be/NJ_RTC_jL1o&quot; target=&quot;_blank&quot;&gt;YouTube&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;Origem&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;http://ontraining.com.br/2012/03/05/microsoft-excel-vba-como-retirar-senha-de-protecao-de-planilha/&quot; target=&quot;_blank&quot;&gt;http://ontraining.com.br/2012/03/05/microsoft-excel-vba-como-retirar-senha-de-protecao-de-planilha/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/5707429780753798349/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://ocodigofonte.blogspot.com/2013/02/remover-senha-planilha-excel-vba.html#comment-form' title='11 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/5707429780753798349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/5707429780753798349'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/2013/02/remover-senha-planilha-excel-vba.html' title='Remover senha de proteção de uma Planilha do Excel'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8337375805238385969.post-2233961075069175064</id><published>2012-04-29T11:06:00.000-03:00</published><updated>2014-11-30T10:20:43.651-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Delphi"/><title type='text'>Obter o Handle sobre o cursor do Mouse</title><content type='html'>Para obter o Handle sobre o cursor do Mouse utilizando &lt;a href=&quot;http://ocodigofonte.blogspot.com.br/search/label/Delphi&quot; target=&quot;_blank&quot;&gt;Delphi&lt;/a&gt;, iremos utilizar um Timer, três Edits e as seguintes funções:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;GetCursorPos&lt;/b&gt; - Obtém a posição do Mouse;&lt;br /&gt;
&lt;b&gt;WindowFromPoint&lt;/b&gt; - Retorna o Handle de acordo com a posição informada;&lt;br /&gt;
&lt;b&gt;GetWindowText&lt;/b&gt; - Obtém o Texto referente ao Handle;&lt;br /&gt;
&lt;b&gt;GetClassName&lt;/b&gt; - Obtém a Classe referente ao Handle;&lt;br /&gt;
&lt;br /&gt;
O evento OnTimer do Timer ficará assim:
&lt;br /&gt;
&lt;pre class=&quot;brush:delphi&quot;&gt;procedure TfrmMain.tHandleTimer(Sender: TObject);
var
  Handle : Longint;
  Posicao : TPoint;
  Texto, Classe: array [0..255] of char;
begin
  GetCursorPos(Posicao);
  Handle := WindowFromPoint(Posicao);
  GetWindowText(Handle, Texto, SizeOf(Texto));
  GetClassName(Handle, Classe, SizeOf(Classe));
  edtHandle.Text := IntToStr(Handle); //TEdit
  edtTexto.Text := Texto; //TEdit
  edtClasse.Text := Classe; //TEdit
end;
&lt;/pre&gt;
Simples não?&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com/2012/04/handle-sobre-cursor-mouse-delphi.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;handle sobre cursor mouse delphi&quot; border=&quot;0&quot; src=&quot;http://sites.google.com/site/ocodigofonte/imagens/01_download.png&quot; title=&quot;Obter o Handle sobre o cursor do Mouse.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://docs.google.com/open?id=0B0kPGHZIKINoc0VORlU4S20ySkU&quot; target=&quot;_blank&quot;&gt;Google Docs&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/2233961075069175064/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://ocodigofonte.blogspot.com/2012/04/handle-sobre-cursor-mouse-delphi.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/2233961075069175064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/2233961075069175064'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/2012/04/handle-sobre-cursor-mouse-delphi.html' title='Obter o Handle sobre o cursor do Mouse'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8337375805238385969.post-6339930869350471784</id><published>2012-03-17T23:17:00.001-03:00</published><updated>2013-08-18T21:48:42.708-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Delphi"/><title type='text'>Como criar um Teclado Virtual utilizando Delphi</title><content type='html'>Basicamente, o que você observa em um teclado virtual quando o utiliza?&lt;br /&gt;
- sempre fica sobre as janelas e programas abertos.&lt;br /&gt;
- não recebe o foco ao clicar nas teclas.&lt;br /&gt;
- envia teclas para o objeto ativo.&lt;br /&gt;
&lt;br /&gt;
Sabendo disso, para criar um teclado virtual em &lt;a href=&quot;http://ocodigofonte.blogspot.com.br/search/label/Delphi&quot; target=&quot;_blank&quot;&gt;Delphi&lt;/a&gt;, vamos precisar fazer o seguinte:&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;1º Definir a propriedade &lt;b&gt;FormStyle&lt;/b&gt; do Form para &lt;b&gt;fsStayOnTop&lt;/b&gt;.&lt;br /&gt;
2º Incluir o código abaixo no projeto.&lt;br /&gt;
&lt;pre class=&quot;brush:delphi&quot;&gt;private
  { Private declarations }
protected
  { Protected declarations }
  procedure CreateParams(var Params: TCreateParams); override;
public
  { Public declarations }
end;

//alterar TForm1 para o nome do seu formulário
procedure TForm1.CreateParams(var Params: TCreateParams);
const
  WS_EX_NOACTIVATE = $8000000;
begin
  inherited;
  Params.ExStyle := Params.ExStyle + WS_EX_NOACTIVATE;
end;
&lt;/pre&gt;
3º Utilizar o comando keybd_event, conforme os exemplos:
&lt;br /&gt;
&lt;pre class=&quot;brush:delphi&quot;&gt;//teclas normais
keybd_event(Ord(&#39;A&#39;), 0, 0, 0); //pressiona tecla [A]
keybd_event(Ord(&#39;A&#39;), 0, KEYEVENTF_KEYUP, 0); //libera tecla [A]
//ou
keybd_event(65, 0, 0, 0); //pressiona tecla [A]
keybd_event(65, 0, KEYEVENTF_KEYUP, 0); //libera tecla [A]

//teclas especiais
keybd_event(VK_BACK, 0, KEYEVENTF_EXTENDEDKEY or 0, 0); //pressiona Backspace
keybd_event(VK_BACK, 0, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0); //libera Backspace

//simular letra maiúscula
keybd_event(VK_LSHIFT, 0, KEYEVENTF_EXTENDEDKEY or 0, 0); //pressiona Shift esquerdo
keybd_event(65, 0, 0, 0); //pressiona tecla [A]
keybd_event(65, 0, KEYEVENTF_KEYUP, 0); //libera tecla [A]
keybd_event(VK_LSHIFT, 0, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0); //libera Shift esquerdo

//simular acento agudo
keybd_event(219, 0, 0, 0); //pressiona acento agudo
keybd_event(219, 0, KEYEVENTF_KEYUP, 0); //libera acento agudo
keybd_event(65, 0, 0, 0); //pressiona tecla [A]
keybd_event(65, 0, KEYEVENTF_KEYUP, 0); //libera tecla [A]
&lt;/pre&gt;
Com isso você já consegui criar seu próprio teclado virtual.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/2012/03/teclado-virtual-delphi-keyboard.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;teclado virtual delphi keyboard&quot; border=&quot;0&quot; src=&quot;https://sites.google.com/site/ocodigofonte/imagens/01_download.png&quot; title=&quot;Como criar um Teclado Virtual utilizando Delphi.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://docs.google.com/open?id=0B0kPGHZIKINoSXktVGV3NUdTWjJ2ZVh4dDhadXEwZw&quot; target=&quot;_blank&quot;&gt;Google Docs&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/2012/03/teclado-virtual-delphi-keyboard.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;teclado virtual delphi keyboard&quot; border=&quot;0&quot; src=&quot;http://sites.google.com/site/ocodigofonte/imagens/03_atencao.png&quot; title=&quot;Como criar um Teclado Virtual utilizando Delphi.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Não se esqueça de liberar uma tecla após pressioná-la.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/2012/03/teclado-virtual-delphi-keyboard.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;teclado virtual delphi keyboard&quot; border=&quot;0&quot; src=&quot;http://sites.google.com/site/ocodigofonte/imagens/06_mais_informacoes.png&quot; title=&quot;Como criar um Teclado Virtual utilizando Delphi.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pt.wikipedia.org/wiki/ASCII#Caracteres_imprim.C3.ADveis&quot; target=&quot;_blank&quot;&gt;Tabela ASCII&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://delphi.about.com/od/objectpascalide/l/blvkc.htm&quot; target=&quot;_blank&quot;&gt;Tabela Virtual Key&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://ocodigofonte.blogspot.com.br/2012/03/teclado-virtual-delphi-keyboard.html&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;teclado virtual delphi keyboard&quot; border=&quot;0&quot; src=&quot;http://sites.google.com/site/ocodigofonte/imagens/07_origem.png&quot; title=&quot;Como criar um Teclado Virtual utilizando Delphi.&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.devmedia.com.br/forum/viewtopic.asp?id=367715&quot; target=&quot;_blank&quot;&gt;http://www.devmedia.com.br/forum/viewtopic.asp?id=367715&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/6339930869350471784/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://ocodigofonte.blogspot.com/2012/03/teclado-virtual-delphi-keyboard.html#comment-form' title='6 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/6339930869350471784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/6339930869350471784'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/2012/03/teclado-virtual-delphi-keyboard.html' title='Como criar um Teclado Virtual utilizando Delphi'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8337375805238385969.post-4684852201948044292</id><published>2012-02-26T14:41:00.001-03:00</published><updated>2012-03-18T00:11:09.656-03:00</updated><title type='text'>Iniciando</title><content type='html'>Muitas vezes precisamos de alguma ajuda com os nossos códigos e passamos horas tentando encontrar uma solução, o meu objetivo é disponibilizar o máximo de informações possíveis para agilizar esse processo, que muitas vezes chega a ser muito cansativo.&lt;br /&gt;
&lt;br /&gt;
Tenho conhecimentos em Delphi, Java, Java/Android, Visual Basic/VB, VB.Net e&amp;nbsp;Visual Basic for Applications/VBA, não sou nenhum expert, mas &quot;quebro o galho&quot;.&lt;br /&gt;
&lt;br /&gt;
Pretendo disponibilizar o código fonte através das postagens e em arquivos para download.&lt;br /&gt;
&lt;br /&gt;
Todo código fonte que for postado, irá conter a fonte de onde foi retirado/adaptado/pesquisado, com exceção dos códigos que eu mesmo desenvolver.&lt;br /&gt;
&lt;br /&gt;
Os ícones utilizados nas postagens são encontrados no site &lt;a href=&quot;http://www.fatcow.com/free-icons&quot;&gt;http://www.fatcow.com/free-icons&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Espero poder ajudar muitas pessoas.&lt;br /&gt;
&lt;br /&gt;
Abraços.</content><link rel='replies' type='application/atom+xml' href='http://ocodigofonte.blogspot.com/feeds/4684852201948044292/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://ocodigofonte.blogspot.com/2012/02/iniciando.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/4684852201948044292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8337375805238385969/posts/default/4684852201948044292'/><link rel='alternate' type='text/html' href='http://ocodigofonte.blogspot.com/2012/02/iniciando.html' title='Iniciando'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>