help with TP 1.5 
Author Message
 help with TP 1.5

I am taking a programming class at my high school.  We are using Turbo Pascal
1.5 for Windows.  Our teacher, however, has not worked much with this newer
version, but is very skilled with the earlier dos versions.  We have been
unable to utilize the procedures and functions dealing with coloring and
graphics.  I have looked at the samples that are provided with the compiler,
but have found them overly complicated and ultimately confusing.  What I need
is just some short sample code which performs one of these functions (e.g.
changing text or background color).  Just something basic is needed, which will
help us to learn off of so that we can eventually work with the more
complicated aspects of programming.  Thanking you in advance,

                                                          Trevor



Wed, 18 Jun 1902 08:00:00 GMT  
 help with TP 1.5

Quote:

> I am taking a programming class at my high school.  We are using Turbo Pascal
> 1.5 for Windows.  Our teacher, however, has not worked much with this newer
> version, but is very skilled with the earlier dos versions.  We have been
> unable to utilize the procedures and functions dealing with coloring and
> graphics.  I have looked at the samples that are provided with the compiler,
> but have found them overly complicated and ultimately confusing.

Very true. Be happy you don't have a C++ compiler; most of the examples provided
with C++ programming environments don't even compile correctly.

Quote:
> What I need is just some short sample code which performs one of these functions
> (e.g.
> changing text or background color).  Just something basic is needed, which will
> help us to learn off of so that we can eventually work with the more
> complicated aspects of programming.  Thanking you in advance,

To draw, you first need a window. Unfortunately, I don't know if and to what extent
TPW 1.5 supports object-oriented code.

Assuming it doesn't: You must create a new window class and register it (function
RegisterClass). Then call the CreateWindow function, followed by ShowWindow and
UpdateWindow. You must also define a procedure that will handle mouse clicks and
such. Creating a window manually is very cumbersome; I pray for you that there is a
sample program that demonstrates how to create a generic window.

If TPW supports object-oriented code, the following program will create a basic
window. Because I am using a later version, you might have to make some changes to
the code:

uses wintypes, winprocs, owindows;
type
  TApp = object(TApplication)
         end;
var
  app : TApp;
  DC  : HDC;
begin
  app.Init('');

  DC := GetDC(app.MainWindow^.hwindow);
  Rectangle(DC, 10, 10, 100, 100);

  app.Run;
  app.Done
end.

Every window has a device context. To draw to a window, you must first find out its
device context. This is done by calling the procedure GetDC and specifying the
window handle of the window in question. The corresponding line in the sample
program above is "DC := GetDC(app.MainWindow^.hwindow)". app is the object of type
TApplication, MainWindow is the predefined name of the main window of your
application (the one that appears when you launch the program) and hwindow is its
handle.
The program then draws a rectangle; its upper left corner is 10, 10 (relative to
the coordinates of the window), the lower right corner is 100, 100. Note that you
must specify the device context.

This is a very basic program. If you want to implement user interaction, you must
create an object derived from the type TWindow. You will be able to use buttons,
menus, checkboxes, etc. An event handler (TWindow.Paint) would avoid that the
rectangle disappears if the window is minimized or hidden by another window.



Wed, 18 Jun 1902 08:00:00 GMT  
 help with TP 1.5

[BPW 7]

Quote:
> With the risk of getting it wrong again:
> I think's it's a DOS IDE but - for the windows-part - almost the
> same units as in TPW1.5. are used. So: almost no change
> in language.

In fact, BP[W] 7 has both DOS and WIN IDE's, BP and BPW respectively. I
imagine in this case they'd use the Windows IDE.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Porting from TP for DOS 5.0 to TP for windows 1.5

2. StrPCopy and Copy in TP 1.5 Win and TP 7

3. Good books for tpw 1.5 for a true novice (tp 7.0 too) --- Please help

4. I know TP 7 (DOS), Now I need help learning TPW 1.5

5. Help- TP 1.5 for Windows

6. TP for W 1.5

7. Turbo Debugger - TP Win ver 1.5

8. I have TP for Win version 1.5

9. I need sample code for TP 1.5

10. graphics question should be TP 1.5

11. Colour in TP for Windows 1.5

12. TP WIN 1.5 - CRT UNIT - any fixes?

 

 
Powered by phpBB® Forum Software