473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Changing Edit Box Text Colors in Windows

I'm having problems changing the text colors in an edit box in my program.
Here's what I'm trying to do, under WM_CREATE I have the following:

ClockFace = CreateWindowEx(0,
"EDIT",
"0.0.00",
WS_CHILD|WS_VISIBLE|WS_BORDER,
125,
75,
300,
100,
hwnd,
HMENU(CLOCKWINDOW),
NULL,
NULL);
HFONT StopFont =
CreateFont(100,24,0,0,700,200,0,0,0,0,0,0,0,TEXT(" Verdana"));
SendMessage(ClockFace, WM_SETFONT, WPARAM(StopFont),
MAKELPARAM(0,0));
hdc = GetDC(ClockFace); //tried putting this section under
WM_CTLCOLOREDIT, still didn't work
SetTextColor(hdc, RGB(0, 200, 0));
SetBkColor(hdc, RGB(0, 0, 0));

However, when I compile this I still get the standard black lettering and
white background. I think my problem lies in how I'm getting the DC handle.
I first tried typecasting the ClockFace HWND variable to a HDC but that
didn't work, but apparently GetDC isn't solving my problems either. How can
I fix this? Thanks for any help.
Jul 19 '05 #1
2 8855
Matt wrote:
I'm having problems changing the text colors in an edit box
in my program.


This news group is for discussion of the c++ language itself,
not OS-specific stuff, so you'd do better in future to direct
questions like this to microsoft.public.win32.programmer.ui

With that said, here is the answer: you need to use the
WM_CTLCOLOREDIT message, but don't use GetDC.
Use the wParam and lParam values, and return a HBRUSH
to change the background, like this -

LRESULT CtlColorEdit(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{

// control's window handle is lParam, not hWnd
if((HWND)lParam==ClockFace)
{
// HDC of control is wParam
SetTextColor((HDC)wParam, 0x00C800);
// return new background brush
return (LRESULT)GetStockObject(BLACK_BRUSH);
}

// just use the default settings otherwise
return DefWindowProc(hWnd, message, wParam, lParam);
}
Good luck...

Jul 19 '05 #2
krlll wrote:
Matt wrote:
I'm having problems changing the text colors in an edit box
in my program.

This news group is for discussion of the c++ language itself,
not OS-specific stuff, so you'd do better in future to direct
questions like this to microsoft.public.win32.programmer.ui

With that said, here is the answer:


Why are you posting an off-topic reply to an off-topic question when you
know it's off-topic? The idea is to discourage off-topic posts, not
encourage them.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: GujuBoy | last post by:
i have a ansi.py file that i use in LINUX to change the text color to STDOUT when i use the "print" function...but when i move this ansi.py file over the windows...it does not work is there a...
2
by: Steve M | last post by:
Hello, I've been trying to change the text color on a windows console program I've been working on with no luck. I should mention that I'm a novice so please dummy up your replies. ...
5
by: Cecilia Bergengruen | last post by:
2 questions: 1)I inserted a menu in an mdi window form. I right clicked on a menu item and pressed edit names. I therefore edited all my menu item names. Then I right clicked and pressed edit...
4
by: JoelW | last post by:
Let's say you're programming in VB.NET, and you have: Dim str1 As String Dim str2 As String Dim str3 As String str1 = "I am red" str2 = "I am yellow" str3 = "I am dark green"
1
by: dotnettester | last post by:
Hi, I have implemented a datagrid where users can change the value of one column. But I have a problem, when a user clicks the 'edit' button and the column to edit changes into a text box. If...
7
by: Fabien LE LEZ | last post by:
Hello, I'd like to put, on a web page, a "place" where the user can type a rather long text, with automatic coloring of each word (e.g. a color depending on the number of letters of the word). ...
4
by: Sam Carleton | last post by:
How do I change the CSS colors via JavaScript DOM? Let me explain... I am working on a Windows application (in C#) that displays some HTML. In one place the HTML is a status window. What happens...
1
by: Brian Heibert | last post by:
Can anyone tell me how to create a Edit menu I am new to VB .Net and this news group Thanks, Brian
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.