Autor Tema: Cómo modificar el código?  (Leído 4496 veces)

0 Usuarios y 1 Visitante están viendo este tema.

vbgedo

  • Bytes
  • *
  • Mensajes: 10
  • Reputación: +0/-0
    • Ver Perfil
Cómo modificar el código?
« en: Julio 14, 2014, 08:29:10 pm »
Hola Encontré este código a través de este tema

http://leandroascierto.com/foro/index.php?topic=2298.0

Código: [Seleccionar]
Option Explicit
Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateDIBSection Lib "gdi32.dll" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByRef lplpVoid As Any, ByVal handle As Long, ByVal dw As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function UpdateLayeredWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal hdcDst As Long, pptDst As Any, psize As Any, ByVal hdcSrc As Long, pptSrc As Any, ByVal crKey As Long, ByRef pblend As BLENDFUNCTION, ByVal dwFlags As Long) As Long
Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As Long, graphics As Long) As Long
Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
Private Declare Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As Long, ByVal image As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single) As Long
Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As String, image As Long) As Long
Private Declare Function GdipGetImageWidth Lib "gdiplus" (ByVal image As Long, Width As Long) As Long
Private Declare Function GdipGetImageHeight Lib "gdiplus" (ByVal image As Long, Height As Long) As Long
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal image As Long) As Long
Private Declare Function GdiplusStartup Lib "gdiplus" (gToken As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
Private Declare Sub GdiplusShutdown Lib "gdiplus" (ByVal gToken As Long)
 
Private Type BLENDFUNCTION
    BlendOp As Byte
    BlendFlags As Byte
    SourceConstantAlpha As Byte
    AlphaFormat As Byte
End Type
 
Private Type Size
    cx As Long
    cy As Long
End Type
 
Private Type POINTAPI
    x As Long
    y As Long
End Type
 
Private Type BITMAPINFOHEADER
    biSize As Long
    biWidth As Long
    biHeight As Long
    biPlanes As Integer
    biBitCount As Integer
    biCompression As Long
    biSizeImage As Long
    biXPelsPerMeter As  Long
    biYPelsPerMeter As  Long
    biClrUsed As Long
    biClrImportant As Long
End Type
 
Private Type BITMAPINFO
    bmiHeader As BITMAPINFOHEADER
    bmiColors() As Long
End Type
 
Private Type GdiplusStartupInput
   GdiplusVersion As Long
   DebugEventCallback As Long
   SuppressBackgroundThread As Long
   SuppressExternalCodecs As Long
End Type
 
Private Const ULW_ALPHA         As Long = &H2
Private Const DIB_RGB_COLORS     As  Long = 0
Private Const AC_SRC_ALPHA      As Long = &H1
Private Const AC_SRC_OVER       As Long = &H0
Private Const WS_EX_LAYERED     As Long = &H80000
Private Const GWL_EXSTYLE       As Long = -20
Private Const HWND_TOPMOST      As Long = -1
Private Const SWP_NOMOVE        As Long = &H2
Public Const HTCAPTION         As Long = 2
Public Const WM_NCLBUTTONDOWN  As Long = &HA1
 
Public Function SplashForm(Frm As Form, sImgPath As String) As Boolean
    Dim GpInput     As GdiplusStartupInput
    Dim BI           As BITMAPINFO
    Dim hImage      As Long
    Dim hGraphics   As Long
    Dim SZ           Ace Size
    Dim PT          As POINTAPI
    Dim mDC         As Long
    Dim hBitmap     As Long
    Dim BF          As BLENDFUNCTION
    Dim gToken      As Long
    Dim OldhBitmap   As  Long
 
    GpInput.GdiplusVersion = 1
   
    If GdiplusStartup(gToken, GpInput) = 0 Then
       
        If GdipLoadImageFromFile(StrConv(sImgPath, vbUnicode), hImage) = 0 Then
       
            Call GdipGetImageWidth(hImage, SZ.cx)
            Call GdipGetImageHeight(hImage, SZ.cy)
           
            mDC = CreateCompatibleDC(Frm.hdc)
            With BI.bmiHeader
               .biSize = Len(BI.bmiHeader)
               .biBitCount = 32
               .biWidth = SZ.cx
               .biHeight = SZ.cy
               .biPlanes = 1
               .biSizeImage = .biWidth * .biHeight * (.biBitCount / 8)
            End With
           
            hBitmap = CreateDIBSection(mDC, BI, DIB_RGB_COLORS, ByVal 0, 0, 0)
            OldhBitmap = SelectObject(mDC, hBitmap)
           
            Call GdipCreateFromHDC(mDC, hGraphics)
            Call GdipDrawImageRect(hGraphics, hImage, 0, 0, SZ.cx, SZ.cy)
            Call GdipDisposeImage(hImage)
            Call GdipDeleteGraphics(hGraphics)
            Call GdiplusShutdown(gToken)
        Else
            Call GdiplusShutdown(gToken)
            MsgBox "Error reading image" , vbCritical
            Exit Function
        End  If
    Else
         MsgBox "Failed to start GDI +" , vbCritical
         Exit Function
    End  If
 
    SetWindowLong Frm.hwnd, GWL_EXSTYLE, GetWindowLong(Frm.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
    SetWindowPos Frm.hwnd, HWND_TOPMOST, 0, 0, SZ.cx, SZ.cy, SWP_NOMOVE
 
    With BF
       .AlphaFormat = AC_SRC_ALPHA
       .BlendOp = AC_SRC_OVER
       .SourceConstantAlpha = 255
    End With
 
    SplashForm = UpdateLayeredWindow(Frm.hwnd, Frm.hdc, ByVal 0&, SZ, mDC, PT, 0, BF, ULW_ALPHA)
 
    DeleteObject SelectObject (MDC OldhBitmap)
    DeleteDC mDC
End Function


Código: [Seleccionar]
Option Explicit
 
Private Sub Form_Load()
    Call SplashForm(Me, "C:\Users\Windows\Desktop\FormTransp\aaa.png")
End Sub
 
Private Sub Form_DblClick()
    Unload Me
End Sub
 
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Call ReleaseCapture
    SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub


Quiero poner las herramientas en forma hay una manera o una solución para eso

A la espera de ayuda

Gracias a todos
« última modificación: Julio 14, 2014, 08:33:14 pm por vbgedo »

coco

  • Administrador
  • Terabyte
  • *****
  • Mensajes: 548
  • Reputación: +63/-3
    • Ver Perfil
Re:Cómo modificar el código?
« Respuesta #1 en: Julio 16, 2014, 07:03:05 pm »
No entiendo, que significa "quiero poner las herramientas"?
'-     coco
(No me cabe: Java, Python ni Pascal)
SQLite - PIC 16F y 18F - ARM STM32 - ESP32 - Linux Embebido - VB6 - Electronica - Sonido y Ambientacion

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:Cómo modificar el código?
« Respuesta #2 en: Julio 17, 2014, 09:33:53 am »
Me parece que uso un traductor, y se refiere a poner controles sobre el formulario, y bueno la respuesta mas corta es no  :D

vbgedo

  • Bytes
  • *
  • Mensajes: 10
  • Reputación: +0/-0
    • Ver Perfil
Re:Cómo modificar el código?
« Respuesta #3 en: Julio 17, 2014, 10:47:13 pm »
No entiendo, que significa "quiero poner las herramientas"?

i need to add tools on form

vbgedo

  • Bytes
  • *
  • Mensajes: 10
  • Reputación: +0/-0
    • Ver Perfil
Re:Cómo modificar el código?
« Respuesta #4 en: Julio 17, 2014, 10:48:55 pm »
Me parece que uso un traductor, y se refiere a poner controles sobre el formulario, y bueno la respuesta mas corta es no  :D

This is exactly that I want but why no ?

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:Cómo modificar el código?
« Respuesta #5 en: Julio 18, 2014, 02:56:06 pm »
hello, give an explanation of why not in English is complicated for me, you can put controls, but these are not rendered, there are some methods, which is to put another container window on same.

if you are interested in deepening the topic see the following suite of classes cWidget.cls 

http://leandroascierto.com/blog/estado-del-tiempo/


vbgedo

  • Bytes
  • *
  • Mensajes: 10
  • Reputación: +0/-0
    • Ver Perfil
Re:Cómo modificar el código?
« Respuesta #6 en: Julio 21, 2014, 01:05:21 am »
hello, give an explanation of why not in English is complicated for me, you can put controls, but these are not rendered, there are some methods, which is to put another container window on same.

if you are interested in deepening the topic see the following suite of classes cWidget.cls 

http://leandroascierto.com/blog/estado-del-tiempo/


Thank you for help

but I don't understand this example

If there is another solution please help me

Wait for Help