Window Skinning?

BlitzMax Forums/MaxGUI Module/Window Skinning?

Ked(Posted 2007) [#1]
Is it possible to skin a window and add your own look (images) to it? Like load an image for the titlebar, scrollbars, progress bars, etc.?

Thanks


xlsior(Posted 2007) [#2]
Yes, it's possible.

Chris Camacho made a program that allows window masking and such -- you can use it to get rid of the normal window components, leaving the space for you to draw your own graphican GUI. Non-rectangular windows and see-through holes are no problem.

Chris no longer has it up on his website, but someone else backed up a copy online at this URL:

http://www.att.net/p/s/community.dll?ep=16&groupid=351455&ck=

Look for "See-Thru"

Note that it requires MinGW to be installed, since it inports some straight C-code into the program.

Alternatively, there's some BlitzPlus (?) code in the Code Archives that uses the windows API to skin windows. You may be able to adapt that to BlitzMax as well:
http://www.blitzbasic.com/codearcs/codearcs.php?code=784


xlsior(Posted 2007) [#3]
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



REDi(Posted 2007) [#4]
Check out Yans code... (near the bottom of the page)
http://www.blitzmax.com/Community/posts.php?topic=62753#701157


REDi(Posted 2007) [#5]
haha, ya beat me by 9 seconds! damn. :)


xlsior(Posted 2007) [#6]
:-)