News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Error Return from SetTextColor

Started by raleeper, August 21, 2011, 01:50:31 PM

Previous topic - Next topic

raleeper

The alleged error return from GetTextColor is a WORD, not a DWORD.  I know how to deal with that, but how can I spot such cases in advance?


According to the help file of my SDK for server 2003, the return values from

SetTextColor, hdc, crColor

are:

----------
Return Values
If the function succeeds, the return value is a color reference for the previous text color as a COLORREF value.

If the function fails, the return value is CLR_INVALID.

----------
In my code I had

invoke SetTextColor,hdc,[ebx+4]
cmp eax, CLR_INVALID
  jnz @F


The listing of that is
               
00001557  FF 73 04   *          push   dword   ptr [ebx]+000000004h
0000155A  FF 35 00001ECC R *   push   hdc
00001560  E8 00000000 E *       call   SetTextColor
00001565  3D 0000FFFF      cmp   eax, CLR_INVALID
0000156A  75 01                              jnz   @F

Well, it did return failure while I was working on it, but the return was not 0000FFFFh, but 0FFFFFFFFh (which must be failure, since it is not a valid color reference.)

Thanks, ral



Tedd

You're right, windows.inc is wrong.


Currently, it's:
CLR_INVALID equ 0FFFFh

It should be:
CLR_NONE    equ 0FFFFFFFFh
CLR_INVALID equ CLR_NONE

No snowflake in an avalanche feels responsible.

raleeper

Quote from: Tedd on August 21, 2011, 01:59:42 PM
You're right, windows.inc is wrong.


Currently, it's:
CLR_INVALID equ 0FFFFh

It should be:
CLR_NONE    equ 0FFFFFFFFh
CLR_INVALID equ CLR_NONE



Thanks Tedd.  That answers my question (No, you can't spot such things in advance [but they should be very rare]), and eliminates some of that lost feeling I was getting.

Robert