Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi

i m trying to change the text color of Edit Control in Window Class #32770
By SubClassing This Control , Msg Recieved But Not Set The Color

What I have tried:

Select Case uMsg
WM_CTLCOLOREDIT '&H133
SetTextColor wparam,RGB(200,0,188)
Exit Function 'Remove Border
Posted
Updated 28-Jan-22 22:11pm
Comments
Richard MacCutchan 29-Jan-22 3:49am    
SetTextColor only changes the text for the currently active Device Context. It is generally only used within the WM_PAINT handler when updating the active Window.
[no name] 29-Jan-22 3:54am    
Hi , Put SetTextColor in WM_PAINT , So why SetTextColor in WM_CTLCOLORSTATIC affect on color in Static Control But WM_CTLCOLOREDIT No any action on Text Colour
Richard MacCutchan 29-Jan-22 4:07am    
Sorry, I do not know the answer. But I really think that you are going to struggle with this unless you have a good solid understanding, and experience, of Windows GDI. It is not a simple subject and there are specific rules that must be followed in order to do it properly.

1 solution

See WM_CTLCOLOREDIT message (Winuser.h) - Win32 apps | Microsoft Docs[^]. This explains what you must do to respond to this message. And calling SetTextColor is obviously not the answer. As I said above, Windows GDI is not a simple subject.
 
Share this answer
 
Comments
[no name] 29-Jan-22 15:47pm    
SetTextColor not working in WM_CTLCOLIREDIT
SetTextColor wparam,RGB(100,0,200)
Exit Function ' Return 0
Richard MacCutchan 30-Jan-22 3:33am    
No of course not, and for the reason explained in the link I gave you above. As I keep saying, if you do not follow the rules then your code will not work.
[no name] 30-Jan-22 10:21am    
Finally Done !
the Parent window recieve WM_CTLCOLOREDIT Or WM_CTLCOLORSTATIC
What i did Try is : (Solved)
Case &H1
hBrush=CreateSolidBrush(RGB(255,255,255)
Case 307
SetTextColor wparam,VbRed
WinProc=hBrush ' Rgb(255,255,255)
Exit Function
of Course no need put hbrush in WM_CREAT Or WM_INITDIALOG
here do not allow to put picture so could not attach it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900