![]() |
Programm beim Beenden langsam ausblenden
Hallo leute! habe das gerade in nem anderen programm gesehen: wenn man auf schließen klickt dann blendet sich das formular langsam aus, wenn es weg ist wird es eigentlich erst beendet. wie stellt man das an?
Gruße, dopeline :dancer: |
Re: Programm beim Beenden langsam ausblenden
Delphi-Quellcode:
Mit dem TimerIntervall etwas rumspielen, bis es paßt.
type
TForm1 = class(TForm) Timer1: TTimer; procedure Timer1Timer(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); private { Private-Deklarationen } FCanClose: Boolean; public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Timer1Timer(Sender: TObject); begin AlphaBlendValue := AlphaBlendvalue - 20; if AlphaBlendValue < 20 then begin FCanClose := TRUE; Timer1.Enabled := FALSE; Close(); end; end; procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin Timer1.Enabled := TRUE; CanClose := FCanClose; end; |
Re: Programm beim Beenden langsam ausblenden
das geht aber nur mit winxp oder?
|
Re: Programm beim Beenden langsam ausblenden
Das geht mit 2000 und neuer. Siehe auch Delphi-Hilfe.
|
Re: Programm beim Beenden langsam ausblenden
@Luckie
also irgentwie funzt das nicht. ich starte das programm, klicke auf schließen, es passiert nichts, ich kann so oft klicken, wie ich will, nichts. nach ner weile schließt sich das formular (allerdings ohne sich auszublenden.) also an windows dürfte das nicht liegen (WinXP Pro) irgentwo ist dort der wurm drin. aber wo? Gruß, dopeline |
Re: Programm beim Beenden langsam ausblenden
Liste der Anhänge anzeigen (Anzahl: 1)
Geht so, wie er da steht. Beweis im Anhang.
|
Re: Programm beim Beenden langsam ausblenden
Kannst es hiermit ja mal versuchen.
Man braucht zwar eine Trackbar und es funktionier nur unter WindowsXP, aber du kannst es ja ein bischen ändern.
Delphi-Quellcode:
// Make your forms 25%, 50% Transparent...
TMyForm = class (TForm); TrackBar1: TTrackBar; //.. private FColorKey: TCOLOR; end; const // Use crKey as the transparency color. LWA_COLORKEY = 1; // Use bAlpha to determine the opacity of the layered window.. LWA_ALPHA = 2; WS_EX_LAYERED = $80000; implementation {$R *.DFM} // The SetLayeredWindowAttributes function sets the opacity and transparency // color key of a layered window. // Note : This function is only available with Windows 2000 and XP! function SetLayeredWindowAttributes( // Handle to the layered window. Wnd: hwnd; // Pointer to a COLORREF value that specifies the transparency // color key to be used when composing the layered window crKey: ColorRef; // Alpha value used to describe the opacity of the layered window Alpha: Byte; // Specifies an action to take // LWA_COLORKEY or LWA_ALPHA // This parameter can be one or more of the following values: dwFlags: DWORD): Boolean; stdcall; external 'user32.dll'; procedure TMyForm.TrackBar1Change(Sender: TObject); // Trackbar.Position must run at range 1-255... begin SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED); SetLayeredWindowAttributes(Handle, ColorToRGB(FColorKey), TrackBar1.Position, LWA_ALPHA); end; {******************************************************************} { To load the SetLayeredWindowAttributes() function dynamically, use this function:} function MakeWindowTransparent(Wnd: HWND; nAlpha: Integer = 10): Boolean; type TSetLayeredWindowAttributes = function(hwnd: HWND; crKey: COLORREF; bAlpha: Byte; dwFlags: Longint): Longint; stdcall; const // Use crKey as the transparency color. LWA_COLORKEY = 1; // Use bAlpha to determine the opacity of the layered window.. LWA_ALPHA = 2; WS_EX_LAYERED = $80000; var hUser32: HMODULE; SetLayeredWindowAttributes: TSetLayeredWindowAttributes; i: Integer; begin Result := False; // Here we import the function from USER32.DLL hUser32 := GetModuleHandle('USER32.DLL'); if hUser32 <> 0 then begin @SetLayeredWindowAttributes := GetProcAddress(hUser32, 'SetLayeredWindowAttributes'); // If the import did not succeed, make sure your app can handle it! if @SetLayeredWindowAttributes <> nil then begin // Check the current state of the dialog, and then add the WS_EX_LAYERED attribute SetWindowLong(Wnd, GWL_EXSTYLE, GetWindowLong(Wnd, GWL_EXSTYLE) or WS_EX_LAYERED); // The SetLayeredWindowAttributes function sets the opacity and // transparency color key of a layered window SetLayeredWindowAttributes(Wnd, 0, Trunc((255 / 100) * (100 - nAlpha)), LWA_ALPHA); Result := True; end; end; end; |
Re: Programm beim Beenden langsam ausblenden
@Luckie
hab den fehler gefunden: vergessen alphablend des formulares auf true zu setzen :oops: @Uncle Cracker ich glaub da nehm ich lieber luckies variante. ist mir leichter verständlich :wink: dankeschön! :hello: |
Re: Programm beim Beenden langsam ausblenden
Zitat:
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:31 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz