NO

Author Topic: Scrolling desktop demo  (Read 431 times)

Online Vortex

  • Member
  • *
  • Posts: 802
    • http://www.vortex.masmcode.com
Scrolling desktop demo
« on: January 13, 2024, 09:57:04 PM »
Here is another improved version :

Code: [Select]
.386
.model flat,stdcall
option casemap:none

include ScrollDesktop.inc

.data

ClassName   db 'Shell_TrayWnd',0

.code

start:

    call    main
    invoke  ExitProcess,0

main PROC uses esi edi ebx

LOCAL hDC:DWORD
LOCAL x:DWORD,y:DWORD
LOCAL x2:DWORD,y2:DWORD
LOCAL tempDC:DWORD,hWnd:DWORD
LOCAL hBmp:DWORD,hOldBmp:DWORD

    xor     ebx,ebx
    invoke  FindWindow,ADDR ClassName,ebx
    mov     hWnd,eax

    invoke  GetDC,ebx                               ; get the DC of desktop
    mov     hDC,eax

    invoke  CreateCompatibleDC,eax                  ; create a DC compatible with hDC
    mov     tempDC,eax

    invoke  GetSystemMetrics,ebx ; SM_CXSCREEN      ; get the width and height of the screen
    mov     x,eax
    mov     x2,eax

    invoke  GetSystemMetrics,SM_CYSCREEN
    mov     y,eax
    mov     y2,eax

    invoke  CreateCompatibleBitmap,hDC,x,eax        ; create a compatible bitmap
    mov     hBmp,eax

    invoke  SelectObject,tempDC,eax
    mov     hOldBmp,eax

    invoke  BitBlt,tempDC,ebx,ebx,x,y,hDC,ebx,ebx,SRCCOPY   ; copy the screen to the target DC

    xor     esi,esi
    mov     edi,SRCCOPY

@@:
    invoke  BitBlt,hDC,esi,ebx,x,y,hDC,ebx,ebx,edi
    invoke  BitBlt,hDC,ebx,esi,x,y,hDC,ebx,ebx,edi
    invoke  Sleep,50

    add     esi,1
    cmp     esi,30
    jne     @b

@@:
    invoke  BitBlt,hDC,esi,ebx,x,y,hDC,ebx,ebx,edi
    invoke  BitBlt,hDC,esi,esi,x,y,hDC,ebx,ebx,edi
    invoke  Sleep,50

    sub     esi,1
    test    esi,esi
    jnz     @b

    invoke  BitBlt,hDC,ebx,ebx,x2,y2,tempDC,ebx,ebx,edi     ; copy the screen to the target DC
    invoke  SelectObject,tempDC,hOldBmp             ; return back the old handle

    mov     ebx,hWnd

    invoke  ShowWindow,ebx,SW_HIDE                  ; redraw the taskbar to display the correct time
    invoke  ShowWindow,ebx,SW_SHOW

    mov     esi,DeleteObject
    push    hBmp
    call    esi

    push    hOldBmp
    call    esi

    invoke  DeleteDC,tempDC
    invoke  ReleaseDC,ebx,hDC

    ret

main ENDP

END start
Code it... That's all...