?
Solved

Colour change

Posted on 1998-01-18
1
Medium Priority
?
795 Views
Last Modified: 2010-04-16
how do i change the text and background colour using Borland turbo pascal for windows.
Cheers
Scarhand
0
Comment
Question by:Scarhand
1 Comment
 
LVL 5

Accepted Solution

by:
inter earned 150 total points
ID: 1217167
In windows, when you want to draw any thing on windows. You should do it by calling windows internal functions called GDI (graphic driver interface) API(application programmers interface). To draw, you must first obtain a handle (an integer value like pointer that points to that memory object). Once you obtain the handle, you can modify its properties, and paint on it. The following example writes a Blue text on your window in Borland Pascal.

var
  ThePen, OldPeb : HPen; {these are defined by wintypes unit}
  TheDC  : HDC;
const
  Ts : PChar = 'This is test'#0;
begin
  TheDC := GetDC(hWnd);  {obtain device context handle for hWnd}
                         {Hwnd is a handle to out window ssigned}
                         {by Windows}
  ThePen := CreatePen(psSolid, 1, BLUE);
  OldPen := SelectObject(TheDC, ThePen);
  {Begining of any drawing}
  TextOut(TheDC, 10,10, Ts, Length(Ts)); {now draw text at 10,10}
                                         {Since the PEN is BLUE}
                               {The text will be blue}
  {End of any drawing}
  SelectObject(TheDC, OldPen); {Replace old pen}
  DeleteObject(ThePen);   {Free up pen}
  ReleaseDC(hWnd, TheDC); {Free up the DC}
end;

As you see the operation is a bit complex. This is due to the fact that windows drawing system should maintain all the applications drawings and prevent them from destroying other windows appereance.
To my personal oppinion if you want to program on windows you'd better program in Borland Delphi since you know pascal. If this not satisfy you I may give more info...
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

864 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