Delphiidiot (白 白) Email: wangsl@dhc.com.cn QQ: 46525765
Introducing pictures in the application and fades, allowing the user interface to be more beautiful. There are two common methods described in previous newspapers and magazines: First, write procedures, all pixels for mixing gradient; Second, use DirectX to create a Surface with Alpha channel. The first, the effect can be controlled by himself, but it is more troublesome, and it is generally not easy to generate hardware optimized code; the second speed is very fast, but it needs to use the DirectX library.
This article combines the Delphi instance code, introduces two simple and fast implementation methods, is a summary, I hope to help beginners.
One: Use of animateWindow function: (1) Function prototype: BOOL AnimateWindow (HWND HWnd, // Handle DWORD DWTIME, // Movie Duration To Duty in milliseconds) // animation type in milliseconds) (2) Parameter setting: hWnd: Use "Form name .handle", such as: form1.handle; dwtime: Under normal circumstances, I am more suitable for 1000; dwflags: can be set to a variety of effects, See MSDN, here I only introduce the parameters for fade in fade out; if it is fade, set to aw_blend, if it is fade, set to aw_blend or aw_hide. (3) Creating a new project, add a button button1 on the generated form FORM1, button1's CAPTION is set to "出"; next to the following two codes, realize fade out: 1, fade in: Double click Form1 Add: AnimateWindow (Form1.Handle, 1000, AW_BLEND); 2, Fade: Double-click Button1, add: AnimateWindow (Form1.Handle, 1000, aw_hide or aw_blend); Form1.close; // Close window
the entire procedure the following procedure: procedure TForm1.FormCreate (Sender: TObject); begin AnimateWindow (Form1.Handle, 1000, AW_BLEND); end; procedure TForm1.Button1Click (Sender: TObject); begin AnimateWindow (Form1.Handle, 1000, AW_HIDE OR aw_blend; end; two, alphablend properties Combine TIMER Components: (1) Principle: In Delphi6.0 (I don't know 6.0, I don't know), each form has alphablend properties and alphablendValue properties, will alphablend properties Set to TRUE, then change the value of AlphablendValue (0-255) over time over time.