Solved

Colour change

Posted on 1998-01-18
1
781 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 50 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Threads Delphi Programs 2 1,622
copy one tchart to another 1 527
Activex get website that activex running on 3 91
build html 5 client that connect to indy Tidtcpserver 3 395
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
An article on effective troubleshooting
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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