Solved

Change EditBox color

Posted on 2003-11-28
13
301 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
  • 5
  • 4
13 Comments
 

Accepted Solution

by:
Brr earned 50 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 50 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now