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

x
?
Solved

Colour change

Posted on 1998-01-18
1
Medium Priority
?
794 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
[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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

610 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