elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Api Google Char
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Api Google Char  (Leído 1,901 veces)
LeandroA
Moderador
***
Desconectado Desconectado

Mensajes: 760


www.leandroascierto.com


Ver Perfil WWW
Api Google Char
« en: 23 Julio 2008, 03:09 am »

Hola este es un ejemplo para pode utilizar el Api Google Char desde visual, bien esto puede ser utili en muy pocos caso, cuando tengamos conexion a internet y las consultas no sea muy frecuentes, asi que bien cada uno sabra si le puede dar utilidad.

Aca pueden encontrar toda la informacion de como utilizar esta api
http://code.google.com/apis/chart/


agregar Cuatro Botones, un Picture1,  y un HScroll1
Código:
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal HDC As Long, graphics As Long) As Long
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal image As Long) As Long
Private Declare Function GdipDrawImageRectRectI Lib "gdiplus" (ByVal graphics As Long, ByVal image As Long, ByVal dstx As Long, ByVal dsty As Long, ByVal dstwidth As Long, ByVal dstheight As Long, ByVal srcx As Long, ByVal srcy As Long, ByVal srcwidth As Long, ByVal srcheight As Long, ByVal srcUnit As Long, ByVal imageAttributes As Long, Optional ByVal callback As Long = 0, Optional ByVal callbackData As Long = 0) As Long
Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As String, ByRef image As Long) As Long
Private Declare Function GdiplusStartup Lib "gdiplus" (ByRef token As Long, inputbuf As Long, Optional ByVal outputbuf As Long = 0) As Long
Private Declare Sub GdiplusShutdown Lib "gdiplus" (ByVal token As Long)

Private Function RenderChar(ByVal HDC As Long, ByVal Param As String, ByVal X As Long, ByVal Y As Long, ByVal Width As Long, ByVal Height As Long) As Boolean
Dim hGraph As Long
Dim hImage As Long
Dim hGdiPlus As Long

If URLDownloadToFile(0, "http://chart.apis.google.com/chart?chs=" & Width & "x" & Height & "&" & Param, App.Path & "\Temp.png", 0, 0) = 0 Then

    GdiplusStartup hGdiPlus, 1
   
    If GdipCreateFromHDC(HDC, hGraph) = 0 Then

        If GdipLoadImageFromFile(StrConv(App.Path & "\Temp.png", vbUnicode), hImage) = 0 Then
       
            If GdipDrawImageRectRectI(hGraph, hImage, X, Y, Width, Height, 0, 0, Width, Height, &H2&, 0) = 0 Then
                RenderChar = True
            End If
           
        End If
       
        GdipDisposeImage hImage
       
    End If
   
    GdipDeleteGraphics hGraph
    GdiplusShutdown hGdiPlus
    Kill App.Path & "\Temp.png"
End If
End Function



Private Sub Command1_Click()
Dim Param As String
Param = "cht=p3&chd=t:80,40,30&chl=Sapallo|Lechuga|Tomate"
Debug.Print RenderChar(Picture1.HDC, Param, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight)
End Sub

Private Sub Command2_Click()
Dim Param As String
Param = "cht=bhs&chco=ff0000,00ff00,0000ff,&chd=s:FOE,THE,Bar&chxt=x,y&chxl=1:|Dec|Nov|Oct|0:||20K||60K||100K|"
Debug.Print RenderChar(Picture1.HDC, Param, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight)
End Sub

Private Sub Command3_Click()
Dim Param As String
Param = "cht=gom&chd=t:" & HScroll1.Value & "&chl=" & "Valor " & HScroll1.Value
Debug.Print RenderChar(Picture1.HDC, Param, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight)
End Sub

Private Sub Command4_Click()
Dim Param As String
Param = "cht=v&chd=t:100,80,60,30,30,30,10&chco=00ff00,0000ff"
Debug.Print RenderChar(Picture1.HDC, Param, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight)
End Sub

Private Sub Form_Load()
Picture1.ScaleMode = vbPixels
Picture1.Move 0, 0, 5500, 2500
HScroll1.Max = 100: HScroll1.Min = 1
End Sub

Saludos


En línea

seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: Api Google Char
« Respuesta #1 en: 23 Julio 2008, 03:25 am »

Hola, excelente Leandro  ;D,esto esta muy bueno,viste se pueden hacer un monton de cosas con estas api's onlines ya sea de google o de cualquier otro,tienen tantas opciones que no da para leerlo todo,por lo menos yo no podria es una perdida de tiempo bastante importante leer todo,pero ir haciendo miniaplicaciones de a poco asi mostrando funciones esta bien... :xD

saludos.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines