Das Ganze scheint unter Windows 10 echt knifflig zu sein.
Mehr als einen Rahmen um die Icons bekomme ich bisher nicht hin:
Code: Alles auswählen
Procedure DrawTransparentImage(DC, Bitmap, x, y, Width, Height, TransparentColor)
; First, create some DC's. These are our gateways To associated
; bitmaps in RAM
maskDC = CreateCompatibleDC_(DC)
tempDC = CreateCompatibleDC_(DC)
SourceDC = CreateCompatibleDC_(DC)
SelectObject_(SourceDC, Bitmap)
; Then, we need the bitmaps. Note that we create a monochrome
; bitmap here!
; This is a trick we use For creating a mask fast enough.
hMaskBmp = CreateBitmap_(Width, Height, 1, 1, 0)
hTempBmp = CreateCompatibleBitmap_(DC, Width, Height)
; Then we can assign the bitmaps to the DCs
;
hMaskBmp = SelectObject_(maskDC, hMaskBmp)
hTempBmp = SelectObject_(tempDC, hTempBmp)
; Now we can create a mask. First, we set the background color
; To the transparent color; then we copy the image into the
; monochrome bitmap.
; When we are done, we reset the background color of the
; original source.
TransparentColor= SetBkColor_(SourceDC, TransparentColor)
BitBlt_ (maskDC, 0, 0, Width, Height, SourceDC, 0, 0, #SRCCOPY)
SetBkColor_(SourceDC, TransparentColor)
; The first we do with the mask is To MergePaint it into the
; destination.
; This will punch a WHITE hole in the background exactly were
; we want the graphics To be painted in.
BitBlt_ (tempDC, 0, 0, Width, Height, maskDC, 0, 0, #SRCCOPY)
BitBlt_ (DC, x, y, Width, Height, tempDC, 0, 0, #MERGEPAINT)
; Now we delete the transparent part of our source image. To do
; this, we must invert the mask And MergePaint it into the
; source image. The transparent area will now appear as WHITE.
BitBlt_ (maskDC, 0, 0, Width, Height, maskDC, 0, 0, #NOTSRCCOPY)
BitBlt_ (tempDC, 0, 0, Width, Height, SourceDC, 0, 0, #SRCCOPY)
BitBlt_ (tempDC, 0, 0, Width, Height, maskDC, 0, 0, #MERGEPAINT)
; Both target And source are clean. All we have To do is To And
; them together!
BitBlt_ (DC, x, y, Width, Height, tempDC, 0, 0, #SRCAND)
; Now all we have To do is To clean up after us And free system
; resources..
DeleteObject_ (hMaskBmp)
DeleteObject_ (hTempBmp)
DeleteDC_ (maskDC)
DeleteDC_ (tempDC)
DeleteDC_ (SourceDC)
EndProcedure
Procedure.i GetDesktopHwnd() ;Modifiziert
Protected hshell.i
Protected hview.i
Protected hworker.i
Protected hsys.i
hshell = GetShellWindow_()
If hshell
SendMessage_(hshell,$052C,$D,#False)
SendMessage_(hshell,$052C,$D,#True)
hshell = GetDesktopWindow_()
Repeat
hworker = FindWindowEx_(hshell,hworker,@"WorkerW",#Null) ;Unicode-Pointer (LPCSTR)
If hworker
hview = FindWindowEx_(hworker,#Null,@"SHELLDLL_DefView",#Null)
If hview
Debug "hier"
hsys = FindWindowEx_(hview,#Null,@"SysListView32", @"FolderView")
ProcedureReturn hsys
;If hsys
; ProcedureReturn FindWindowEx_(hsys,#Null,@"SysHeader32",#Null)
;EndIf
EndIf
EndIf
Until hworker = #Null
EndIf
ProcedureReturn #Null
EndProcedure
ExamineDesktops()
Global Frame.rect
Frame\bottom = DesktopHeight(0) * DesktopResolutionY()
Frame\left = 10 ;?
Frame\right = DesktopWidth(0) * DesktopResolutionX()
Frame\top = 10 ;?
Global.i hdc, hw
hw = GetDesktopHwnd()
Debug hw
hdc = GetDCEx_(hw, #Null, $403)
Debug hdc
If CreateImage(0, Frame\right, Frame\bottom, 32)
StartDrawing(ImageOutput(0))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(255,0,0))
StopDrawing()
EndIf
;InvalidateRect_(hdc, @Frame, #True)
DrawTransparentImage(hdc, ImageID(0), 0, 0, ImageWidth(0), ImageHeight(0), RGB(0,0,0))
RedrawWindow_( hw, @Frame, 0, #RDW_NOERASE | #RDW_INVALIDATE | #RDW_UPDATENOW | #RDW_NOCHILDREN)
;RedrawWindow_( GetShellWindow_(), @Frame, #Null, #RDW_ERASE | #RDW_UPDATENOW )
Ich bin mir noch nicht so ganz sicher wohin hier ein weiter experimentieren führt:
Code: Alles auswählen
If CreateImage(0, Frame\right, Frame\bottom, 32, #PB_Image_Transparent)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels) ;?
Box(0, 0, OutputWidth(), OutputHeight(), RGB(255,0,0))
StopDrawing()
EndIf
DrawTransparentImage(hdc, ImageID(0), 0, 0, ImageWidth(0), ImageHeight(0), RGB(0,0,0))
SetClassLongPtr_(hwnd, -10, CreateSolidBrush_(RGB(255, 0, 0))) ;-10 = SetWindowColor()
;InvalidateRect_(hdc, @Frame, #True)
;SetWindowLongPtr_(hw, #GWL_EXSTYLE, GetWindowLongPtr_(hw, #GWL_EXSTYLE) | #WS_EX_LAYERED)
SetLayeredWindowAttributes_(hw, RGB(255, 0, 0), 0, #LWA_COLORKEY)
;SetLayeredWindowAttributes_(hw, RGB(255, 255, 255), 255, #LWA_ALPHA)
RedrawWindow_( hw, @Frame, 0, #RDW_NOERASE | #RDW_INVALIDATE | #RDW_UPDATENOW | #RDW_ALLCHILDREN)
Das hier ist geil! (Damit ist nicht der Hintergrund rot, sondern die Icons)
Code: Alles auswählen
Structure lvbkimage
ulflags.i
hbm.i
pszImage.i
cchImageMax.i
xOffsetPercent.i
yOffsetPercent.i
EndStructure
Global bild.lvbkimage
bild\ulflags = 1
bild\hbm = ImageID(0)
DrawTransparentImage(hdc, ImageID(0), 0, 0, ImageWidth(0), ImageHeight(0), RGB(0,0,0))
;SetClassLongPtr_(hwnd, -10, CreateSolidBrush_(RGB(255, 0, 0))) ;-10 = SetWindowColor()
;InvalidateRect_(hdc, @Frame, #True)
;SetWindowLongPtr_(hw, #GWL_STYLE, GetWindowLongPtr_(hw, #GWL_EXSTYLE) | #WS_EX_LAYERED)
;SetLayeredWindowAttributes_(hw, RGB(255, 0, 0), 0, #LWA_COLORKEY)
;SetLayeredWindowAttributes_(hw, RGB(255, 255, 255), 255, #LWA_ALPHA)
SendMessage_(hw,#LVM_SETBKIMAGE,0, bild) ;ListViewImage
RedrawWindow_( hw, @Frame, 0, #RDW_NOERASE | #RDW_VALIDATE | #RDW_UPDATENOW | #RDW_ALLCHILDREN)
Betriebssysteme: div. Windows, Linux, Unix - Systeme
no Keyboard, press any key
no mouse, you need a cat