SetWindowAlpha Funktion

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Neue Antwort erstellen

Suco-X

Betreff: SetWindowAlpha Funktion

BeitragMi, Jan 25, 2006 12:03
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi
Nachdem endlich der QUERY_HWND Fix gekommen ist, hier die Funktion (Es werden die neusten BRL GUI Module gebraucht)
Mit dieser Funktion kann man einem Fenster einen Alphawert von 0.0 - 1.0 geben. Zu gebrauchen für Startscreens die sich ein und ausblenden oder für sonstige Spielereien.
Wieder nur für Windows, da ich für die anderen Betriebssysteme weder Zeit noch Mittel habe.

Code mit Beispiel:
Code: [AUSKLAPPEN]

Strict

?Win32

Function SetWindowAlpha(Window:TGadget, Alpha:Float)
   
   Const LWA_ALPHA = 2

   Extern "Win32"
      Function SetWindowLong:Int(hWnd:Int, nIndex:Int, dwNewLong:Int)="SetWindowLongA@12"
      Function SetLayeredWindowAttributes(hWnd:Int, temp:Int, alpha:Int, buh:Int)="SetLayeredWindowAttributes@16"
      Function GetWindowLong:Int(hWnd:Int, nIndex:Int)="GetWindowLongA@8"
   End Extern
   
   Local hWnd:Int
   Local Style:Int
   
   hWnd = QueryGadget(Window, QUERY_HWND)
   
   If Not hWnd
      Return False
   EndIf
   
   Style = GetWindowLongA(hWnd, GWL_EXSTYLE)
   Style:|WS_EX_LAYERED
   
   SetWindowLongA(hWnd, GWL_EXSTYLE, Style)
   SetLayeredWindowAttributes(hWnd, 0, (255.0*Alpha), LWA_ALPHA)
   
   Return True
End Function

?


Local Window:TGadget = CreateWindow("Alpha Test",100, 100, 400, 400)
SetWindowAlpha(Window, 0.5)


Repeat

   WaitEvent()
   
   Select EventID()
   
      Case EVENT_WINDOWCLOSE
         End
         
   End Select
   
Forever



Mfg Suco
Intel Core 2 Quad Q8300, 4× 2500 MHz, 4096 MB DDR2-Ram, GeForce 9600GT 512 MB

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group