NO

Author Topic: Scrolling desktop demo  (Read 2632 times)

Offline Vortex

  • Member
  • *
  • Posts: 843
    • 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...

Offline Vortex

  • Member
  • *
  • Posts: 843
    • http://www.vortex.masmcode.com
Re: Scrolling desktop demo
« Reply #1 on: September 16, 2024, 09:35:42 PM »
Macro for quick local definitions :

Code: [Select]
LOCDD MACRO _name

LOCAL _local

    _local TEXTEQU <LOCAL >,_name,< : DWORD>

    _local

ENDM

Code: [Select]
main PROC uses esi edi ebx

LOCDD hDC
LOCDD x
LOCDD y
LOCDD x2
LOCDD y2
LOCDD tempDC
LOCDD hWnd
LOCDD hBmp
LOCDD hOldBmp
Code it... That's all...

Offline Vortex

  • Member
  • *
  • Posts: 843
    • http://www.vortex.masmcode.com
Re: Scrolling desktop demo
« Reply #2 on: September 18, 2024, 08:26:22 PM »
An improved version of the LOCDD macro :

Code: [Select]
LOCDD MACRO arglist:VARARG

LOCAL _local

    FOR arg,<arglist>

        _local TEXTEQU <LOCAL >,arg,< : DWORD>

        _local

    ENDM

ENDM

Code: [Select]
main PROC uses esi edi ebx

LOCDD hOldBmp
LOCDD hDC,x,y
LOCDD x2,y2,tempDC
LOCDD hWnd,hBmp
« Last Edit: September 18, 2024, 08:59:21 PM by Vortex »
Code it... That's all...

Offline Vortex

  • Member
  • *
  • Posts: 843
    • http://www.vortex.masmcode.com
Re: Scrolling desktop demo
« Reply #3 on: September 22, 2024, 10:56:59 AM »
The 64-bit version :

Code: [Select]
LOCQW MACRO arglist:VARARG

LOCAL _local

    FOR arg,<arglist>

        _local TEXTEQU <LOCAL >,arg,< : QWORD>

        _local

    ENDM

ENDM
Code it... That's all...