Oh -- and after a little more digging I also found this one in straight BlitzMax, by Yan:
Strict
Const HTCAPTION = 2
Const RGN_XOR = 3
Extern "Win32"
Function SetWindowRgn(hWnd, hRgn, bRedraw)
Function CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect)
Function CombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, fnCombineMode)
End Extern
Local skinPmap:TPixmap = LoadPixmapPNG(LoadBank("http::homepage.ntlworld.com/mollymole/storage/skin.png"))
If skinPmap = Null Then RuntimeError "Oi...Where's me picture?"
Local window:TGadget = CreateWindow("", 100, 100, skinPmap.width, skinPmap.height, Null, WINDOW_HIDDEN)
SkinWindow(window, skinPmap)
ShowGadget(window)
Local canvas:TGadget = CreateCanvas(0, 0, ClientWidth(window), ClientHeight(window), window)
Local hWnd = QueryGadget(window, QUERY_HWND)
Repeat
Select WaitEvent()
Case EVENT_MOUSEDOWN
ReleaseCapture()
SendMessageA(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, Null)
Case EVENT_KEYDOWN
If CurrentEvent.data = 27 Then End
Case EVENT_GADGETPAINT
SetGraphics CanvasGraphics(canvas)
DrawPixmap skinPmap, 0, 0
Flip
End Select
Forever
End
Function SkinWindow(window:TGadget, skin:TPixmap)
Local rectRgn = CreateRectRgn(0, 0, GadgetWidth(window), GadgetHeight(window))
Local hWnd = QueryGadget(window, QUERY_HWND_CLIENT)
For Local pixY=0 Until skin.height
Local startFlag = 0
Local startX = 0
Local maskLine, pixX
For pixX=0 Until skin.width
Local argb = ReadPixel(skin, pixX, pixY)
If argb & $ff000000 = 0
If startFlag = 0
startFlag = 1
startX = pixX
EndIf
Else
If startFlag
startFlag = 0
maskLine = CreateRectRgn(startX, pixY, pixX, pixY + 1)
CombineRgn(rectrgn, rectrgn, maskLine, RGN_XOR)
DeleteObject(maskLine)
EndIf
EndIf
Next
If startFlag
maskLine = CreateRectRgn(startX, pixY, pixX, pixY + 1)
CombineRgn(rectrgn, rectrgn, maskLine, RGN_XOR)
DeleteObject(maskLine)
EndIf
Next
SetWindowRgn(hWnd, rectrgn, True)
End Function
|