Scrolling the Console Window

The following Scroll.asm program writes 50 lines of text to the screen buffer. It then resizes
and repositions the console window, effectively scrolling the text backward. It uses the
SetConsoleWindowInfo function:

 
  
TITLE Scrolling the Console Window (Scroll.asm)
INCLUDE Irvine32.inc
.data
message BYTE ": This line of text was written "
BYTE "to the screen buffer",0dh,0ah
messageSize DWORD ($-message)
outHandle HANDLE 0 ; standard output handle
bytesWritten DWORD ? ; number of bytes written
lineNum DWORD 0
windowRect SMALL_RECT <0,0,60,11> ; left,top,right,bottom
.code
main PROC
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov outHandle,eax
.REPEAT
mov eax,lineNum
call WriteDec ; display each line number
INVOKE WriteConsole,
outHandle, ; console output handle
ADDR message, ; string pointer
messageSize, ; string length
ADDR bytesWritten, ; returns num bytes written
0 ; not used
inc lineNum ; next line number
.UNTIL lineNum > 50
; Resize and reposition the console window relative to the
; screen buffer.
INVOKE SetConsoleWindowInfo,
outHandle,
TRUE,
ADDR windowRect ; window rectangle
call Readchar ; wait for a key
call Clrscr ; clear the screen buffer
call Readchar ; wait for a second key
INVOKE ExitProcess,0
main ENDP
END main

 

 

It is best to run this program directly from MS-Windows Explorer or a command prompt rather
than an integrated editor environment. Otherwise, the editor may affect the behavior and appearance
of the console window. You must press a key twice at the end: once to clear the screen
buffer and a second time to end the program.

转载于:https://www.cnblogs.com/dreamafar/p/5985937.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值