Avatar billede akexpert Nybegynder
18. november 2001 - 12:18 Der er 4 kommentarer og
1 løsning

Gennemsigtigt vindue

Er der nogen der ved hvordan man kan få en form til at blive gennemsigtig ligesom i WinAmp?
Avatar billede particle Nybegynder
18. november 2001 - 12:20 #1
Hvad mener du?

/particle
Avatar billede akexpert Nybegynder
18. november 2001 - 12:23 #2
du har vel WinAmp, ikk? Så hvis du vælger et skin til winamp, kan du få et skin som er gennemsigtigt, så du fx. både kan se skrivebordet, og winamp på én gang, fårstået?
Avatar billede sjh Nybegynder
19. november 2001 - 01:10 #3
\'--------------------------- Form1 ---------------------------
\'Set Form1.BorderStyle = 0
\'-------------------------------------------------------------
Option Explicit

Private Declare Function ReleaseCapture Lib \"user32\" () As Long
Private 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 SetWindowRgn Lib \"user32\" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib \"gdi32\" (ByVal hObject As Long) As Long
Private Declare Function CreateCompatibleDC Lib \"gdi32\" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib \"gdi32\" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function GetObject Lib \"gdi32\" Alias \"GetObjectA\" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function CreateRectRgn Lib \"gdi32\" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib \"gdi32\" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function DeleteDC Lib \"gdi32\" (ByVal hdc As Long) As Long
Private Declare Function GetPixel Lib \"gdi32\" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long

Private Type BITMAP
    bmType As Long
    bmWidth As Long
    bmHeight As Long
    bmWidthBytes As Long
    bmPlanes As Integer
    bmBitsPixel As Integer
    bmBits As Long
End Type

Private Function GetBitmapRegion(cPicture As StdPicture, cTransparent As Long) As Long
Dim hRgn As Long, tRgn As Long
Dim X As Integer, Y As Integer, X0 As Integer
Dim hdc As Long, BM As BITMAP

hdc = CreateCompatibleDC(0)
  If hdc Then
    SelectObject hdc, cPicture
    GetObject cPicture, Len(BM), BM
    hRgn = CreateRectRgn(0, 0, BM.bmWidth, BM.bmHeight)
    For Y = 0 To BM.bmHeight
      For X = 0 To BM.bmWidth
        While X <= BM.bmWidth And GetPixel(hdc, X, Y) <> cTransparent
          X = X + 1
            Wend
              X0 = X
            While X <= BM.bmWidth And GetPixel(hdc, X, Y) = cTransparent
          X = X + 1
        Wend
        If X0 < X Then
          tRgn = CreateRectRgn(X0, Y, X, Y + 1)
          CombineRgn hRgn, hRgn, tRgn, 4
          DeleteObject tRgn
        End If
      Next X
    Next Y
    GetBitmapRegion = hRgn
    DeleteObject SelectObject(hdc, cPicture)
  End If
DeleteDC hdc
End Function

Private Sub Form_Load()
Dim hRgn As Long
  Me.Picture = LoadPicture(\"C:\\WINDOWS\\Skrivebord\\test.bmp\") \'Load billede
  hRgn = GetBitmapRegion(Me.Picture, &HFF00FF) \'&HFF00FF< Transparent Farve
  SetWindowRgn Me.hwnd, hRgn, True
  DeleteObject hRgn
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = vbLeftButton Then
    \'--------- Move window ---------
    ReleaseCapture
    Call SendMessage(Me.hwnd, &HA1, 2, 0&)
    \'--------- Move window ---------
  End If
End Sub
\'--------------------------- Form1 ---------------------------
Avatar billede simon_jacobsen Nybegynder
19. november 2001 - 16:17 #4
nå du var lige smart at kopier det samme svar to gange > sjh :)
dobbelt point dobbelt glæde :D
Avatar billede akexpert Nybegynder
02. januar 2002 - 17:22 #5
Hmm...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester