Hi guys,

i'm writing a game. At the end of the game, a dialog is shown with DialogBoxParam(). I have a STATIC class window on thast dlg, with the words "Game over" in it. In the dlgProc, i am handling the WM_CTLCOLORSTATIC message so that i can select a font into that STATIC. I also want to colour the text red, but i can't get that bit to work. Here is the code:

dlgWndProc proc m_hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

;write total score to score box (STATIC window)
invoke dwtoa, g_dwTotalPoints, addr outStrWorkSpace
invoke SendDlgItemMessage, m_hWnd, IDC_finalScoreQuantity, WM_SETTEXT, NULL, addr outStrWorkSpace

mov eax, TRUE

;get the handle of the control we want to change:
invoke GetDlgItem, m_hWnd, IDC_gameOverText

;check we are messing with the correct STATIC control:
.IF eax == lParam
;select font into main "Game over" label
invoke SelectObject, wParam, masterTileFont
RGB 255, 0, 0
invoke SetTextColor, wParam, eax

mov eax, TRUE

mov eax, FALSE
dlgWndProc endp

(that last line should read:
"dlgWndProc endp"
the parsing engine keeps chopping it...)

No matter what i tried, i can't get the text to change colour, anybody got any ideas?

Posted on 2001-10-29 03:58:57 by sluggy
Hi Sluggy

Use this to set back and fore color in static.

invoke GetWindowLong,lParam,GWL_ID
.if eax==1001
.if hBrush
invoke DeleteObject,hBrush
invoke SetBkMode,wParam,TRANSPARENT
INVOKE SetTextColor,wParam,0FFFFh
invoke CreateSolidBrush,0FFh
mov hBrush,eax
mov eax,FALSE

Posted on 2001-10-29 04:31:58 by KetilO
Thanks KetilO,
that worked a treat. I forgot that by returning a TRUE value after that message, Windoze would think i was returning a brush handle, which of course would have been invalid. I won't do that again :)
Posted on 2001-10-29 05:44:35 by sluggy