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_VIS IBLE|WS_BORDER,
125,
75,
300,
100,
hwnd,
HMENU(CLOCKWIND OW),
NULL,
NULL);
HFONT StopFont =
CreateFont(100, 24,0,0,700,200, 0,0,0,0,0,0,0,T EXT("Verdana")) ;
SendMessage(Clo ckFace, WM_SETFONT, WPARAM(StopFont ),
MAKELPARAM(0,0) );
hdc = GetDC(ClockFace ); //tried putting this section under
WM_CTLCOLOREDIT , still didn't work
SetTextColor(hd c, 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. 2 8914
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.publi c.win32.program mer.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(HW ND 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((H DC)wParam, 0x00C800);
// return new background brush
return (LRESULT)GetSto ckObject(BLACK_ BRUSH);
}
// just use the default settings otherwise
return DefWindowProc(h Wnd, message, wParam, lParam);
}
Good luck...
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.publi c.win32.program mer.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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 version of ansi.py i can use for windows/linux....
please help
|
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.
Thanks-in-Advance
Steve
|
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 names again to return to the
normal view of the menu.
When I returned later on to muy menu names, they hadn´t been saved. How
do I use this utility (edit names), since the changes I edit don´t
prevail?
2) Is there a way to change the font and...
|
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"
|
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 the user then changes the text and hits
enter, onclick on the text box is executed. Can I change it to 'update' link.
So that when user finished changing the text in the text box and hits enter.
The 'update' link will be clicked.
| |
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).
The only solution I could think of is rather ugly: a <textareafor
the user to type in, and behind the <textarea>, one <spanfor each
word, with the same text and font, and a colored background.
I've put it there:...
|
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 is the static
HTML page is embedded into the application. The static page displayed
and then the C# code gets a hold of the HTML DOM from the web browser
and updates what pieces need to be updated.
What I need to do now is change the colors...
|
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
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |