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

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [SNIPPET-VB6] DrawGraph - Dibujar sobre controles.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [SNIPPET-VB6] DrawGraph - Dibujar sobre controles.  (Leído 1,470 veces)
F3B14N

Desconectado Desconectado

Mensajes: 47


Ver Perfil
[SNIPPET-VB6] DrawGraph - Dibujar sobre controles.
« en: 12 Marzo 2011, 14:48 pm »

Lo hice hace ya un tiempo para hacer poner imágenes en los commandbutton y que queden en la misma linea, pero se puede aplicar a cualquier control.

Código
  1. Option Explicit
  2.  
  3. Private Const WM_PAINT As Long = &HF
  4. Private Const GWL_WNDPROC = -4
  5.  
  6. Private Type DRAW_DATA
  7.    DrawPic As PictureBox
  8.    DrawTop As Long
  9.    DrawLeft As Long
  10.    lpPrevWndProc As Long
  11.    ControlHwnd As Long
  12.    ControlDC As Long
  13. End Type
  14.  
  15. Private Declare Function SetWindowLong Lib "USER32" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  16. Private Declare Function CallWindowProc Lib "USER32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal Hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  17. Private Declare Function GetDC Lib "USER32" (ByVal Hwnd As Long) As Long
  18. Private Declare Function GdiTransparentBlt Lib "GDI32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
  19.  
  20. Private DrawArray() As DRAW_DATA
  21.  
  22. Public Sub DrawGraph(Hwnd As Long, Pic As PictureBox, Top As Long, Left As Long)
  23.    Dim i As Long
  24.  
  25.    If Not Not DrawArray Then: i = UBound(DrawArray) + 1
  26.    ReDim Preserve DrawArray(i)
  27.  
  28.    With DrawArray(i)
  29.        Set .DrawPic = Pic
  30.        .DrawPic.BorderStyle = 0
  31.        .DrawPic.ScaleMode = vbPixels
  32.        .DrawPic.BackColor = &HFF00FF
  33.        .DrawPic.AutoSize = True
  34.        .DrawPic.Refresh
  35.  
  36.        .ControlHwnd = Hwnd
  37.        .lpPrevWndProc = SetWindowLong(Hwnd, GWL_WNDPROC, AddressOf ControlProc)
  38.        .ControlDC = GetDC(Hwnd)
  39.        .DrawTop = Top: .DrawLeft = Left
  40.    End With
  41. End Sub
  42.  
  43. Public Sub UnDrawGraph(ByVal Hwnd As Long)
  44.    Dim i As Long
  45.  
  46.    For i = 0 To UBound(DrawArray)
  47.        If DrawArray(i).ControlHwnd = Hwnd Then
  48.            Call SetWindowLong(Hwnd, GWL_WNDPROC, DrawArray(i).lpPrevWndProc)
  49.        End If
  50.    Next i
  51. End Sub
  52.  
  53. Private Function ControlProc(ByVal Hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  54.    Dim i As Long
  55.  
  56.    For i = 0 To UBound(DrawArray)
  57.        With DrawArray(i)
  58.            If .ControlHwnd = Hwnd Then
  59.                ControlProc = CallWindowProc(.lpPrevWndProc, Hwnd, Msg, wParam, lParam)
  60.                If (Msg = WM_PAINT) Then
  61.                    Call GdiTransparentBlt(.ControlDC, .DrawLeft, .DrawTop, .DrawPic.ScaleWidth, .DrawPic.ScaleHeight, .DrawPic.hdc, 0, 0, .DrawPic.ScaleWidth, .DrawPic.ScaleHeight, &HFF00FF)
  62.                End If
  63.            End If
  64.        End With
  65.    Next i
  66. End Function


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Una preguntilla sobre dibujar animaciones
Diseño Gráfico
Za3LoT 5 4,106 Último mensaje 15 Agosto 2006, 06:29 am
por juampivicius
Accion sobre un array de controles (labels)
Programación Visual Basic
Güan 6 1,701 Último mensaje 25 Diciembre 2006, 22:26 pm
por Güan
ShellElevated [snippet]
Programación Visual Basic
cobein 0 1,125 Último mensaje 15 Julio 2008, 12:37 pm
por cobein
[SNIPPET] GetTitleActiveApp (VB6) « 1 2 »
Programación Visual Basic
The Swash 10 5,328 Último mensaje 1 Abril 2010, 15:01 pm
por Karcrack
Dibujar texto sobre controles de formulario
.NET (C#, VB.NET, ASP)
.::IT::. 3 2,933 Último mensaje 19 Noviembre 2010, 04:03 am
por [D4N93R]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines