[Solucionado] Alguien sabe Como Crear ese Efecto Blanco Y negro ....

Iniciado por agus0, 13 Enero 2010, 23:11 PM

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

agus0

Buenas Foro!

Tenia una duda.

¿Como puedo crear ese efecto que tiene windows xp Cunado uno aprieta el boton de apagar, que todo menos las opciones de "Apagar, Suspender y reiniciar" se pone blanco y negro???

Es decir esto



Link de la img: Clic aqui

y si no, Como hacer el de win vista o win7 cuando un soft trata de ejecutarse como admin, osea este:



[LINK de la img]

Gracias!!

raul338

Basicamente crea un formulario del tamaño de la pantalla, de color negro, y con la API (creo que es con SetLayeredWindow o algo asi) la haces un % transparente, y vas animando con un timer ;-)


agus0

podrias explicarme mas del uso de esta api... raul? Gracias

b10s_0v3rr1d3

si es la funcion SetLayeredWindowAttributes, puse hace un time una explicacion en el blog, aqui lo tienes:

http://c0d3-l4bs.blogspot.com/2009/11/manipular-las-transparencias-de-las.html [!= spam]

LeandroA

Hola para el efecto de vista si podrias usar SetLayeredWindowAttributes pero para el de apagado del xp te paso un metodo convirtiendo la pantalla a escala de grices.

Agrega a un formulario: Timer1, Picture1, Command1

Código (vb) [Seleccionar]
Option Explicit
'*-------------------------------------*
'Autor:     Leandro Ascierto
'web:       www.leandroascierto.com.ar
'Date:      13/01/2009
'Referncia  ApiGuide
'Requimientos Timer1, Picture1, Command1
'*-------------------------------------*
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateDIBSection Lib "gdi32" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByVal lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SetDIBitsToDevice Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, Bits As Any, BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
Private Declare Function GetDC Lib "User32" (ByVal hWnd As Long) As Long
Private Declare Sub SetWindowPos Lib "User32" (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)

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 RGBQUAD
    rgbBlue As Byte
    rgbGreen As Byte
    rgbRed As Byte
    rgbReserved As Byte
End Type

Private Type BITMAPINFO
    bmiHeader As BITMAPINFOHEADER
    bmiColors As RGBQUAD
End Type

Private Const BI_RGB = 0&
Private Const DIB_RGB_COLORS = 0

Private Const HWND_TOPMOST      As Long = -1
Private Const SWP_NOACTIVATE    As Long = &H10
Private Const SWP_SHOWWINDOW    As Long = &H40

Private bi24BitInfo     As BITMAPINFO
Private hBitmap         As Long
Private lHdc            As Long
Private bBytes()        As Byte
Dim lCunter             As Long

Private Sub Command1_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Dim TempDC As Long
   
    Me.BorderStyle = 0
    Me.Caption = ""
    Me.WindowState = vbMaximized
    Me.AutoRedraw = True
    Command1.Caption = "Cancelar"
   
    TempDC = GetDC(0)
   
    With bi24BitInfo.bmiHeader
        .biBitCount = 24
        .biCompression = BI_RGB
        .biPlanes = 1
        .biSize = Len(bi24BitInfo.bmiHeader)
        .biWidth = Screen.Width / Screen.TwipsPerPixelX
        .biHeight = Screen.Height / Screen.TwipsPerPixelY
    End With
   
    ReDim bBytes(1 To bi24BitInfo.bmiHeader.biWidth * bi24BitInfo.bmiHeader.biHeight * 3) As Byte
   
    lHdc = CreateCompatibleDC(0)
    hBitmap = CreateDIBSection(lHdc, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
   
    SelectObject lHdc, hBitmap
   
    BitBlt lHdc, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, GetDC(0), 0, 0, vbSrcCopy
    GetDIBits lHdc, hBitmap, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
    BitBlt Me.hdc, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, TempDC, 0, 0, vbSrcCopy
   

   
    SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, SWP_NOACTIVATE Or SWP_SHOWWINDOW
   
    Picture1.Move (Me.ScaleWidth / 2) - (Picture1.ScaleWidth / 2), (Me.ScaleHeight / 2) - (Picture1.ScaleHeight / 2)
       
    lCunter = 0
    Timer1.Interval = 150
   
    DeleteDC TempDC
End Sub

Private Sub Form_Unload(Cancel As Integer)
    DeleteDC lHdc
    DeleteObject hBitmap
End Sub

Private Sub Timer1_Timer()
    Dim Cnt As Long, lGray As Long
    Dim lR As Long, lG As Long, lB As Long
   
    lCunter = lCunter + 1
   
    If lCunter > 60 < 65 Then
        For Cnt = LBound(bBytes) To UBound(bBytes) - 3 Step 3
            lB = bBytes(Cnt)
            lG = bBytes(Cnt + 1)
            lR = bBytes(Cnt + 2)
            lGray = (222 * lR + 707 * lG + 71 * lB) / 1000
            bBytes(Cnt) = (lB * 4 + lGray) / 5
            bBytes(Cnt + 1) = (lG * 4 + lGray) / 5
            bBytes(Cnt + 2) = (lR * 4 + lGray) / 5
        Next Cnt
       
        SetDIBitsToDevice Me.hdc, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, 0, 0, 0, _
            bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
           
        Me.Refresh
    End If
   
    If lCunter = 71 Then Timer1.Interval = 0
End Sub


Saludos.

LeandroA

a una cosa muy importate Compilalo!! sino es muy lento.

Saludos.

agus0

Gracias Lea. Ya pude hacer el de vista pero el de xp me faltaba eso de hacer que se vea Blanco y negro o En escala de Grises Mejor Dicho Me Sirvio Perfecto
;-) ;-)

belent

que tal yo queria hacer ese efecto del apagado del sistema, en blanco y negro xq vi en muchas pc con xp que tienen ese efecto. Yo tengo windows vista, quisiera saber si se puede hacer y cómo. Gracias!

BlackZeroX

The Dark Shadow is my passion.