Im making an NFO Viewer for a particular program im making... thats all fine.
My problem revolves around the fact while using a timer, im trying to change the Colour of the text every .05 second (or however fast I make the timer using SetTimer).
This is what I have but for some reason it is just not working with the exe, it assembles, links and compiles without any errors, hlp would be appreciated;
.elseif wParam == 91 ;timer
cmp eax, 0FFFFFFh
jge loopey
add eax,10
Invoke SetTextColor, wParam, eax
JMP herewe_are
loopey:
mov eax, 0000000h
herewe_are:
.endif
I dont really know why its not working, thanks would be grateful
hi ksbunker
send me please the source code for help
What type of control ?? And SetTextColor probably doesn't work exactly as you would expect, it will not generally change the text color in the way you want. It is usually used in conjunction with WM_PAINT etc... or GDI drawing not as a general API. For example using it just to set the color of the text in an EDIT control will have no effect as the default pen is selected almost immediately when the WM_PAINT is sent to the control. In order to change the text color you should be responding to oine of the WM_CTLCOLOR messages, and the timer should only be forcing a repaint of the control.
ah crap you're right.
QuoteNfoProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg == WM_INITDIALOG
;Invoke GetDlgItem, hWnd, IDD_NFO
;mov hDialog2, eax
Invoke SetTimer, hWnd, 90, 150, NULL
Invoke SetTimer, hWnd, 91, 10, NULL
INVOKE SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOSIZE Or SWP_NOMOVE
Invoke FindResource, hInstance, ID_NFO, RT_RCDATA
Invoke LoadResource, hInstance, eax
Invoke LockResource, eax
Invoke SetDlgItemText, hWnd, IDC_EDITBOX, eax
;Invoke SetWindowText, IDC_EDITBOX, eax
;Invoke SendDlgItemMessage, hWnd, IDC_EDITBOX, WM_KILLFOCUS, 0, 0
Invoke SetWindowText, hWnd, ADDR szNFOCaption
.ELSEIF uMsg == WM_CTLCOLORDLG
mov eax, hBlackColor
ret
.ELSEIF uMsg == WM_CTLCOLORSTATIC
Invoke SetTextColor, wParam, CR_WHITE
Invoke SetBkMode, wParam, OPAQUE
Invoke SetBkColor, wParam, CR_BACKGROUND
mov eax, hBlackColor
ret
.ELSEIF uMsg == WM_CTLCOLOREDIT
Invoke SetTextColor, wParam, CR_RED
Invoke SetBkMode, wParam, OPAQUE
Invoke SetBkColor, wParam, CR_BACKGROUND
mov eax, hBlackColor
ret
.ELSEIF uMsg == WM_TIMER
.if wParam == 90
Invoke GetAsyncKeyState, VK_F11
cmp eax, 0
JE F12
Invoke SendDlgItemMessage, hWnd, IDC_EDITBOX, EM_SCROLL, 0, 0
F12:
Invoke GetAsyncKeyState, VK_F12
cmp eax, 0
JE xored
Invoke SendDlgItemMessage, hWnd, IDC_EDITBOX, EM_SCROLL, 1, 0
; .elseif wParam == 91
;
;
; cmp eax, 0FFFFFFh
; jge loopey
;
; add eax,10
;
; Invoke SetTextColor, wParam, eax
; JMP herewe_are
;
; loopey:
; mov eax, 0000000h
;
; herewe_are:
.endif
.ELSEIF uMsg == WM_CLOSE
JMP here
.ELSEIF uMsg == WM_RBUTTONUP
here:
Invoke KillTimer, hWnd, 90
Invoke KillTimer, hWnd, 91
Invoke RegisterHotKey, hWin, 7, NULL, VK_F11 ;Speed
Invoke RegisterHotKey, hWin, 8, NULL, VK_F12 ;Supershot
Invoke ShowWindow, hWin, SW_SHOW
Invoke EndDialog, hWnd, NULL
.ELSEIF uMsg == WM_LBUTTONDOWN
INVOKE SendMessage, hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
.ENDIF
So using... WM_CTLCOLOREDIT, how would I go about doing what I want?
You know at this point I would suggest that the standard edit control does not meet your requirements, I would choose a different control for example a richedit or a custom or sub/superclassed edit. Trying to make a control do things it wasn't meant to only leads to settling for less than what you originally intended and rarely leaves room for new ideas or expansion. In my opinion you should look to a simple richedit control, for such an easy application it is adequate but for something more complex I would go with a custom control.
If you want to stick to your current way, just set the GWL_USERDATA field of the edit control to the colour the text should be when handling the WM_TIMER message and extract it during the WM_CTLCOLOREDIT message. If you need the control painted immediately use InvalidateRect. By using GWL_USERDATA you do not need any global variables and by setting it in the edit control you allow for multiple edits with different colours.
Sorry for bumping such an old response.
I just dont want to go out of my way to test it out only to see it doesn't work.
Will subclassing the edit box, then with WM_TIMER change SetTextColor, work?. I noticed that there is no control ID specifier in the params of SetTextColor. By donig it this way, would the changes made by SetTextColor affect the whole control (that being the subcalled edit control).
Sorry for questions, im just curious.
Depending on your application there may not be a need to subclass the edit control, if it is simply to change all the text color the WM_CTLCOLOR message will do, here is an example. Note that I do not code in MASM so you will have to translate it from GoAsm but it is a very simple application and should not be a problem.
Donkey
[attachment deleted by admin]
ive googled a lot for an answer, but I cannot seem to get the assembler to process the line;
cmovz ecx, eax
The error I receive is "error A2085: instruction or register not accepted in current CPU mode". Presumably it is that my directive is .386, but i wasn't sure what to change it to
Change your cpu directive to 686, that instruction is only available from the PII up AFAIK
.686
.model flat, stdcall
option casemap none