Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change EditBox color

Posted on 2003-11-28
13
Medium Priority
?
312 Views
Last Modified: 2010-04-05
Var
    Hcol: HDC;

Begin
 Hcol:=GetWindowDC(HandleOfEditBox);
 SetBkColor(HCol,RGB(255,0,0));
 SetTextColor(Hcol,RGB(255,0,0));
End;

Ok any idea why this does not work?
0
Comment
Question by:craig_capel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
13 Comments
 

Accepted Solution

by:
Brr earned 200 total points
ID: 9838280
Dont know - but you can use the Color and Font.Color properties of the editbox
0
 
LVL 2

Author Comment

by:craig_capel
ID: 9838313
I am not using the VCL, i need to use windows API
0
 
LVL 3

Assisted Solution

by:JDuncan
JDuncan earned 200 total points
ID: 9838532
It may be that you are not drawing to the edit box eith the nex settings because this chages the text.

procedure TForm1.Button1Click(Sender: TObject);
Var
  Hcol: HDC;
  mystr : array [0..5] of char;
Begin
 mystr:='abcdef';
 Hcol:=GetWindowDC(Edit1.Handle);
 label1.caption:=inttohex(hcol,8);
 SetBkColor(HCol,RGB(0,100,0));
 SetTextColor(Hcol,RGB(128,0,0));
 TextOut(Hcol,0,0,myStr,5);
 ReleaseDC(Edit1.Handle,Hcol);
end;

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:craig_capel
ID: 9838585
I see what that's doing but it's not changing all of the edit box to a different color, just the text, but hey it's something to go on thanks....

i will keep trying...
0
 
LVL 2

Author Comment

by:craig_capel
ID: 9838590
Chances are i am going about it the wrong way, maybe it's a different call :O
0
 
LVL 3

Expert Comment

by:JDuncan
ID: 9838604
get the text and re draw it, you could maybe use the invalidaterect call to force a redraw or just do this

 Hcol:=GetWindowDC(Edit1.Handle);
 SetBkColor(HCol,RGB(0,100,0));
 SetTextColor(Hcol,RGB(128,0,0));
 GetWindowText(Hcol,myStr,6);
 TextOut(Hcol,0,0,myStr,5);
 ReleaseDC(Edit1.Handle,Hcol);
0
 
LVL 3

Expert Comment

by:JDuncan
ID: 9838721
This is strange , when you set the backgroud color the systems reports it as changed to
the new value .

It looks like you are only changing the windows context and this may be causing the delphi edit box to re paint to the original settings.

You amy have to create the edit box using windows calls instead of delphi calls to do what you want to do.


0
 
LVL 2

Author Comment

by:craig_capel
ID: 9840333
I use CreateWindowEx to make my edit control, there are no params to set the color of the edit box, you should be able to take the handle of the edit box (from any application) and with nothing more than the handle change the edit color box like doing...

EditBox1.Color:=$FF00FF;

That's all i am trying to do but in Win32 API
0
 
LVL 3

Expert Comment

by:JDuncan
ID: 9845336
What operating system are you using <=win98 or >=2000
0
 
LVL 2

Author Comment

by:craig_capel
ID: 9846824
Win2K
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question