December 04, 2020, 11:17:24 AM

Author Topic: [bb] transparent windows by Hip Teen [ 1+ years ago ]  (Read 534 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] transparent windows by Hip Teen [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : transparent windows
Author : Hip Teen
Posted : 1+ years ago

Description : I think there is not much to say, just sorry for my bad english, it is not my native language ;-)

Code :
Code: BlitzBasic
  1. ;--------------------------------------------------------;
  2. ; Funktion made by Thorsten Ludwig (thorsten.ludwig1@gmx.de)  ;
  3. ;--------------------------------------------------------;
  4. ; add this in the user32.decls
  5. ;
  6. ; .lib "User32.dll"
  7. ; SetWindowLong%(hWnd%, nIndex%, dwNewLong%):"SetWindowLongA"  
  8. ; SetLayeredWindowAttributes%(hwnd, crKey, bAlpha, dwFlags):"SetLayeredWindowAttributes"
  9. ;--------------------------------------------------------------------------------------;
  10.  
  11.  
  12. timer = CreateTimer (50)
  13. window = CreateWindow("Test",0,0,600,400,Desktop(),0)
  14. panel = CreatePanel (0,0,gadgetwidth(window), GadgetHeight(window), window)
  15. example = CreateTextField (250,120,100,20,panel)
  16. skin_window(window,"test.bmp",panel, $FF00FF,100,3)
  17. Repeat
  18.   Select WaitEvent()
  19.   Case $101
  20.     Select EventData()
  21.     Case 1
  22.       End
  23.     End Select    
  24.         Case $4001
  25.     If MouseDown(1) Then
  26.      If gedrueckt = 0 Then
  27.        maus_X = MouseX()
  28.        maus_Y = MouseY()
  29.        fenster_X = GadgetX(window)
  30.        fenster_Y = GadgetY(window)
  31.        gedrueckt = 1
  32.      Else
  33.        neues_maus_X = MouseX()
  34.        neues_maus_Y = MouseY()
  35.        differenz_X = maus_X - neues_maus_X
  36.        differenz_Y = maus_Y - neues_maus_Y
  37.        fenster_X = fenster_X - differenz_X
  38.        fenster_Y = fenster_Y - differenz_Y
  39.        maus_X = neues_maus_X
  40.        maus_Y = neues_maus_Y
  41.        SetGadgetShape (window, fenster_X, fenster_Y, 600,400)
  42.      End If
  43.     Else
  44.             gedrueckt = 0
  45.           End If
  46.          End Select
  47. Forever
  48.  
  49. Function skin_window(window_handle, image_path$,panel,colorkey,alpha,colororalpha)
  50. ; colorkey is transparency color in hexadecimal form, black ist for example $FFFFFF
  51. ; alpha describes the opacity of the window, 0 for full translucent and 255 for non translucent
  52. ; use coloralpha to choose the mode you want to use
  53. ; 1 to set one color fully lucent
  54. ; 2 to set the level of the transperence of the whole window
  55. ; 3 to do both
  56. ; I think the rest ist self-explanatory
  57.  
  58.    If Not panel Then
  59.      panel = CreatePanel (0,0,gadgetwidth (window_handle), GadgetHeight (window_handle), window_handle)
  60.    End If
  61.    SetPanelImage panel, image_path$
  62.    hwnd = QueryObject (window_handle, 1)
  63.    SetWindowLong(hwnd, -20,  $80000)
  64.    SetLayeredWindowAttributes(hwnd, colorkey, alpha, colororalpha)
  65. End Function


Comments :


mag.(Posted 1+ years ago)

 its work! great. thanks


David Boudreau(Posted 1+ years ago)

 Please explain!  This looks very nice, but I do not understand what each one of these lines do (individually):
Code: [Select]
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? [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal