The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: hutch-- on September 28, 2005, 11:08:40 PM

Title: Fade in window algo
Post by: hutch-- on September 28, 2005, 11:08:40 PM
I found the idea in Bill Cravener's example code so I played wit it to make it self contained and update the window that is being faded in. I tested it with the editor I write called TopGun and it apears to work fine. The additional UpdateWindow calls in the loop are so they other windows in the interface are updated as well as the parent window. This code will not work on a pre win2000 os version.


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

WindowFadeIn proc hWin:DWORD,msdelay:DWORD,step:DWORD,swattr:DWORD

    ; --------------------------------------------------
    ; hWin      = handle of window to fade in.
    ; msdelay   = delay between fade level changes
    ; step      = incremental fade rate change up to 255
    ; swattr    = ShowWindow style
    ; --------------------------------------------------

    LOCAL wstyle    :DWORD

    push esi
    xor esi, esi

    invoke GetWindowLong,hWin,GWL_EXSTYLE           ; get current window style
    mov wstyle, eax
    or eax,WS_EX_LAYERED
    invoke SetWindowLong,hWin,GWL_EXSTYLE,eax       ; add the WS_EX_LAYERED style

    invoke SetLayeredWindowAttributes,hWin,0,0,2

    invoke ShowWindow,hWin,swattr

  doloop:
    invoke SetLayeredWindowAttributes,hWin,esi,esi,1 or 2
    invoke Sleep, msdelay

    invoke UpdateWindow,hEdit
    invoke UpdateWindow,hRebar
    invoke UpdateWindow,hStatus
    invoke UpdateWindow,hWin

    add esi,step
    cmp esi,255
    jl doloop

    invoke SetLayeredWindowAttributes,hWin,0,255,2
    invoke UpdateWindow,hWin

    invoke SetWindowLong,hWin,GWL_EXSTYLE,wstyle    ; restore original window style

    pop esi

    ret

WindowFadeIn endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

Title: Re: Fade in window algo
Post by: Farabi on September 29, 2005, 03:41:36 PM
Fast.  :U
Title: Re: Fade in window algo
Post by: Biterider on September 29, 2005, 06:30:55 PM
Hi Hutch
Here the Window Fade in and out of the ObjMem32 library. It autodetects the OS and executes the code if the APIs are supported. The APIs are loaded dynamically to prevent startup problems with static linking.

Regards

Biterider



[attachment deleted by admin]
Title: Re: Fade in window algo
Post by: hutch-- on September 30, 2005, 09:15:54 AM
Biterider,

Compliments, nice piece of code. The version detect is a good idea if the app is designed to run on 9x as well as later systems.  :U