The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: Ranjan on May 29, 2006, 11:02:12 AM

Title: m32lib ClearScreen change
Post by: Ranjan on May 29, 2006, 11:02:12 AM
The ClearScreen do not clear the screen attribute. A little change for correcting the bug.

code:
ClearScreen proc

  ; -----------------------------------------------------------
  ; This procedure reads the column and row count, multiplies
  ; them together to get the number of characters that will fit
  ; onto the screen, writes that number of blank spaces to the
  ; screen, set the screen buffer attributes and reposition
  ; the prompt at position 0,0.
  ; -----------------------------------------------------------

    LOCAL hOutPut:DWORD
    LOCAL noc    :DWORD
    LOCAL cnt    :DWORD
    LOCAL sbi    :CONSOLE_SCREEN_BUFFER_INFO

    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov hOutPut, eax

    invoke GetConsoleScreenBufferInfo,hOutPut,ADDR sbi

    mov eax, sbi.dwSize     ; 2 word values returned for screen size

  ; -----------------------------------------------
  ; extract the 2 values and multiply them together
  ; -----------------------------------------------
    mov ecx, eax
    shr eax, 16
    mul cx
    mov cnt, eax

    invoke FillConsoleOutputCharacter, hOutPut, 32, cnt, NULL, ADDR noc

    movzx ecx,sbi.wAttributes
    invoke FillConsoleOutputAttribute, hOutPut, ecx, cnt, NULL, ADDR noc

    invoke SetConsoleCursorPosition, hOutPut, NULL

    ret

ClearScreen endp

Title: Re: m32lib ClearScreen change
Post by: zeikman on August 26, 2010, 02:57:47 PM
Thanks for the info, it is very useful
Title: Re: m32lib ClearScreen change
Post by: frktons on September 13, 2010, 05:25:53 AM
It seems to work just fine.

Frank