News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

color fonction

Started by imadhx30, March 20, 2014, 06:29:58 AM

Previous topic - Next topic

imadhx30

COLOr

jj2007

Google SetConsoleTextAttribute.

imadhx30


ragdog

Why not working, have you not google
or this field here on board for searching?

http://masm32.com/board/index.php?topic=2980.msg31142#msg31142

Greets,

imadhx30

masm32rt not compatible with other library as kernel32.inc and mams32.inc .......
in my program used kernel32.inc library and masm32.inc .....
I used
http://masm32.com/board/index.php?topic=2980.msg31142#msg31142
of dedndav but not compatible with my program

MichaelW

Quote from: imadhx30 on March 20, 2014, 08:32:37 AM
masm32rt not compatible with other library as kernel32.inc and mams32.inc .......
in my program used kernel32.inc library and masm32.inc .....

They are not compatible because masm32rt.inc includes these other include files. See the example code below.

In case you don't already know, the console text attributes are the same format as for the old VGA 16-color alphanumeric modes with the default palette. In this format the foreground and background attributes are packed into a byte with the bit assignments as follows:

Bit7 background intensity
Bit6 background red component
Bit5 background green component
Bit4 background blue component
Bit3 foreground intensity
Bit2 foreground red component
Bit1 foreground green component
Bit0 foreground blue component

So instead of using Microsoft's clumsy defines, FOREGROUND_BLUE, FOREGROUND_GREEN, etc, you can simply specify the necessary bits as a number in the range 0-15.   

This code defines a macro to specify the foreground and background attributes that, for the color assignments, works essentially like the BASIC language COLOR statement:



color MACRO foreground, background
    mov eax, background
    shl eax, 4
    or eax, foreground
    EXITM <eax>
ENDM

include \masm32\include\masm32rt.inc
.data
    hStdout dd 0
.code
start:
    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov hStdout, eax
    xor esi, esi
    .WHILE esi < 16
        xor edi, edi
        .WHILE edi < 16
            invoke SetConsoleTextAttribute, hStdout, color(esi,edi)
            printf("X")
            inc edi
        .ENDW
        printf("\n")
        inc esi
    .ENDW
    ; Restore the default attribute (white on black).
    invoke SetConsoleTextAttribute, hStdout, color(7,0)
    printf("\n\n")
    inkey
    exit
end start





Well Microsoft, here's another nice mess you've gotten us into.

jj2007

Quote from: imadhx30 on March 20, 2014, 07:14:15 AM
Not WOrking!!

If Google is not WOrking, bad luck - you can still use MasmBasic ConsoleColor:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  ConsoleColor
  Print "This is the standard color (white on black),", CrLf$, "but "
  ConsoleColor cRed, cWhite
  Print "this is red on white, while"
  ConsoleColor cBlue, cGray
  Print "this is blue", CrLf$,"on grey, and"
  ConsoleColor
  Inkey " this is back to white on black"
  Exit
end start

Available colors (see also http://support.microsoft.com/kb/319883):
cBlack, cWhite, cGray, cBlue, cGreen, cCyan, cRed, cMagenta, cYellow
cDarkGray, cDarkBlue, cDarkGreen, cDarkCyan, cDarkRed, cDarkMagenta, cDarkYellow

dedndave

SetConsoleTextAttribute only changes the color for any text displayed after the color change

i thought i posted a routine that sets the colors and clears the screen

ok - maybe that's not what you want

but.....
the colors for future attributes is not the same as the colors in the buffer

hutch--

It may also help if you included WINDOWS.INC FIRST as it is designed to be used.

imadhx30

how to change color black other color bachground my progrmme
without using masm32rt library

dedndave


imadhx30

already used my program but not change color
Please give another color function

dedndave

i don't understand what the problem is
does the program i posted show up with yellow text and a blue background ?
if not, what colors does it show up with
are you using the windows console ?
or dos box or what
i need more information to help you

MichaelW

Quote from: dedndave on March 21, 2014, 08:57:12 AM
i don't understand what the problem is

Or what the problem is with using masm32rt.inc.
Well Microsoft, here's another nice mess you've gotten us into.