The MASM Forum

General => The Campus => Topic started by: imadhx30 on March 02, 2014, 11:45:51 PM

Title: display masm32
Post by: imadhx30 on March 02, 2014, 11:45:51 PM
how to change background color screen to display masm32 !! :icon_exclaim:
Title: Re: display masm32
Post by: hutch-- on March 03, 2014, 12:22:49 AM
I am not sure what you mean but if its the editor colour, go to the settings on the edit menu and change the colours to what you find OK.
Title: Re: display masm32
Post by: imadhx30 on March 04, 2014, 06:53:22 AM
not color masm32 editor
but color window to display results (of after run program) :icon_exclaim:
Title: Re: display masm32
Post by: qWord on March 04, 2014, 07:29:33 AM
Quote from: imadhx30 on March 04, 2014, 06:53:22 AMbut color window to display results (of after run program) :icon_exclaim:
GUI or console window? More details please!! :icon_exclaim:
Title: Re: display masm32
Post by: KeepingRealBusy on March 04, 2014, 07:32:06 AM
If I understand you correctly, you execute a program created by masm32. If this is a Console App, then right click in the Title bar, and select Properties, then select Colors. Someone else (Hutch?) will have to explain what to do if this is a windows App.

Dave.
Title: Re: display masm32
Post by: dedndave on March 04, 2014, 07:45:24 AM
it can be done programatically in the console by using FillConsoleOutputAttribute

this is a console clear screen routine - it uses the current colors
but, i commented the line where DX holds a word with attributes
you can set that to whatever foreground/background combination you like

;***********************************************************************************************

ConCls  PROC USES EBX

;Console Clear-Screen
;Version 1.0, David R. Sheldon, 10-2013

;-----------------------------------

;Call With: Nothing
;
;  Returns: EAX = hStdOut, console output handle
;           ECX = total number of characters in screen buffer
;           EDX = buffer character attributes used to clear screen
;
;Also Uses: EBX, ESI, EDI, EBP are preserved

;-----------------------------------

        LOCAL   _csbi   :CONSOLE_SCREEN_BUFFER_INFO
        LOCAL   _nChars :DWORD

;-----------------------------------

    INVOKE  GetStdHandle,STD_OUTPUT_HANDLE
    xchg    eax,ebx                                    ;EBX = hConsole
    INVOKE  GetConsoleScreenBufferInfo,ebx,addr _csbi
    movzx   eax,word ptr _csbi.dwSize.x
    movzx   edx,word ptr _csbi.dwSize.y
    lea     ecx,_nChars
    mul     edx
    INVOKE  FillConsoleOutputCharacter,ebx,32,eax,0,ecx
    movzx   edx,word ptr _csbi.wAttributes                             ;DX = current attributes
    push    edx
    INVOKE  FillConsoleOutputAttribute,ebx,edx,_nChars,0,addr _nChars
    INVOKE  SetConsoleCursorPosition,ebx,0
    xchg    eax,ebx
    mov     ecx,_nChars
    pop     edx
    ret

ConCls  ENDP

;***********************************************************************************************


http://msdn.microsoft.com/en-us/library/windows/desktop/ms682662%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682662%28v=vs.85%29.aspx)

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682088%28v=vs.85%29.aspx#_win32_character_attributes (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682088%28v=vs.85%29.aspx#_win32_character_attributes)
Title: Re: display masm32
Post by: dedndave on March 04, 2014, 08:59:10 AM
ok - slight problem
the above code sets the attributes in the buffer
however, any new text displayed uses the current console attributes

by calling both FillConsoleOutputAttribute and SetConsoleTextAttribute, you set both
see the attached...
Title: Re: display masm32
Post by: imadhx30 on March 04, 2014, 09:42:01 AM
thank you dedndav  :t
Title: Re: display masm32
Post by: dedndave on March 04, 2014, 09:42:31 PM
 :t