Code archives/BlitzPlus Gui/transparent windows
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
I think there is not much to say, just sorry for my bad english, it is not my native language ;-) | |||||
;--------------------------------------------------------; ; Funktion made by Thorsten Ludwig (thorsten.ludwig1@gmx.de) ; ;--------------------------------------------------------; ; add this in the user32.decls ; ; .lib "User32.dll" ; SetWindowLong%(hWnd%, nIndex%, dwNewLong%):"SetWindowLongA" ; SetLayeredWindowAttributes%(hwnd, crKey, bAlpha, dwFlags):"SetLayeredWindowAttributes" ;--------------------------------------------------------------------------------------; timer = CreateTimer (50) window = CreateWindow("Test",0,0,600,400,Desktop(),0) panel = CreatePanel (0,0,gadgetwidth(window), GadgetHeight(window), window) example = CreateTextField (250,120,100,20,panel) skin_window(window,"test.bmp",panel, $FF00FF,100,3) Repeat Select WaitEvent() Case $101 Select EventData() Case 1 End End Select Case $4001 If MouseDown(1) Then If gedrueckt = 0 Then maus_X = MouseX() maus_Y = MouseY() fenster_X = GadgetX(window) fenster_Y = GadgetY(window) gedrueckt = 1 Else neues_maus_X = MouseX() neues_maus_Y = MouseY() differenz_X = maus_X - neues_maus_X differenz_Y = maus_Y - neues_maus_Y fenster_X = fenster_X - differenz_X fenster_Y = fenster_Y - differenz_Y maus_X = neues_maus_X maus_Y = neues_maus_Y SetGadgetShape (window, fenster_X, fenster_Y, 600,400) End If Else gedrueckt = 0 End If End Select Forever Function skin_window(window_handle, image_path$,panel,colorkey,alpha,colororalpha) ; colorkey is transparency color in hexadecimal form, black ist for example $FFFFFF ; alpha describes the opacity of the window, 0 for full translucent and 255 for non translucent ; use coloralpha to choose the mode you want to use ; 1 to set one color fully lucent ; 2 to set the level of the transperence of the whole window ; 3 to do both ; I think the rest ist self-explanatory If Not panel Then panel = CreatePanel (0,0,gadgetwidth (window_handle), GadgetHeight (window_handle), window_handle) End If SetPanelImage panel, image_path$ hwnd = QueryObject (window_handle, 1) SetWindowLong(hwnd, -20, $80000) SetLayeredWindowAttributes(hwnd, colorkey, alpha, colororalpha) End Function |
Comments
| ||
its work! great. thanks |
| ||
Please explain! This looks very nice, but I do not understand what each one of these lines do (individually):hwnd = QueryObject (window_handle, 1) SetWindowLong(hwnd, -20, $80000) SetLayeredWindowAttributes(hwnd, colorkey, alpha, colororalpha) Also, why do you recreate the panel in your function? I have been trying to do the same thing with a canvas instead of a panel (or, a canvas on such a panel), but it leaves junk of black boxes (the same size as the canvas) all over my screen (desktop) when I move the window, without clearing itself (even when the program exits). If that's not possible, please tell me so, and why it can work with a panel but not canvas. I've searched MSDN and the web for information on what those three lines mean and how I might edit it for BlitzPlus but have not found anything. E.g. what do the parameters -20 and $80000 mean? |
Code Archives Forum