Jump to content
Tuts 4 You

How To Fade-in And Fade-out?


hakand

Recommended Posts

Hello everyone,

I really wonder how it is done fading in and fading out effects while closing the application window and displaying it.

Does anyone know how to? I need the codes for Win98(especially) and XP systems.

Thanks in advance.

Link to comment
Guest Tundra

This is from Goppit's Win32 Assembly for Crackers. It can be found at tutorials.accessroot.com

In order to get our keygen to fade in and out on opening and closing, we have 2 procedures called FadeIn and FadeOut. For these we will need 2 prototypes, an uninitialised DWORD variable "Transparency" and the following constants which we have to define as they are not already in the windows.inc file: LWA_ALPHA, LWA_COLORKEY, WS_EX_LAYERED and DELAY_VALUE.

In order to use the transparency features of win2k or XP (ie not available on older versions of windows), we must use a layered window. This can significantly improve performance and visual effects for a window that has a complex shape, animates its shape, or wishes to use alpha blending effects. The system automatically composes and repaints layered windows and the windows of underlying applications. As a result, layered windows are rendered smoothly, without the flickering typical of complex window regions. In addition, layered windows can be partially translucent, that is, alpha-blended. In order to make a layered window, the window must be created with or set to have the WS_EX_LAYERED extended windows style.

The FadeIn procedure looks like this:

FadeIn proc hWnd:HWND
invoke ShowWindow,hWnd,SW_SHOW
mov Transparency,75
@@:
invoke SetLayeredWindowAttributes,hWnd,0,Transparency,LWA_ALPHA
invoke Sleep,DELAY_VALUE
add Transparency,5
cmp Transparency,255
jne @b
ret
FadeIn endp

The GetWindowLong API retrieves information about a window. The type of information is specified by the 2nd param - in our case GWL_EXSTYLE requests the extended windows style for the window and this is returned in eax. The next line adds in the value represented by WS_EX_LAYERED to eax. The 3rd line sets this value as the extended windows style for the window.

The SetLayeredWindowAttributes API sets the opacity and transparency colour key of a layered window. In this case the final parameter specifies a transparency (alpha blend) setting, and the 2nd 0 specifies completely transparent. The following line displays the window in a non-activated format and the next line moves a value of 75 into our transparency variable.

The next loop of instructions increments transparency by 5 and sets the window transparency with the new value each loop until transparency reaches 255 (maximum value = opaque). Sleep leaves a small delay between each loop so that the fade does not occur too quickly to see. When transparency = 255 the procedure returns.

The FadeOut procedure looks much the same and operates in reverse:

FadeOut proc hWnd:HWND
mov Transparency,255
@@:
invoke SetLayeredWindowAttributes,hWnd,0,Transparency,LWA_ALPHA
invoke Sleep,DELAY_VALUE
sub Transparency,5
cmp Transparency,0
jne @b
ret
FadeOut endp
Link to comment
Guest Tundra

You can try

invoke AnimateWindow,hWin,1000,AW_BLEND+AW_ACTIVATE

to fade in

and

invoke AnimateWindow,hWin,1000,AW_BLEND+AW_HIDE

to fade out

This won't work too well with invisible buttons, and I'm not even sure if this will work with Win9X; I only have WinXP

Link to comment

Tundra I couldnt find AnimateWindow function in win32API.hlp file. So, I am afraid win98 doesnt support that function.

Are there some other solutions for fading effects on win98?

Thanks.

Link to comment
  • 1 month later...

SetLayeredWindowAttributes is also not available in 98 or 95, just use the osversioninfo struct to check that the major version is above 5 before fading the window, if it's not, use standard window creation methods

Link to comment
  • 4 weeks later...

Hi guyz Anybody Know if this can be done

with a dUP Patch for exp.

I have made a dUP patch compiled it

and if i can make some code injection

and make it fade in and out?

Link to comment
  • 1 year later...
This is from Goppit's Win32 Assembly for Crackers. It can be found at tutorials.accessroot.com

In order to get our keygen to fade in and out on opening and closing, we have 2 procedures called FadeIn and FadeOut. For these we will need 2 prototypes, an uninitialised DWORD variable "Transparency" and the following constants which we have to define as they are not already in the windows.inc file: LWA_ALPHA, LWA_COLORKEY, WS_EX_LAYERED and DELAY_VALUE.

In order to use the transparency features of win2k or XP (ie not available on older versions of windows), we must use a layered window. This can significantly improve performance and visual effects for a window that has a complex shape, animates its shape, or wishes to use alpha blending effects. The system automatically composes and repaints layered windows and the windows of underlying applications. As a result, layered windows are rendered smoothly, without the flickering typical of complex window regions. In addition, layered windows can be partially translucent, that is, alpha-blended. In order to make a layered window, the window must be created with or set to have the WS_EX_LAYERED extended windows style.

The FadeIn procedure looks like this:

FadeIn proc hWnd:HWND
invoke ShowWindow,hWnd,SW_SHOW
mov Transparency,75
@@:
invoke SetLayeredWindowAttributes,hWnd,0,Transparency,LWA_ALPHA
invoke Sleep,DELAY_VALUE
add Transparency,5
cmp Transparency,255
jne @b
ret
FadeIn endp

The GetWindowLong API retrieves information about a window. The type of information is specified by the 2nd param - in our case GWL_EXSTYLE requests the extended windows style for the window and this is returned in eax. The next line adds in the value represented by WS_EX_LAYERED to eax. The 3rd line sets this value as the extended windows style for the window.

The SetLayeredWindowAttributes API sets the opacity and transparency colour key of a layered window. In this case the final parameter specifies a transparency (alpha blend) setting, and the 2nd 0 specifies completely transparent. The following line displays the window in a non-activated format and the next line moves a value of 75 into our transparency variable.

The next loop of instructions increments transparency by 5 and sets the window transparency with the new value each loop until transparency reaches 255 (maximum value = opaque). Sleep leaves a small delay between each loop so that the fade does not occur too quickly to see. When transparency = 255 the procedure returns.

The FadeOut procedure looks much the same and operates in reverse:

FadeOut proc hWnd:HWND
mov Transparency,255
@@:
invoke SetLayeredWindowAttributes,hWnd,0,Transparency,LWA_ALPHA
invoke Sleep,DELAY_VALUE
sub Transparency,5
cmp Transparency,0
jne @b
ret
FadeOut endp

Thanks for the infos :cool:

Link to comment

Depending on what language you are using, it is obviously different. But in vb.net you can very easily do it using:

Me.Opacity = Double value

For example, Me.Opacity = 0 makes the form 'invisible' and Me.Opacity = 1 makes the form 100% visible. Just make a loop to slowly increment the opacity when the app starts and to decrement when it closes. Simple.

Link to comment

@AK-47

Yeah you can inject code.....add the API AnimateWindow to your Patch and inject the code :)

to determinate where it the WM_INIDIALOG Message routine found you can use a used function in it ^^

or with a bit more experiense by yourself.......

Link to comment

Just simple FadeIn/Out examples for Delphi:

procedure FadeIn(FormName : TForm; tranz : byte);
var
i : Integer;
begin
FormName.AlphaBlend := True;
FormName.AlphaBlendValue := 0;
FormName.Show;
for i := 1 to tranz do begin
FormName.AlphaBlendValue := FormName.AlphaBlendValue + 1;
application.ProcessMessages;
end;
end;
procedure FadeOut(FormName : TForm);
var
i : Integer;
begin
for i := FormName.AlphaBlendValue downto 0 do begin
FormName.AlphaBlendValue := FormName.AlphaBlendValue - 1;
application.ProcessMessages;
end;
end;

BR, ChupaChu!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...